@formicoidea/labre-core 0.42.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
  2. package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
  3. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  5. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  6. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  7. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  8. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  9. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  10. package/dist/_pkgs/affine-block-callout/view.js +3 -0
  11. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  12. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  13. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  14. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  15. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  16. package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
  17. package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
  18. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
  19. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  20. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  23. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
  24. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
  25. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -0
  27. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
  28. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
  29. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  30. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +0 -2
  31. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -5
  32. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -1
  33. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +14 -6
  34. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
  35. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
  36. package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -0
  37. package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -0
  38. package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
  39. package/dist/_pkgs/affine-block-embed/index.js +1 -0
  40. package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
  41. package/dist/_pkgs/affine-block-embed/translations.js +28 -0
  42. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  43. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
  44. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  45. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  46. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
  47. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  48. package/dist/_pkgs/affine-block-frame/frame-manager.js +53 -19
  49. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  50. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  51. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  52. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  53. package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
  54. package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
  55. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  56. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  57. package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
  58. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
  59. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
  60. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  61. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  62. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  63. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  64. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  65. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  66. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  67. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  68. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  69. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  70. package/dist/_pkgs/affine-block-root/index.js +1 -0
  71. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  72. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  73. package/dist/_pkgs/affine-block-root/view.js +2 -0
  74. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  75. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  76. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  77. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  78. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  87. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  88. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  89. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  90. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  93. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  94. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  96. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  97. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  98. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +13 -1
  103. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +8 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/legend.js +59 -3
  105. package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  107. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  108. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  109. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  110. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  115. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  116. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  117. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  118. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
  119. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
  120. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  121. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +98 -19
  122. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  123. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  124. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  125. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  126. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  127. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  128. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  129. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  130. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  131. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  132. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  133. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  134. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +1 -1
  135. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  136. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  137. package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
  138. package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
  139. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
  140. package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
  141. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  142. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  143. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  144. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  145. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  146. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
  147. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  148. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  149. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  150. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  151. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  152. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  153. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  154. package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
  155. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  156. package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +5 -0
  157. package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
  158. package/dist/_pkgs/affine-components/context-menu/button.js +17 -1
  159. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  160. package/dist/_pkgs/affine-components/icons/ai.js +3 -3
  161. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  162. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  163. package/dist/_pkgs/affine-components/icons/list.js +7 -1
  164. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  165. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  166. package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
  167. package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
  168. package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
  169. package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
  170. package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
  171. package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
  172. package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
  173. package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
  174. package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
  175. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  176. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
  177. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +3 -3
  178. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  179. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  180. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  181. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  182. package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
  183. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
  184. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
  185. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  186. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  187. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +6 -4
  188. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +24 -8
  189. package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
  190. package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
  191. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  192. package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
  193. package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
  194. package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +6 -0
  195. package/dist/_pkgs/affine-gfx-mindmap/translations.js +10 -0
  196. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  197. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  198. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +5 -3
  199. package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
  200. package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
  201. package/dist/_pkgs/affine-gfx-template/builtin/other.js +13 -7
  202. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  203. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  204. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  205. package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
  206. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  207. package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
  208. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +5 -3
  209. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  210. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  211. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  212. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  213. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +56 -3
  214. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  215. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  216. package/dist/_pkgs/affine-gfx-text/translations.d.ts +8 -0
  217. package/dist/_pkgs/affine-gfx-text/translations.js +12 -0
  218. package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
  219. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  220. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  221. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  222. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  223. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  224. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  225. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  226. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  227. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  228. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  229. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  230. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  231. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  232. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  233. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  234. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  235. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  236. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  237. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  238. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  239. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  240. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  241. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  242. package/dist/_pkgs/affine-model/consts/text.d.ts +41 -2
  243. package/dist/_pkgs/affine-model/consts/text.js +50 -1
  244. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  245. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  246. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  247. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  248. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  249. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  250. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  251. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  252. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  253. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  254. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  255. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  256. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  257. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  258. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  259. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  260. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  261. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  262. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  263. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +13 -2
  264. package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -54
  265. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  266. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  267. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  268. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  269. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  270. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  271. package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
  272. package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
  273. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +25 -0
  274. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +90 -0
  275. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  276. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  277. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  278. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  279. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  280. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  281. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  282. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  283. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  284. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  285. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  286. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  287. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  288. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  289. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  290. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  291. package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
  292. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +15 -4
  293. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  294. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
  295. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
  296. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
  297. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  298. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  299. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  300. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  301. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  304. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  305. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  306. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  307. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  308. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  309. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  310. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  311. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  312. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  313. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +58 -0
  314. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +171 -1
  315. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  316. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
  317. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  318. package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
  319. package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
  320. package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
  321. package/dist/_pkgs/data-view/core/detail/field.js +2 -1
  322. package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
  323. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
  324. package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
  325. package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
  326. package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
  327. package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
  328. package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
  329. package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
  330. package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
  331. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
  332. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
  333. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
  334. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
  335. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  336. package/dist/_pkgs/std/gfx/controller.js +22 -2
  337. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  338. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  339. package/dist/_pkgs/std/gfx/index.js +3 -1
  340. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  341. package/dist/_pkgs/std/gfx/layer.js +73 -5
  342. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  343. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  344. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  345. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  346. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  347. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
  348. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  349. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  350. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  351. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  352. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  353. package/dist/_pkgs/std/utils/layer.js +64 -13
  354. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  355. package/dist/commands.js +6 -2
  356. package/dist/translations.js +15 -6
  357. package/package.json +13 -2
  358. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  359. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  360. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  361. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  362. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  363. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  364. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  365. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  366. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  367. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -1,9 +1,11 @@
1
- import { EdgelessClipboardConfigIdentifier, EdgelessCRUDIdentifier, SurfaceGroupLikeModel, } from '../../../affine-block-surface/index.js';
1
+ import { isFrameBlock } from '../../../affine-block-frame/index.js';
2
+ import { EdgelessClipboardConfigIdentifier, EdgelessCRUDIdentifier, resolveCreationLayer, writeModelLayer, } from '../../../affine-block-surface/index.js';
2
3
  import { Bound } from '../../../global/gfx/index.js';
3
4
  import { assertType } from '../../../global/utils/index.js';
4
- import { GfxControllerIdentifier, SortOrder, } from '../../../std/gfx/index.js';
5
+ import { DEFAULT_LAYER_ID, GfxControllerIdentifier, ownLayerOf, } from '../../../std/gfx/index.js';
5
6
  import { BlockSnapshotSchema } from '../../../store/index.js';
6
7
  import { createCanvasElement } from './canvas.js';
8
+ import { pastedIndexes, pastedParentage } from './paste-order.js';
7
9
  import { createNewPresentationIndexes, edgelessElementsBoundFromRawData, } from './utils.js';
8
10
  export const createElementsFromClipboardDataCommand = (ctx, next) => {
9
11
  const { std, elementsRawData } = ctx;
@@ -33,60 +35,116 @@ export const createElementsFromClipboardDataCommand = (ctx, next) => {
33
35
  const blockModels = [];
34
36
  const canvasElements = [];
35
37
  const allElements = [];
36
- for (const data of elementsRawData) {
37
- const { data: blockSnapshot } = BlockSnapshotSchema.safeParse(data);
38
- if (blockSnapshot) {
39
- const oldId = blockSnapshot.id;
40
- const config = std.getOptional(EdgelessClipboardConfigIdentifier(blockSnapshot.flavour));
41
- if (!config)
42
- continue;
43
- if (typeof blockSnapshot.props.index !== 'string') {
44
- console.error(`Block(id: ${oldId}) does not have index property`);
45
- continue;
46
- }
47
- const originalIndex = blockSnapshot.props.index;
48
- if (typeof blockSnapshot.props.xywh !== 'string') {
49
- console.error(`Block(id: ${oldId}) does not have xywh property`);
50
- continue;
51
- }
52
- assertType(blockSnapshot.props);
53
- blockSnapshot.props.xywh = getNewXYWH(blockSnapshot.props.xywh);
54
- blockSnapshot.props.lockedBySelf = false;
55
- const newId = await config.createBlock(blockSnapshot, context);
56
- if (!newId)
57
- continue;
58
- const block = std.store.getBlock(newId);
59
- if (!block)
60
- continue;
61
- assertType(block.model);
62
- blockModels.push(block.model);
63
- allElements.push(block.model);
64
- context.oldToNewIdMap.set(oldId, newId);
65
- context.originalIndexes.set(oldId, originalIndex);
66
- }
67
- else {
68
- assertType(data);
69
- const oldId = data.id;
38
+ // Read before anything is created: `createCanvasElement` rewrites a
39
+ // group's `children` with the new ids.
40
+ const oldParents = pastedParentage(elementsRawData);
41
+ // Decided before anything is created too, so that a canvas element is
42
+ // born with its final index: written afterwards, each index moved an
43
+ // element already on the board, through the layer manager, one by one.
44
+ const newIndexes = pastedIndexes(std, elementsRawData, oldParents, context.originalIndexes);
45
+ const blockIndexes = new Map();
46
+ // What each block's snapshot asked for, read before its config creates
47
+ // it; applied in the final transaction (`keepSourceLayerAndHide`).
48
+ const blockRequests = new Map();
49
+ // Canvas elements are written in as few transactions as the blocks allow,
50
+ // so a peer receives one update for a run of them instead of one per
51
+ // element (plus one per index fix-up). A block cannot join: its config's
52
+ // `createBlock` may be async (notes, texts, images and attachments go
53
+ // through the transformer, which awaits), and a Yjs transaction cannot
54
+ // span an `await`. So the run of canvas elements before a block is written
55
+ // first — the block may reference them (a frame's `childElementIds`) —
56
+ // and the last run is written together with the final indexes.
57
+ // ponytail: a block still costs its own transactions; a two-phase config
58
+ // contract (async prepare, then a sync write) is the upgrade path.
59
+ const pendingCanvasElements = [];
60
+ const seen = new Set();
61
+ const createPendingCanvasElements = () => {
62
+ for (const data of pendingCanvasElements) {
63
+ data.index = newIndexes.get(data.id) ?? data.index;
70
64
  const element = createCanvasElement(std, data, context, getNewXYWH(data.xywh));
71
65
  if (!element)
72
66
  continue;
73
67
  canvasElements.push(element);
74
68
  allElements.push(element);
75
- context.oldToNewIdMap.set(oldId, element.id);
76
- context.originalIndexes.set(oldId, element.index);
69
+ context.oldToNewIdMap.set(data.id, element.id);
77
70
  }
78
- }
79
- // remap old id to new id for the original index
80
- const oldIds = [...context.originalIndexes.keys()];
81
- oldIds.forEach(oldId => {
82
- const newId = context.oldToNewIdMap.get(oldId);
83
- const originalIndex = context.originalIndexes.get(oldId);
84
- if (newId && originalIndex) {
85
- context.originalIndexes.set(newId, originalIndex);
86
- context.originalIndexes.delete(oldId);
71
+ pendingCanvasElements.length = 0;
72
+ };
73
+ // One gesture, one undo step: close whatever the previous gesture left
74
+ // open in the undo manager's capture window.
75
+ // ponytail: the paste's own transactions then merge only while each ends
76
+ // within that window (500 ms) of the one before, so a block whose creation
77
+ // takes longer splits the step; the two-phase contract above removes the
78
+ // ceiling (the budget spec measures it on 406 elements).
79
+ std.store.captureSync();
80
+ for (const data of elementsRawData) {
81
+ // Clipboard data written before `sortEdgelessElements` deduplicated can
82
+ // list one element twice; the first copy is the one its container maps.
83
+ if (seen.has(data.id))
84
+ continue;
85
+ seen.add(data.id);
86
+ const { data: blockSnapshot } = BlockSnapshotSchema.safeParse(data);
87
+ if (!blockSnapshot) {
88
+ assertType(data);
89
+ pendingCanvasElements.push(data);
90
+ continue;
91
+ }
92
+ if (pendingCanvasElements.length > 0) {
93
+ std.store.transact(createPendingCanvasElements);
94
+ }
95
+ const oldId = blockSnapshot.id;
96
+ const config = std.getOptional(EdgelessClipboardConfigIdentifier(blockSnapshot.flavour));
97
+ if (!config)
98
+ continue;
99
+ if (typeof blockSnapshot.props.index !== 'string') {
100
+ console.error(`Block(id: ${oldId}) does not have index property`);
101
+ continue;
102
+ }
103
+ if (typeof blockSnapshot.props.xywh !== 'string') {
104
+ console.error(`Block(id: ${oldId}) does not have xywh property`);
105
+ continue;
87
106
  }
107
+ assertType(blockSnapshot.props);
108
+ blockSnapshot.props.xywh = getNewXYWH(blockSnapshot.props.xywh);
109
+ blockSnapshot.props.lockedBySelf = false;
110
+ const requested = {
111
+ layer: blockSnapshot.props.layer,
112
+ hiddenForEveryone: blockSnapshot.props.hiddenForEveryone,
113
+ };
114
+ const newId = await config.createBlock(blockSnapshot, context);
115
+ if (!newId)
116
+ continue;
117
+ const block = std.store.getBlock(newId);
118
+ if (!block)
119
+ continue;
120
+ assertType(block.model);
121
+ blockRequests.set(block.model, requested);
122
+ blockModels.push(block.model);
123
+ allElements.push(block.model);
124
+ context.oldToNewIdMap.set(oldId, newId);
125
+ const index = newIndexes.get(oldId);
126
+ if (index)
127
+ blockIndexes.set(block.model, index);
128
+ }
129
+ std.store.transact(() => {
130
+ createPendingCanvasElements();
131
+ const parents = new Map();
132
+ oldParents.forEach((oldParent, oldChild) => {
133
+ const child = context.oldToNewIdMap.get(oldChild);
134
+ const parent = context.oldToNewIdMap.get(oldParent);
135
+ if (child && parent)
136
+ parents.set(child, parent);
137
+ });
138
+ releaseChildrenFromAdoptingFrames(std, allElements, parents);
139
+ // A block config chooses its own index (a frame takes the top of the
140
+ // board, a note the transformer's): set the planned one afterwards.
141
+ const crud = std.get(EdgelessCRUDIdentifier);
142
+ blockIndexes.forEach((index, block) => {
143
+ if (block.index !== index)
144
+ crud.updateElement(block.id, { index });
145
+ });
146
+ blockRequests.forEach((requested, block) => keepSourceLayerAndHide(std, block, requested));
88
147
  });
89
- updatePastedElementsIndex(std, allElements, context.originalIndexes);
90
148
  return {
91
149
  canvasElements: canvasElements,
92
150
  blockModels: blockModels,
@@ -96,42 +154,62 @@ export const createElementsFromClipboardDataCommand = (ctx, next) => {
96
154
  createdElementsPromise: runner(),
97
155
  });
98
156
  };
99
- function updatePastedElementsIndex(std, elements, originalIndexes) {
100
- const gfx = std.get(GfxControllerIdentifier);
101
- const crud = std.get(EdgelessCRUDIdentifier);
102
- function compare(a, b) {
103
- if (a instanceof SurfaceGroupLikeModel && a.hasDescendant(b)) {
104
- return SortOrder.BEFORE;
105
- }
106
- else if (b instanceof SurfaceGroupLikeModel && b.hasDescendant(a)) {
107
- return SortOrder.AFTER;
108
- }
109
- else {
110
- const aGroups = a.groups;
111
- const bGroups = b.groups;
112
- let i = 1;
113
- let aGroup = aGroups.at(-i);
114
- let bGroup = bGroups.at(-i);
115
- while (aGroup === bGroup && aGroup) {
116
- ++i;
117
- aGroup = aGroups.at(-i);
118
- bGroup = bGroups.at(-i);
157
+ /**
158
+ * A pasted or duplicated block gets what a pasted element gets from
159
+ * `crud.addElement`, which forwards every serialized prop (ADR 0031 §6 and
160
+ * "What stays loadable"): its `layer` when it names a layer of this surface,
161
+ * else the active one, and its `hiddenForEveryone`. Most
162
+ * `EdgelessClipboardConfig.createBlock` rebuild the block from a handful of
163
+ * the snapshot's props (frame, image, attachment, bookmark, the embeds…), so
164
+ * a duplicate fell in the active layer and came back visible. The rule is
165
+ * applied once here, for every config, rather than in each of them; nothing
166
+ * is written when the config already carried both.
167
+ *
168
+ * `requested` is read BEFORE `createBlock`: the snapshot-pasting configs
169
+ * stamp `snapshot.props` in place, and an explicit default-layer request from
170
+ * a clone gesture (`prepareCloneData`) is gone from it afterwards. Called
171
+ * inside the paste's final transaction, beside the index fix-ups, so it adds
172
+ * no update of its own.
173
+ */
174
+ function keepSourceLayerAndHide(std, model, requested) {
175
+ const layer = resolveCreationLayer(std, requested.layer) ?? DEFAULT_LAYER_ID;
176
+ if (layer !== (ownLayerOf(model) ?? DEFAULT_LAYER_ID)) {
177
+ writeModelLayer(std, model, layer);
178
+ }
179
+ if (requested.hiddenForEveryone === true &&
180
+ model.props.hiddenForEveryone !== true) {
181
+ std.store.updateBlock(model, { hiddenForEveryone: true });
182
+ }
183
+ }
184
+ /**
185
+ * The paste creates children before their container (post-order), and the
186
+ * frame manager adopts whatever is created inside a frame — a block at once on
187
+ * `blockUpdated`, a canvas element a microtask later, which an `await` between
188
+ * two creations lets run. So a child of a pasted group or frame can already sit
189
+ * in the frame under the paste point when its own container claims it, and a
190
+ * child claimed twice is copied twice by the next duplicate.
191
+ *
192
+ * The paste knows the parentage it is writing; the frame's guess does not
193
+ * survive it. Each pasted container's children leave any other frame. The
194
+ * container itself is untouched, so a pasted group still lands in the frame it
195
+ * was dropped on.
196
+ */
197
+ function releaseChildrenFromAdoptingFrames(std, created, parents) {
198
+ if (parents.size === 0)
199
+ return;
200
+ const frames = std.store
201
+ .getModelsByFlavour('affine:frame')
202
+ .filter(isFrameBlock);
203
+ if (frames.length === 0)
204
+ return;
205
+ for (const child of created) {
206
+ const container = parents.get(child.id);
207
+ if (!container)
208
+ continue;
209
+ for (const frame of frames) {
210
+ if (frame.id !== container && frame.hasChild(child)) {
211
+ frame.removeChild(child);
119
212
  }
120
- aGroup = aGroup ?? a;
121
- bGroup = bGroup ?? b;
122
- return originalIndexes.get(aGroup.id) === originalIndexes.get(bGroup.id)
123
- ? SortOrder.SAME
124
- : originalIndexes.get(aGroup.id) < originalIndexes.get(bGroup.id)
125
- ? SortOrder.BEFORE
126
- : SortOrder.AFTER;
127
213
  }
128
214
  }
129
- const idxGenerator = gfx.layer.createIndexGenerator();
130
- const sortedElements = elements.sort(compare);
131
- sortedElements.forEach(ele => {
132
- const newIndex = idxGenerator();
133
- crud.updateElement(ele.id, {
134
- index: newIndex,
135
- });
136
- });
137
215
  }
@@ -0,0 +1,21 @@
1
+ import type { BlockStdScope } from '../../../std/index.js';
2
+ import { type SerializedElement } from '../../../std/gfx/index.js';
3
+ import type { BlockSnapshot } from '../../../store/index.js';
4
+ /**
5
+ * Child id → container id, as the pasted data spells it: a group's or a mind
6
+ * map's `children`, a frame's `childElementIds`.
7
+ *
8
+ * The paste reads its parentage from here and not from the models: a canvas
9
+ * container written in the final transaction registers its children (its
10
+ * `childIds`, `getGroup`) only when that transaction ends, so inside it a
11
+ * model would answer "no parent".
12
+ */
13
+ export declare function pastedParentage(elementsRawData: (SerializedElement | BlockSnapshot)[]): Map<string, string>;
14
+ /**
15
+ * The fresh indexes of the pasted elements, by their id in the pasted data: on
16
+ * top of the board, in the order they had where they were copied from — a
17
+ * container before its children, and otherwise by the original index of the
18
+ * topmost pasted ancestor (then of the next one down, then of the element
19
+ * itself). The original indexes are recorded in `originalIndexes`.
20
+ */
21
+ export declare function pastedIndexes(std: BlockStdScope, elementsRawData: (SerializedElement | BlockSnapshot)[], parents: Map<string, string>, originalIndexes: Map<string, string>): Map<string, string>;
@@ -0,0 +1,85 @@
1
+ import { GfxControllerIdentifier, SortOrder, } from '../../../std/gfx/index.js';
2
+ /*
3
+ * The paste's stacking order, decided on the PASTED DATA before any model
4
+ * exists. Its own module, which the package does not re-export, so that
5
+ * `paste-order-parity.unit.spec.ts` can hold its copy of the canvas'
6
+ * ancestor rule to `compareLayer` without making it API.
7
+ */
8
+ /**
9
+ * Child id → container id, as the pasted data spells it: a group's or a mind
10
+ * map's `children`, a frame's `childElementIds`.
11
+ *
12
+ * The paste reads its parentage from here and not from the models: a canvas
13
+ * container written in the final transaction registers its children (its
14
+ * `childIds`, `getGroup`) only when that transaction ends, so inside it a
15
+ * model would answer "no parent".
16
+ */
17
+ export function pastedParentage(elementsRawData) {
18
+ const parents = new Map();
19
+ for (const data of elementsRawData) {
20
+ const children = 'flavour' in data ? data.props.childElementIds : data.children;
21
+ if (!children || typeof children !== 'object')
22
+ continue;
23
+ for (const childId of Object.keys(children)) {
24
+ parents.set(childId, data.id);
25
+ }
26
+ }
27
+ return parents;
28
+ }
29
+ /**
30
+ * The fresh indexes of the pasted elements, by their id in the pasted data: on
31
+ * top of the board, in the order they had where they were copied from — a
32
+ * container before its children, and otherwise by the original index of the
33
+ * topmost pasted ancestor (then of the next one down, then of the element
34
+ * itself). The original indexes are recorded in `originalIndexes`.
35
+ */
36
+ export function pastedIndexes(std, elementsRawData, parents, originalIndexes) {
37
+ for (const data of elementsRawData) {
38
+ const index = 'flavour' in data ? data.props.index : data.index;
39
+ if (typeof index === 'string' && !originalIndexes.has(data.id)) {
40
+ originalIndexes.set(data.id, index);
41
+ }
42
+ }
43
+ // Pasted ancestors, nearest first — the order `GfxModel.groups` uses.
44
+ const ancestors = new Map();
45
+ for (const id of originalIndexes.keys()) {
46
+ const chain = [];
47
+ for (let parent = parents.get(id); parent && !chain.includes(parent); parent = parents.get(parent)) {
48
+ chain.push(parent);
49
+ }
50
+ ancestors.set(id, chain);
51
+ }
52
+ function compare(a, b) {
53
+ const aGroups = ancestors.get(a) ?? [];
54
+ const bGroups = ancestors.get(b) ?? [];
55
+ if (bGroups.includes(a)) {
56
+ return SortOrder.BEFORE;
57
+ }
58
+ else if (aGroups.includes(b)) {
59
+ return SortOrder.AFTER;
60
+ }
61
+ let i = 1;
62
+ let aGroup = aGroups.at(-i);
63
+ let bGroup = bGroups.at(-i);
64
+ while (aGroup === bGroup && aGroup) {
65
+ ++i;
66
+ aGroup = aGroups.at(-i);
67
+ bGroup = bGroups.at(-i);
68
+ }
69
+ const aIndex = originalIndexes.get(aGroup ?? a);
70
+ const bIndex = originalIndexes.get(bGroup ?? b);
71
+ return aIndex === bIndex
72
+ ? SortOrder.SAME
73
+ : aIndex < bIndex
74
+ ? SortOrder.BEFORE
75
+ : SortOrder.AFTER;
76
+ }
77
+ const nextIndex = std
78
+ .get(GfxControllerIdentifier)
79
+ .layer.createIndexGenerator();
80
+ const newIndexes = new Map();
81
+ [...originalIndexes.keys()].sort(compare).forEach(id => {
82
+ newIndexes.set(id, nextIndex());
83
+ });
84
+ return newIndexes;
85
+ }
@@ -51,6 +51,12 @@ export declare class EdgelessRootBlockComponent extends BlockComponent<RootBlock
51
51
  flavour?: boolean;
52
52
  }): () => void;
53
53
  connectedCallback(): void;
54
+ /**
55
+ * The grid follows `CanvasGrid` (ADR 0031 §11) through one attribute on
56
+ * the root, which both containers that paint it — this block's background
57
+ * and the surface container — key their `background-image: none` on.
58
+ */
59
+ private _initGrid;
54
60
  disconnectedCallback(): void;
55
61
  firstUpdated(): void;
56
62
  renderBlock(): import("lit-html").TemplateResult<1>;
@@ -38,7 +38,7 @@ import { isSingleMindMapNode } from '../../affine-gfx-mindmap/index.js';
38
38
  import { PanTool } from '../../affine-gfx-pointer/index.js';
39
39
  import { mountShapeTextEditor } from '../../affine-gfx-shape/index.js';
40
40
  import { NoteBlockModel, } from '../../affine-model/index.js';
41
- import { EditorSettingProvider, EditPropsStore, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
41
+ import { CanvasGrid, EditorSettingProvider, EditPropsStore, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
42
42
  import { isTouchPadPinchEvent, matchModels, requestConnectedFrame, requestThrottledConnectedFrame, } from '../../affine-shared/utils/index.js';
43
43
  import { IS_WINDOWS } from '../../global/env/index.js';
44
44
  import { Bound, Point, Vec } from '../../global/gfx/index.js';
@@ -110,6 +110,11 @@ let EdgelessRootBlockComponent = (() => {
110
110
  );
111
111
  }
112
112
 
113
+ /* ADR 0031 §11: the grid is a setting (CanvasGrid.visible$). */
114
+ affine-edgeless-root[data-grid-hidden] .edgeless-background {
115
+ background-image: none;
116
+ }
117
+
113
118
  .edgeless-container {
114
119
  color: var(--affine-text-primary-color);
115
120
  position: relative;
@@ -347,6 +352,7 @@ let EdgelessRootBlockComponent = (() => {
347
352
  connectedCallback() {
348
353
  super.connectedCallback();
349
354
  this._initViewport();
355
+ this._initGrid();
350
356
  this.keyboardManager = new EdgelessPageKeyboardManager(this);
351
357
  this.handleEvent('selectionChange', () => {
352
358
  const surface = this.host.selection.value.find((sel) => sel.is(SurfaceSelection));
@@ -359,6 +365,17 @@ let EdgelessRootBlockComponent = (() => {
359
365
  return;
360
366
  });
361
367
  }
368
+ /**
369
+ * The grid follows `CanvasGrid` (ADR 0031 §11) through one attribute on
370
+ * the root, which both containers that paint it — this block's background
371
+ * and the surface container — key their `background-image: none` on.
372
+ */
373
+ _initGrid() {
374
+ this._disposables.add(effect(() => {
375
+ const visible = this.std.getOptional(CanvasGrid)?.visible$.value ?? true;
376
+ this.toggleAttribute('data-grid-hidden', !visible);
377
+ }));
378
+ }
362
379
  disconnectedCallback() {
363
380
  super.disconnectedCallback();
364
381
  if (this._resizeObserver) {
@@ -7,6 +7,15 @@ import type { BlockSnapshot, Transformer } from '../../../store/index.js';
7
7
  * return all elements in the tree of the elements
8
8
  */
9
9
  export declare function getSortedCloneElements(elements: GfxModel[]): GfxModel[];
10
+ /**
11
+ * The data a clone gesture in the same document (duplicate, alt-drag)
12
+ * re-creates. Each model asks for its source's layer EXPLICITLY, the default
13
+ * layer included (ADR 0031, amendment "A duplicate stays in its source's
14
+ * layer, the default one included"): a default-layer model serializes no
15
+ * `layer`, and "absent" would hand its copy to the viewer's active layer. A
16
+ * paste goes through `prepareClipboardData` instead and keeps §6's rule — it
17
+ * cannot tell the default layer from another document.
18
+ */
10
19
  export declare function prepareCloneData(elements: GfxModel[], std: BlockStdScope): (BlockSnapshot | SerializedElement)[];
11
20
  export declare function serializeElement(element: GfxModel, elements: GfxModel[], job: Transformer): SerializedElement | {
12
21
  type: "block";
@@ -1,4 +1,5 @@
1
1
  import { ConnectorElementModel, GroupElementModel, MindmapElementModel, } from '../../../affine-model/index.js';
2
+ import { sourceLayerOf } from '../../../affine-block-surface/index.js';
2
3
  import { getTopElements, GfxBlockElementModel, isGfxGroupCompatibleModel, } from '../../../std/gfx/index.js';
3
4
  /**
4
5
  * return all elements in the tree of the elements
@@ -16,11 +17,29 @@ export function getSortedCloneElements(elements) {
16
17
  });
17
18
  return sortEdgelessElements([...set]);
18
19
  }
20
+ /**
21
+ * The data a clone gesture in the same document (duplicate, alt-drag)
22
+ * re-creates. Each model asks for its source's layer EXPLICITLY, the default
23
+ * layer included (ADR 0031, amendment "A duplicate stays in its source's
24
+ * layer, the default one included"): a default-layer model serializes no
25
+ * `layer`, and "absent" would hand its copy to the viewer's active layer. A
26
+ * paste goes through `prepareClipboardData` instead and keeps §6's rule — it
27
+ * cannot tell the default layer from another document.
28
+ */
19
29
  export function prepareCloneData(elements, std) {
20
30
  elements = sortEdgelessElements(elements);
21
31
  const job = std.store.getTransformer();
22
32
  const res = elements.map(element => {
23
33
  const data = serializeElement(element, elements, job);
34
+ if (!data)
35
+ return data;
36
+ const layer = sourceLayerOf(element);
37
+ if ('props' in data && data.type === 'block') {
38
+ data.props = { ...data.props, layer };
39
+ }
40
+ else {
41
+ data.layer = layer;
42
+ }
24
43
  return data;
25
44
  });
26
45
  return res.filter((d) => !!d);
@@ -77,7 +96,16 @@ export function sortEdgelessElements(elements) {
77
96
  const rest = elements.filter(element => !(element instanceof ConnectorElementModel));
78
97
  return [...rest, ...connectors];
79
98
  };
99
+ // A child may be claimed by two containers in a stored document (a frame and
100
+ // a group: an older paste let the frame adopt a child before the pasted group
101
+ // claimed it). `getTopElements` then reports it as a top element — its
102
+ // `.group` reads the other container — and the walk meets it again under its
103
+ // group. Visit each element once, or the paste creates it twice.
104
+ const visited = new Set();
80
105
  const traverse = (element) => {
106
+ if (visited.has(element))
107
+ return;
108
+ visited.add(element);
81
109
  if (isGfxGroupCompatibleModel(element)) {
82
110
  moveConnectorToEnd(element.childElements).forEach(child => traverse(child));
83
111
  }
@@ -1,5 +1,6 @@
1
1
  export * from './adapters/index.js';
2
2
  export * from './clipboard/index.js';
3
+ export * from './commands/copy-link-commands.js';
3
4
  export * from './commands/pivot-commands.js';
4
5
  export * from './commands/reading-commands.js';
5
6
  export * from './commands/tag-commands.js';
@@ -1,5 +1,6 @@
1
1
  export * from './adapters/index.js';
2
2
  export * from './clipboard/index.js';
3
+ export * from './commands/copy-link-commands.js';
3
4
  export * from './commands/pivot-commands.js';
4
5
  export * from './commands/reading-commands.js';
5
6
  export * from './commands/tag-commands.js';
@@ -1,7 +1,7 @@
1
1
  import { EdgelessCRUDIdentifier, getLastPropsKey, } from '../../affine-block-surface/index.js';
2
2
  import { EditPropsStore } from '../../affine-shared/services/index.js';
3
3
  import { pickStylePropsForKey } from '../../affine-shared/utils/index.js';
4
- import { IS_WINDOWS } from '../../global/env/index.js';
4
+ import { IS_LINUX, IS_WINDOWS } from '../../global/env/index.js';
5
5
  import { GfxControllerIdentifier, GfxPrimitiveElementModel, } from '../../std/gfx/index.js';
6
6
  import { duplicate } from '../edgeless/utils/clipboard-utils.js';
7
7
  /**
@@ -21,12 +21,13 @@ import { duplicate } from '../edgeless/utils/clipboard-utils.js';
21
21
  *
22
22
  * Computed by the `when` predicate AND by `run`, on purpose: the projection to
23
23
  * a shortcut only consumes the keystroke when `when` holds, and this gesture
24
- * must fall through when it has nothing to apply — on Windows `Mod+Y` is also
25
- * the `redo-windows` alias, which has to keep working.
24
+ * must fall through when it has nothing to apply — on Windows and Linux `Mod+Y`
25
+ * is also the `redo-windows` alias, which has to keep working.
26
26
  */
27
27
  function lastStyleTargets(std) {
28
28
  // Readonly: nothing to repaint, so `when` fails and the keystroke falls
29
- // through (on Windows Mod+Y is also the redo alias, itself readonly-gated).
29
+ // through (on Windows and Linux Mod+Y is also the redo alias, itself
30
+ // readonly-gated).
30
31
  if (std.store.readonly)
31
32
  return [];
32
33
  const gfx = std.get(GfxControllerIdentifier);
@@ -72,7 +73,9 @@ export const coreCommands = [
72
73
  },
73
74
  },
74
75
  {
75
- // Windows-only redo alias (Ctrl+Y); not bound on mac (empty combo).
76
+ // Redo alias (Ctrl+Y) on Windows and Linux; not bound on mac (empty
77
+ // combo). The id still says "windows": command ids are persisted in
78
+ // users' override tables, so it is kept rather than renamed.
76
79
  id: 'redo-windows',
77
80
  owner: 'core',
78
81
  kind: 'action',
@@ -84,7 +87,7 @@ export const coreCommands = [
84
87
  scope: 'global',
85
88
  defaultKeys: { mac: [], other: ['Control-y'] },
86
89
  availability: 'always',
87
- when: () => IS_WINDOWS,
90
+ when: () => IS_WINDOWS || IS_LINUX,
88
91
  run: std => {
89
92
  if (std.store.canRedo)
90
93
  std.store.redo();
@@ -33,7 +33,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
33
  return useValue ? value : void 0;
34
34
  };
35
35
  import { EdgelessCRUDIdentifier, getBgGridGap, } from '../../affine-block-surface/index.js';
36
- import { EditorSettingProvider, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
36
+ import { documentShowsGrid, EditorSettingProvider, FontLoaderService, ThemeProvider, ViewportElementProvider, } from '../../affine-shared/services/index.js';
37
37
  import { requestThrottledConnectedFrame } from '../../affine-shared/utils/index.js';
38
38
  import { BlockComponent, SurfaceSelection, } from '../../std/index.js';
39
39
  import { GfxControllerIdentifier, } from '../../std/gfx/index.js';
@@ -95,6 +95,11 @@ let EdgelessRootPreviewBlockComponent = (() => {
95
95
  );
96
96
  }
97
97
 
98
+ /* ADR 0031 §11: a preview follows the document's showGrid alone. */
99
+ affine-edgeless-root-preview .edgeless-background.grid-hidden {
100
+ background-image: none;
101
+ }
102
+
98
103
  @media print {
99
104
  .selected {
100
105
  background-color: transparent !important;
@@ -208,8 +213,16 @@ let EdgelessRootPreviewBlockComponent = (() => {
208
213
  ...this.backgroundStyle,
209
214
  background: this.overrideBackground,
210
215
  });
216
+ // A preview is a picture of the document, not a viewer's session: no
217
+ // viewer override and no host default, only what the document saved.
218
+ const gridClass = documentShowsGrid(this.surfaceBlockModel)
219
+ ? ''
220
+ : ' grid-hidden';
211
221
  return html `
212
- <div class="edgeless-background edgeless-container" style=${background}>
222
+ <div
223
+ class="edgeless-background edgeless-container${gridClass}"
224
+ style=${background}
225
+ >
213
226
  <gfx-viewport
214
227
  .enableChildrenSchedule=${!this._disableScheduleUpdate}
215
228
  .viewport=${this._gfx.viewport}
@@ -4,6 +4,7 @@ import { ToolbarModuleExtension, ViewportElementExtension, } from '../affine-sha
4
4
  import { BlockFlavourIdentifier, BlockViewExtension, FlavourExtension, CommandExtension, ShortcutKeymapExtension, } from '../std/index.js';
5
5
  import { literal } from 'lit/static-html.js';
6
6
  import { PageClipboard, ReadOnlyClipboard } from './clipboard/index.js';
7
+ import { copyLinkCommands } from './commands/copy-link-commands.js';
7
8
  import { pivotCommands } from './commands/pivot-commands.js';
8
9
  import { readingCommands } from './commands/reading-commands.js';
9
10
  import { tagCommands } from './commands/tag-commands.js';
@@ -70,6 +71,7 @@ export class RootViewExtension extends ViewExtensionProvider {
70
71
  ...pivotCommands,
71
72
  ...tagCommands,
72
73
  ...readingCommands,
74
+ ...copyLinkCommands,
73
75
  ]),
74
76
  ShortcutKeymapExtension('global'),
75
77
  ToolbarModuleExtension({
@@ -1,6 +1,6 @@
1
- import type { ExtensionType } from '../../../../../store/index.js';
2
1
  import type { MarkdownAST } from '../../../../affine-shared/adapters/index.js';
3
2
  import { type ServiceIdentifier } from '../../../../global/di/index.js';
3
+ import type { ExtensionType } from '../../../../store/index.js';
4
4
  import type { ElementModelMatcher } from '../../type.js';
5
5
  export type ElementToMarkdownAdapterMatcher = ElementModelMatcher<MarkdownAST>;
6
6
  export declare const ElementToMarkdownAdapterMatcherIdentifier: ServiceIdentifier<ElementToMarkdownAdapterMatcher> & (<U extends ElementToMarkdownAdapterMatcher = ElementToMarkdownAdapterMatcher>(variant: import("../../../../global/di/types.js").ServiceVariant) => ServiceIdentifier<U>);