@formicoidea/labre-core 0.43.1 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
  2. package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
  3. package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.d.ts +43 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-callout-into.js +109 -0
  5. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  6. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  7. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  8. package/dist/_pkgs/affine-block-callout/configs/toolbar.d.ts +65 -0
  9. package/dist/_pkgs/affine-block-callout/configs/toolbar.js +178 -0
  10. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  11. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  12. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  13. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  14. package/dist/_pkgs/affine-block-callout/view.js +10 -1
  15. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  16. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  17. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  18. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  19. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  20. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  23. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  24. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  25. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  27. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  28. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  29. package/dist/_pkgs/affine-block-frame/commands.d.ts +27 -0
  30. package/dist/_pkgs/affine-block-frame/commands.js +49 -0
  31. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +16 -6
  32. package/dist/_pkgs/affine-block-frame/frame-manager.js +58 -22
  33. package/dist/_pkgs/affine-block-frame/frame-order.d.ts +43 -0
  34. package/dist/_pkgs/affine-block-frame/frame-order.js +93 -0
  35. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  36. package/dist/_pkgs/affine-block-frame/index.d.ts +2 -0
  37. package/dist/_pkgs/affine-block-frame/index.js +2 -0
  38. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.d.ts +10 -2
  39. package/dist/_pkgs/affine-block-frame/present/frame-order-menu.js +32 -18
  40. package/dist/_pkgs/affine-block-frame/view.js +6 -0
  41. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  42. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  43. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  44. package/dist/_pkgs/affine-block-note/configs/toolbar.d.ts +19 -0
  45. package/dist/_pkgs/affine-block-note/configs/toolbar.js +38 -23
  46. package/dist/_pkgs/affine-block-note/translations.d.ts +2 -1
  47. package/dist/_pkgs/affine-block-note/translations.js +14 -6
  48. package/dist/_pkgs/affine-block-root/configs/toolbar.js +48 -3
  49. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  50. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  51. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  52. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  53. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  54. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  55. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  56. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  57. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  58. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  59. package/dist/_pkgs/affine-block-root/translations.d.ts +7 -2
  60. package/dist/_pkgs/affine-block-root/translations.js +10 -13
  61. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  62. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  63. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  64. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  65. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  66. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  67. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  68. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  69. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  70. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  72. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  73. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  74. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  75. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  76. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  77. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  78. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  80. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  81. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  83. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  84. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  85. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  87. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  88. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  89. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  90. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  91. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  92. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  93. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +91 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +285 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +80 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +355 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  98. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  102. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +86 -15
  103. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  105. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  107. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  108. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  109. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  110. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  115. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  116. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  117. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  118. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  119. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  120. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  121. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  122. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  123. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  124. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  125. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  126. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  127. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  128. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  129. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  130. package/dist/_pkgs/affine-components/context-menu/button.js +14 -0
  131. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  132. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  133. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  134. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  135. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  136. package/dist/_pkgs/affine-components/portal/portal.d.ts +1 -1
  137. package/dist/_pkgs/affine-foundation/view.d.ts +8 -8
  138. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  139. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.d.ts +34 -2
  140. package/dist/_pkgs/affine-fragment-frame-panel/body/frame-panel-body.js +194 -81
  141. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.d.ts +7 -4
  142. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +9 -24
  143. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  144. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  145. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +2 -0
  146. package/dist/_pkgs/affine-fragment-frame-panel/index.js +2 -0
  147. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  148. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  149. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +3 -2
  150. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +1 -1
  151. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  152. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  153. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  154. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +1 -1
  155. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  156. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  157. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  158. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +2 -1
  159. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  160. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  161. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  162. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  163. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +53 -2
  164. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  165. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  166. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  167. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  168. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  169. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  170. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  171. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  172. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  173. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  174. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  175. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  176. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  177. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  178. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  179. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  180. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  181. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  182. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  183. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  184. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  185. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  186. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  187. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  188. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  189. package/dist/_pkgs/affine-model/consts/text.d.ts +26 -0
  190. package/dist/_pkgs/affine-model/consts/text.js +25 -0
  191. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  192. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  193. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  194. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  195. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  196. package/dist/_pkgs/affine-model/utils/types.d.ts +2 -2
  197. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  198. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  199. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  200. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  201. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  202. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  203. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  204. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  205. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  206. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +31 -4
  207. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  208. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  209. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  210. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  211. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +2 -2
  212. package/dist/_pkgs/affine-shared/services/font-loader/font-loader-service.d.ts +3 -3
  213. package/dist/_pkgs/affine-shared/services/index.d.ts +4 -1
  214. package/dist/_pkgs/affine-shared/services/index.js +4 -1
  215. package/dist/_pkgs/affine-shared/services/link-preview-service/link-preview-storage.d.ts +4 -4
  216. package/dist/_pkgs/affine-shared/services/outline-panel-service.d.ts +31 -0
  217. package/dist/_pkgs/affine-shared/services/outline-panel-service.js +17 -0
  218. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  219. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  220. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  221. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  222. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +16 -0
  223. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +28 -0
  224. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  225. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  226. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  227. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  228. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  229. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  230. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  231. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  232. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  233. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  234. package/dist/_pkgs/affine-shared/utils/index.d.ts +3 -0
  235. package/dist/_pkgs/affine-shared/utils/index.js +3 -0
  236. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  237. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  238. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  239. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  240. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.d.ts +85 -0
  241. package/dist/_pkgs/affine-shared/utils/panel-reorder-drag.js +162 -0
  242. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +10 -3
  243. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  244. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  245. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  246. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  247. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  248. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +62 -0
  249. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +94 -0
  250. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  251. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  252. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  253. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  254. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  255. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  256. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +186 -0
  257. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1417 -0
  258. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +52 -0
  259. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +161 -1
  260. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  261. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  262. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  263. package/dist/_pkgs/std/gfx/controller.js +22 -2
  264. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  265. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  266. package/dist/_pkgs/std/gfx/index.js +3 -1
  267. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  268. package/dist/_pkgs/std/gfx/layer.js +73 -5
  269. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  270. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  271. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  272. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  273. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  274. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  275. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  276. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  277. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  278. package/dist/_pkgs/std/scope/std-scope.d.ts +1 -1
  279. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  280. package/dist/_pkgs/std/utils/layer.js +64 -13
  281. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  282. package/dist/commands.js +6 -1
  283. package/dist/host-panels.d.ts +90 -0
  284. package/dist/host-panels.js +111 -0
  285. package/dist/translations.js +10 -6
  286. package/package.json +13 -2
  287. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  288. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  289. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.d.ts +0 -27
  290. package/dist/_pkgs/affine-fragment-frame-panel/utils/drag.js +0 -96
  291. package/dist/_pkgs/affine-shared/services/sidebar-service.d.ts +0 -8
  292. package/dist/_pkgs/affine-shared/services/sidebar-service.js +0 -7
  293. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  294. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  295. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  296. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  297. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  298. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  299. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  300. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -12,11 +12,13 @@ export const CALLOUT_SLASH_DESCRIPTION = [
12
12
  ];
13
13
  /** The item's tooltip caption says the exact same word as its name. */
14
14
  export const CALLOUT_SLASH_CAPTION = CALLOUT_SLASH_NAME;
15
+ /** "Turn into → Callout" names the block with the slash item's own word. */
16
+ export const CALLOUT_TURN_INTO_NAME = CALLOUT_SLASH_NAME;
15
17
  /**
16
18
  * Every wording declared above, in declaration order — walked by
17
19
  * `PACKAGE_WORDINGS` in `packages/affine/all/src/translations.ts`. The
18
- * caption alias is not listed again, same rule other packages' chrome
19
- * aliases already follow.
20
+ * caption and turn-into aliases are not listed again, same rule other
21
+ * packages' chrome aliases already follow.
20
22
  */
21
23
  export const CALLOUT_WORDINGS = [
22
24
  CALLOUT_SLASH_NAME,
@@ -1,9 +1,13 @@
1
1
  import { ViewExtensionProvider, } from '../affine-ext-loader/index.js';
2
+ import { TextConversionEntryExtension } from '../affine-rich-text/index.js';
3
+ import { ToolbarModuleExtension } from '../affine-shared/services/index.js';
2
4
  import { SlashMenuConfigExtension } from '../affine-widget-slash-menu/index.js';
3
- import { BlockViewExtension, FlavourExtension } from '../std/index.js';
5
+ import { BlockFlavourIdentifier, BlockViewExtension, FlavourExtension, } from '../std/index.js';
4
6
  import { literal } from 'lit/static-html.js';
5
7
  import { CalloutKeymapExtension } from './callout-keymap.js';
6
8
  import { calloutSlashMenuConfig } from './configs/slash-menu.js';
9
+ import { calloutToolbarConfig } from './configs/toolbar.js';
10
+ import { calloutTurnIntoEntry } from './configs/turn-into.js';
7
11
  import { effects } from './effects.js';
8
12
  export class CalloutViewExtension extends ViewExtensionProvider {
9
13
  constructor() {
@@ -21,6 +25,11 @@ export class CalloutViewExtension extends ViewExtensionProvider {
21
25
  BlockViewExtension('affine:callout', literal `affine-callout`),
22
26
  CalloutKeymapExtension,
23
27
  SlashMenuConfigExtension('affine:callout', calloutSlashMenuConfig),
28
+ TextConversionEntryExtension(calloutTurnIntoEntry),
29
+ ToolbarModuleExtension({
30
+ id: BlockFlavourIdentifier('affine:callout'),
31
+ config: calloutToolbarConfig,
32
+ }),
24
33
  ]);
25
34
  }
26
35
  }
@@ -6,8 +6,21 @@ export declare class CodeBlockHighlighter extends LifeCycleWatcher {
6
6
  private _darkThemeKey;
7
7
  private _lightThemeKey;
8
8
  highlighter$: Signal<HighlighterCore | null>;
9
+ /**
10
+ * In-flight grammar loads, one per language. Per instance rather than
11
+ * static: each editor owns its own shiki core, and a grammar loaded into
12
+ * another editor's core is not loaded into this one.
13
+ */
14
+ private readonly _languageLoads;
9
15
  get themeKey(): string | undefined;
10
16
  private readonly _loadTheme;
17
+ /**
18
+ * Loads a grammar into the shiki core, sharing the pending promise between
19
+ * concurrent callers (every code block of that language asks at once on
20
+ * first paint). A settled load leaves the map, so a failed one is retried
21
+ * on the next request.
22
+ */
23
+ loadLanguage(lang: string, input: Parameters<HighlighterCore['loadLanguage']>[0]): Promise<void>;
11
24
  mounted(): void;
12
25
  unmounted(): void;
13
26
  }
@@ -10,6 +10,12 @@ export class CodeBlockHighlighter extends LifeCycleWatcher {
10
10
  constructor() {
11
11
  super(...arguments);
12
12
  this.highlighter$ = signal(null);
13
+ /**
14
+ * In-flight grammar loads, one per language. Per instance rather than
15
+ * static: each editor owns its own shiki core, and a grammar loaded into
16
+ * another editor's core is not loaded into this one.
17
+ */
18
+ this._languageLoads = new Map();
13
19
  this._loadTheme = async (highlighter) => {
14
20
  const config = this.std.getOptional(CodeBlockConfigExtension.identifier);
15
21
  const darkTheme = config?.theme?.dark ?? CODE_BLOCK_DEFAULT_DARK_THEME;
@@ -27,6 +33,26 @@ export class CodeBlockHighlighter extends LifeCycleWatcher {
27
33
  ? this._darkThemeKey
28
34
  : this._lightThemeKey;
29
35
  }
36
+ /**
37
+ * Loads a grammar into the shiki core, sharing the pending promise between
38
+ * concurrent callers (every code block of that language asks at once on
39
+ * first paint). A settled load leaves the map, so a failed one is retried
40
+ * on the next request.
41
+ */
42
+ loadLanguage(lang, input) {
43
+ const pending = this._languageLoads.get(lang);
44
+ if (pending)
45
+ return pending;
46
+ const highlighter = this.highlighter$.peek();
47
+ if (!highlighter) {
48
+ return Promise.reject(new Error('Code block highlighter is not ready'));
49
+ }
50
+ const load = highlighter.loadLanguage(input).finally(() => {
51
+ this._languageLoads.delete(lang);
52
+ });
53
+ this._languageLoads.set(lang, load);
54
+ return load;
55
+ }
30
56
  mounted() {
31
57
  super.mounted();
32
58
  createHighlighterCore({
@@ -32,6 +32,12 @@ export declare class CodeBlockComponent extends CaptionedBlockComponent<CodeBloc
32
32
  */
33
33
  get showLineNumbers(): boolean;
34
34
  get topContenteditableElement(): BlockComponent<import("../store/index.js").BlockModel<object>, import("../std/index.js").BlockService, string> | null;
35
+ /**
36
+ * Bumped on every highlight request: a grammar load that resolves after a
37
+ * newer request (another language, or plain text) must not repaint the
38
+ * block with its stale tokens (#416).
39
+ */
40
+ private _highlightRequestId;
35
41
  private _updateHighlightTokens;
36
42
  /**
37
43
  * Stable signal: true when the global editor setting enables line numbers.
@@ -84,6 +84,12 @@ let CodeBlockComponent = (() => {
84
84
  ? matchedInfo.name
85
85
  : translateKey(this.std, ...CODE_PLAIN_TEXT_LANGUAGE);
86
86
  });
87
+ /**
88
+ * Bumped on every highlight request: a grammar load that resolves after a
89
+ * newer request (another language, or plain text) must not repaint the
90
+ * block with its stale tokens (#416).
91
+ */
92
+ this._highlightRequestId = 0;
87
93
  /**
88
94
  * Stable signal: true when the global editor setting enables line numbers.
89
95
  * Defaults to true. Updated reactively by an effect in connectedCallback.
@@ -146,6 +152,7 @@ let CodeBlockComponent = (() => {
146
152
  return this.rootComponent;
147
153
  }
148
154
  _updateHighlightTokens() {
155
+ const requestId = ++this._highlightRequestId;
149
156
  const modelLang = this.model.props.language$.value;
150
157
  if (modelLang === null) {
151
158
  this.highlightTokens$.value = [];
@@ -168,9 +175,11 @@ let CodeBlockComponent = (() => {
168
175
  const code = this.model.props.text.toString();
169
176
  const loadedLanguages = highlighter.getLoadedLanguages();
170
177
  if (!loadedLanguages.includes(lang)) {
171
- highlighter
172
- .loadLanguage(langImport)
178
+ this.highlighter
179
+ .loadLanguage(lang, langImport)
173
180
  .then(() => {
181
+ if (requestId !== this._highlightRequestId)
182
+ return;
174
183
  this.highlightTokens$.value = highlighter.codeToTokensBase(code, {
175
184
  lang,
176
185
  theme,
@@ -42,7 +42,17 @@ import { css, LitElement, nothing } from 'lit';
42
42
  import { property, query } from 'lit/decorators.js';
43
43
  import { styleMap } from 'lit/directives/style-map.js';
44
44
  import { html } from 'lit/static-html.js';
45
- import { CODE_SEARCH_FOR_LANGUAGE } from '../../translations.js';
45
+ import { CODE_PLAIN_TEXT_LANGUAGE, CODE_SEARCH_FOR_LANGUAGE, } from '../../translations.js';
46
+ /**
47
+ * The list name of the Plain Text entry, which stands for `language: null`
48
+ * (#417). A colon never appears in a shiki language id, so it cannot collide
49
+ * with one, and no query starting with a letter matches it by name. It lives
50
+ * in the list and its persisted order only, never in the model.
51
+ */
52
+ const PLAIN_TEXT_ITEM_NAME = ':plain-text';
53
+ function languageOf(item) {
54
+ return item.name === PLAIN_TEXT_ITEM_NAME ? null : item.name;
55
+ }
46
56
  let LanguageListButton = (() => {
47
57
  let _classSuper = WithDisposable(SignalWatcher(LitElement));
48
58
  let __langButton_decorators;
@@ -95,16 +105,29 @@ let LanguageListButton = (() => {
95
105
  connectedCallback() {
96
106
  super.connectedCallback();
97
107
  const langList = localStorage.getItem('blocksuite:code-block:lang-list');
98
- if (langList) {
99
- this._sortedBundledLanguages = JSON.parse(langList);
100
- }
101
- else {
102
- this._sortedBundledLanguages = this.blockComponent.langs.map(lang => ({
108
+ const languages = langList
109
+ ? JSON.parse(langList)
110
+ : this.blockComponent.langs.map(lang => ({
103
111
  label: lang.name,
104
112
  name: lang.id,
105
113
  aliases: lang.aliases,
106
114
  }));
115
+ // A list persisted before the entry existed lacks it, and a persisted
116
+ // label is in the locale of the session that wrote it: keep the entry's
117
+ // recently-used position, refresh its words.
118
+ const plainText = {
119
+ label: translateKey(this.blockComponent.std, ...CODE_PLAIN_TEXT_LANGUAGE),
120
+ name: PLAIN_TEXT_ITEM_NAME,
121
+ aliases: ['plain', 'text', 'none'],
122
+ };
123
+ const index = languages.findIndex(item => item.name === PLAIN_TEXT_ITEM_NAME);
124
+ if (index === -1) {
125
+ languages.unshift(plainText);
126
+ }
127
+ else {
128
+ languages[index] = plainText;
107
129
  }
130
+ this._sortedBundledLanguages = languages;
108
131
  this.disposables.add(() => {
109
132
  localStorage.setItem('blocksuite:code-block:lang-list', JSON.stringify(this._sortedBundledLanguages));
110
133
  });
@@ -169,7 +192,7 @@ let LanguageListButton = (() => {
169
192
  sortedBundledLanguages.unshift(item);
170
193
  }
171
194
  this.blockComponent.store.transact(() => {
172
- this.blockComponent.model.props.language$.value = item.name;
195
+ this.blockComponent.model.props.language$.value = languageOf(item);
173
196
  });
174
197
  const std = this.blockComponent.std;
175
198
  const mode = std.getOptional(DocModeProvider)?.getEditorMode() ?? 'page';
@@ -183,7 +206,7 @@ let LanguageListButton = (() => {
183
206
  control: item.name,
184
207
  });
185
208
  },
186
- active: item => item.name === this.blockComponent.model.props.language,
209
+ active: item => languageOf(item) === this.blockComponent.model.props.language,
187
210
  items: this._sortedBundledLanguages,
188
211
  };
189
212
  showPopFilterableList({
@@ -8,6 +8,17 @@ export declare const edgelessTextToolbarConfig: {
8
8
  }, {
9
9
  readonly id: "c.font-style";
10
10
  readonly content: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => import("lit-html").TemplateResult<1> | null;
11
+ }, {
12
+ readonly id: "c.text-decoration";
13
+ readonly when: boolean;
14
+ readonly actions: {
15
+ id: "a.underline" | "b.overline";
16
+ icon: import("lit-html").TemplateResult<1>;
17
+ tooltipWording: import("../../affine-shared/services/index.js").ChromeWording;
18
+ when: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => boolean;
19
+ active: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => boolean;
20
+ run: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => void;
21
+ }[];
11
22
  }, {
12
23
  readonly id: "d.font-size";
13
24
  readonly when: boolean;
@@ -0,0 +1,20 @@
1
+ import { type BlockSvgPainter } from '../affine-block-surface/index.js';
2
+ import { type EdgelessTextBlockModel } from '../affine-model/index.js';
3
+ /**
4
+ * An edgeless text, redrawn as VECTOR text for "Export SVG" (ADR 0025,
5
+ * amendment of 2026-10-04).
6
+ *
7
+ * The block is DOM, so no canvas renderer paints it; this lays it out the way
8
+ * its CSS does, with the canvas text renderer's own font string and wrapping
9
+ * (`@labre/affine-gfx-text`): one line run per paragraph, its size and weight
10
+ * from `HEADING_SCALE` for a heading and from the 15px body otherwise, wrapped
11
+ * to the block's width only when the block has one (`hasMaxWidth`), then
12
+ * rotated about the block's centre and scaled by `scale`, as on screen.
13
+ *
14
+ * ponytail: each paragraph is drawn in the BLOCK's style — inline bold, italic,
15
+ * colour and links are flattened, list bullets and numbers are not drawn, and
16
+ * heading margins are ignored. Upgrade by walking the paragraph's deltas the
17
+ * way `wrapTextDeltas` does for a canvas text, when a board needs it.
18
+ */
19
+ export declare const edgelessTextSvgPainter: BlockSvgPainter<EdgelessTextBlockModel>;
20
+ export declare const EdgelessTextSvgPainterExtension: import("../store/index.js").ExtensionType;
@@ -0,0 +1,76 @@
1
+ import { BlockSvgPainterExtension, } from '../affine-block-surface/index.js';
2
+ import { getFontString, wrapText } from '../affine-gfx-text/index.js';
3
+ import { DefaultTheme } from '../affine-model/index.js';
4
+ import { HEADING_SCALE } from '../affine-shared/consts/index.js';
5
+ import { EDGELESS_TEXT_BASE_FONT_SIZE } from './edgeless-toolbar/font-size.js';
6
+ /** `--affine-line-height` is `calc(1em + 8px)`: what a body line adds to its size. */
7
+ const BODY_LINE_EXTRA = 8;
8
+ /** The container's 1px border, which the text sits inside. */
9
+ const BORDER = 1;
10
+ /** Every paragraph and list item of the block, depth first, as plain text. */
11
+ function runsOf(model, runs = []) {
12
+ for (const child of model.children) {
13
+ if (child.text) {
14
+ const type = child.props.type;
15
+ runs.push({
16
+ level: type !== undefined && type in HEADING_SCALE
17
+ ? type
18
+ : undefined,
19
+ text: child.text.toString(),
20
+ });
21
+ }
22
+ runsOf(child, runs);
23
+ }
24
+ return runs;
25
+ }
26
+ /**
27
+ * An edgeless text, redrawn as VECTOR text for "Export SVG" (ADR 0025,
28
+ * amendment of 2026-10-04).
29
+ *
30
+ * The block is DOM, so no canvas renderer paints it; this lays it out the way
31
+ * its CSS does, with the canvas text renderer's own font string and wrapping
32
+ * (`@labre/affine-gfx-text`): one line run per paragraph, its size and weight
33
+ * from `HEADING_SCALE` for a heading and from the 15px body otherwise, wrapped
34
+ * to the block's width only when the block has one (`hasMaxWidth`), then
35
+ * rotated about the block's centre and scaled by `scale`, as on screen.
36
+ *
37
+ * ponytail: each paragraph is drawn in the BLOCK's style — inline bold, italic,
38
+ * colour and links are flattened, list bullets and numbers are not drawn, and
39
+ * heading margins are ignored. Upgrade by walking the paragraph's deltas the
40
+ * way `wrapTextDeltas` does for a canvas text, when a board needs it.
41
+ */
42
+ export const edgelessTextSvgPainter = (model, ctx, matrix, renderer) => {
43
+ const { scale, rotate, color, fontFamily, fontStyle, fontWeight, textAlign, hasMaxWidth, } = model.props;
44
+ const [, , w, h] = model.deserializedXYWH;
45
+ ctx.setTransform(matrix
46
+ .translate(w / 2, h / 2)
47
+ .rotate(rotate)
48
+ .translate(-w / 2, -h / 2)
49
+ .scale(scale));
50
+ const width = w / scale - 2 * BORDER;
51
+ const x = BORDER +
52
+ (textAlign === 'center' ? width / 2 : textAlign === 'right' ? width : 0);
53
+ ctx.fillStyle = renderer.getColorValue(color, DefaultTheme.textColor, true);
54
+ ctx.textAlign = textAlign;
55
+ ctx.textBaseline = 'middle';
56
+ let y = BORDER;
57
+ for (const { level, text } of runsOf(model)) {
58
+ const heading = level ? HEADING_SCALE[level] : undefined;
59
+ const fontSize = heading?.fontSize ?? EDGELESS_TEXT_BASE_FONT_SIZE;
60
+ const lineHeight = fontSize + (heading?.lineHeightExtra ?? BODY_LINE_EXTRA);
61
+ const font = getFontString({
62
+ fontStyle,
63
+ fontWeight: heading ? String(heading.fontWeight) : fontWeight,
64
+ fontSize,
65
+ fontFamily,
66
+ });
67
+ ctx.font = font;
68
+ const lines = (hasMaxWidth ? wrapText(text, font, width) : text).split('\n');
69
+ for (const line of lines) {
70
+ if (line)
71
+ ctx.fillText(line, x, y + lineHeight / 2);
72
+ y += lineHeight;
73
+ }
74
+ }
75
+ };
76
+ export const EdgelessTextSvgPainterExtension = BlockSvgPainterExtension('affine:edgeless-text', edgelessTextSvgPainter);
@@ -5,6 +5,7 @@ import { EdgelessClipboardEdgelessTextConfig } from './edgeless-clipboard-config
5
5
  import { EdgelessTextInteraction } from './edgeless-text-block.js';
6
6
  import { edgelessTextToolbarExtension } from './edgeless-toolbar/index.js';
7
7
  import { effects } from './effects.js';
8
+ import { EdgelessTextSvgPainterExtension } from './svg-painter.js';
8
9
  export class EdgelessTextViewExtension extends ViewExtensionProvider {
9
10
  constructor() {
10
11
  super(...arguments);
@@ -24,6 +25,7 @@ export class EdgelessTextViewExtension extends ViewExtensionProvider {
24
25
  context.register(edgelessTextToolbarExtension);
25
26
  context.register(EdgelessClipboardEdgelessTextConfig);
26
27
  context.register(EdgelessTextInteraction);
28
+ context.register(EdgelessTextSvgPainterExtension);
27
29
  }
28
30
  }
29
31
  }
@@ -1,4 +1,4 @@
1
- import { reassociateConnectorsCommand } from '../../affine-block-surface/index.js';
1
+ import { applyCreationLayer, reassociateConnectorsCommand, sourceLayerOf, } from '../../affine-block-surface/index.js';
2
2
  import { toast } from '../../affine-components/toast/index.js';
3
3
  import { BookmarkStyles, EmbedGithubModel, EmbedGithubStyles, isExternalEmbedModel, } from '../../affine-model/index.js';
4
4
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../affine-shared/consts/index.js';
@@ -342,7 +342,16 @@ const createBuiltinSurfaceToolbarConfigForExternal = (klass) => {
342
342
  const bounds = Bound.deserialize(xywh);
343
343
  bounds.w = EMBED_CARD_WIDTH[style];
344
344
  bounds.h = EMBED_CARD_HEIGHT[style];
345
- const newId = ctx.store.addBlock(flavour, { url, caption, style, xywh: bounds.serialize() }, parent);
345
+ // The card takes the embed's place, layer included (ADR 0031 §6).
346
+ const props = {
347
+ url,
348
+ caption,
349
+ style,
350
+ xywh: bounds.serialize(),
351
+ layer: sourceLayerOf(model),
352
+ };
353
+ applyCreationLayer(ctx.std, props);
354
+ const newId = ctx.store.addBlock(flavour, props, parent);
346
355
  ctx.command.exec(reassociateConnectorsCommand, { oldId, newId });
347
356
  ctx.store.deleteBlock(model);
348
357
  // Selects new block
@@ -1,4 +1,4 @@
1
- import { reassociateConnectorsCommand } from '../../../affine-block-surface/index.js';
1
+ import { applyCreationLayer, reassociateConnectorsCommand, sourceLayerOf, } from '../../../affine-block-surface/index.js';
2
2
  import { toast } from '../../../affine-components/toast/index.js';
3
3
  import { BookmarkStyles, EmbedIframeBlockModel } from '../../../affine-model/index.js';
4
4
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../../affine-shared/consts/index.js';
@@ -292,7 +292,16 @@ export const builtinSurfaceToolbarConfig = {
292
292
  const bounds = Bound.deserialize(xywh);
293
293
  bounds.w = EMBED_CARD_WIDTH[style];
294
294
  bounds.h = EMBED_CARD_HEIGHT[style];
295
- const newId = ctx.store.addBlock(flavour, { url, caption, style, xywh: bounds.serialize() }, parent);
295
+ // The card takes the iframe's place, layer included (ADR 0031 §6).
296
+ const props = {
297
+ url,
298
+ caption,
299
+ style,
300
+ xywh: bounds.serialize(),
301
+ layer: sourceLayerOf(model),
302
+ };
303
+ applyCreationLayer(ctx.std, props);
304
+ const newId = ctx.store.addBlock(flavour, props, parent);
296
305
  ctx.command.exec(reassociateConnectorsCommand, { oldId, newId });
297
306
  ctx.store.deleteBlock(model);
298
307
  // Selects new block
@@ -1,5 +1,5 @@
1
1
  import { createEmbedEdgelessBlockInteraction, toEdgelessEmbedBlock, } from '../../affine-block-embed/index.js';
2
- import { EdgelessCRUDIdentifier, reassociateConnectorsCommand, } from '../../affine-block-surface/index.js';
2
+ import { EdgelessCRUDIdentifier, reassociateConnectorsCommand, sourceLayerOf, } from '../../affine-block-surface/index.js';
3
3
  import { EmbedLinkedDocBlockSchema } from '../../affine-model/index.js';
4
4
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../affine-shared/consts/index.js';
5
5
  import { cloneReferenceInfoWithoutAliases, isNewTabTrigger, isNewViewTrigger, } from '../../affine-shared/utils/index.js';
@@ -21,6 +21,8 @@ export class EmbedEdgelessLinkedDocBlockComponent extends toEdgelessEmbedBlock(E
21
21
  xywh: bound.serialize(),
22
22
  caption,
23
23
  ...cloneReferenceInfoWithoutAliases(this.referenceInfo$.peek()),
24
+ // In the linked doc's layer, not the active one (ADR 0031 §6).
25
+ layer: sourceLayerOf(this.model),
24
26
  }, surface);
25
27
  this.std.command.exec(reassociateConnectorsCommand, {
26
28
  oldId: id,
@@ -1,3 +1,4 @@
1
+ import { applyCreationLayer, sourceLayerOf } from '../../../affine-block-surface/index.js';
1
2
  import { toast } from '../../../affine-components/toast/index.js';
2
3
  import { EditorChevronDown } from '../../../affine-components/toolbar/index.js';
3
4
  import { DEFAULT_NOTE_HEIGHT, DEFAULT_NOTE_WIDTH, EmbedSyncedDocModel, NoteBlockModel, NoteDisplayMode, } from '../../../affine-model/index.js';
@@ -297,11 +298,15 @@ const builtinSurfaceToolbarConfig = {
297
298
  PADDING;
298
299
  const y = syncedDocModel.elementBound.y;
299
300
  const children = await draftedModels;
300
- const noteId = std.store.addBlock('affine:note', {
301
+ const props = {
301
302
  xywh: new Bound(x, y, DEFAULT_NOTE_WIDTH, DEFAULT_NOTE_HEIGHT).serialize(),
302
303
  index: gfx.layer.generateIndex(),
303
304
  displayMode: NoteDisplayMode.EdgelessOnly,
304
- }, ctx.store.root);
305
+ // Beside the synced doc, in its layer (ADR 0031 §6).
306
+ layer: sourceLayerOf(syncedDocModel),
307
+ };
308
+ applyCreationLayer(std, props);
309
+ const noteId = std.store.addBlock('affine:note', props, ctx.store.root);
305
310
  std.store.addBlock('affine:paragraph', {
306
311
  text: new Text([
307
312
  {
@@ -33,7 +33,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
33
33
  return useValue ? value : void 0;
34
34
  };
35
35
  import { toEdgelessEmbedBlock } from '../../affine-block-embed/index.js';
36
- import { EdgelessCRUDIdentifier, reassociateConnectorsCommand, } from '../../affine-block-surface/index.js';
36
+ import { EdgelessCRUDIdentifier, reassociateConnectorsCommand, sourceLayerOf, } from '../../affine-block-surface/index.js';
37
37
  import {} from '../../affine-model/index.js';
38
38
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../affine-shared/consts/index.js';
39
39
  import { ThemeExtensionIdentifier, ThemeProvider, translateKey, } from '../../affine-shared/services/index.js';
@@ -170,6 +170,8 @@ let EmbedEdgelessSyncedDocBlockComponent = (() => {
170
170
  caption,
171
171
  ...this.referenceInfo,
172
172
  ...aliasInfo,
173
+ // In the synced doc's layer, not the active one (ADR 0031 §6).
174
+ layer: sourceLayerOf(this.model),
173
175
  }, surface);
174
176
  this.std.command.exec(reassociateConnectorsCommand, {
175
177
  oldId: id,
@@ -0,0 +1,27 @@
1
+ import type { AnyCommandDescriptor } from '../std/index.js';
2
+ import { z } from 'zod';
3
+ /**
4
+ * The frames' commands, `owner: 'core'`: a frame belongs to no framework, and
5
+ * `'core'` owners are exempt from the id-prefix rule (ADR 0008).
6
+ *
7
+ * They live here and not beside the selection pane's: `blocks/surface` cannot
8
+ * import `blocks/frame` (the dependency runs the other way), and the action
9
+ * reads the frame manager's presentation order.
10
+ */
11
+ export declare const reorderFramesParams: z.ZodObject<{
12
+ /** The frames to move, as one block, keeping their relative order. */
13
+ ids: z.ZodArray<z.ZodString, "many">;
14
+ /**
15
+ * The frame they land directly BEFORE in the presentation order; `null`
16
+ * puts them at the end.
17
+ */
18
+ before: z.ZodNullable<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ before: string | null;
21
+ ids: string[];
22
+ }, {
23
+ before: string | null;
24
+ ids: string[];
25
+ }>;
26
+ export type ReorderFramesParams = z.infer<typeof reorderFramesParams>;
27
+ export declare const frameCommands: AnyCommandDescriptor[];
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod';
2
+ import { reorderFramePresentation } from './frame-order.js';
3
+ /**
4
+ * The frames' commands, `owner: 'core'`: a frame belongs to no framework, and
5
+ * `'core'` owners are exempt from the id-prefix rule (ADR 0008).
6
+ *
7
+ * They live here and not beside the selection pane's: `blocks/surface` cannot
8
+ * import `blocks/frame` (the dependency runs the other way), and the action
9
+ * reads the frame manager's presentation order.
10
+ */
11
+ export const reorderFramesParams = z.object({
12
+ /** The frames to move, as one block, keeping their relative order. */
13
+ ids: z.array(z.string().min(1)).min(1),
14
+ /**
15
+ * The frame they land directly BEFORE in the presentation order; `null`
16
+ * puts them at the end.
17
+ */
18
+ before: z.string().min(1).nullable(),
19
+ });
20
+ /**
21
+ * Reorder the presentation (ADR 0034). The frame panel's drag, the
22
+ * presentation toolbar's order menu and a host's own slide panel all run it
23
+ * through `runCommand`, so the read-only refusal, the no-op check and the one
24
+ * undo step live in the action, once.
25
+ */
26
+ const reorderFrames = {
27
+ id: 'canvas.frame.reorder',
28
+ owner: 'core',
29
+ kind: 'action',
30
+ labelKey: 'com.labre.command.canvas.frame.reorder',
31
+ labelFallback: 'Reorder frames',
32
+ descriptionKey: 'com.labre.command.canvas.frame.reorder.description',
33
+ descriptionFallback: 'Move frames before another frame in the presentation order, or to its end.',
34
+ // Agent only: without an explicit target there is nothing to say where.
35
+ surfaces: ['agent'],
36
+ scope: 'edgeless',
37
+ defaultKeys: { mac: [], other: [] },
38
+ availability: 'editable',
39
+ params: reorderFramesParams,
40
+ run: (std, _invocation, params) => {
41
+ const parsed = reorderFramesParams.safeParse(params);
42
+ if (!parsed.success) {
43
+ console.error('canvas.frame.reorder: invalid params', parsed.error);
44
+ return;
45
+ }
46
+ reorderFramePresentation(std, parsed.data.ids, parsed.data.before);
47
+ },
48
+ };
49
+ export const frameCommands = [reorderFrames];
@@ -20,10 +20,13 @@ export declare const EdgelessFrameManagerIdentifier: import("../global/di/types.
20
20
  export declare class EdgelessFrameManager extends GfxExtension {
21
21
  static key: string;
22
22
  private readonly _disposable;
23
+ /** Canvas elements added locally, waiting for the adoption microtask. */
24
+ private readonly _pendingAdoptions;
25
+ private _pendingAdoptionTicks;
23
26
  /**
24
- * Get all sorted frames by presentation orderer,
25
- * the legacy frame that uses `index` as presentation order
26
- * will be put at the beginning of the array.
27
+ * Every frame, in presentation order (`framePresentationComparator`): by
28
+ * `presentationIndex`, and the legacy frames that have none AFTER the keyed
29
+ * ones, ordered among themselves by their stacking `index`.
27
30
  */
28
31
  get frames(): FrameBlockModel[];
29
32
  constructor(gfx: GfxController);
@@ -32,7 +35,7 @@ export declare class EdgelessFrameManager extends GfxExtension {
32
35
  index: string;
33
36
  presentationIndex?: string;
34
37
  };
35
- }>(a: T, b: T): 0 | 1 | -1;
38
+ }>(a: T, b: T): 1 | 0 | -1;
36
39
  private _addChildrenToLegacyFrame;
37
40
  private _addFrameBlock;
38
41
  /**
@@ -67,6 +70,8 @@ export declare class EdgelessFrameManager extends GfxExtension {
67
70
  */
68
71
  private _watchFrameMoved;
69
72
  private _watchElementAdded;
73
+ /** A canvas element just added locally: the frame under it adopts it. */
74
+ private _adoptIfInFrame;
70
75
  /**
71
76
  * Whether `element` fully encloses `frame`.
72
77
  *
@@ -119,8 +124,13 @@ export declare class EdgelessFrameManager extends GfxExtension {
119
124
  getFrameFromPoint([x, y]: IVec, ignoreFrames?: FrameBlockModel[]): FrameBlockModel | null;
120
125
  getParentFrame(element: GfxModel): FrameBlockModel | null;
121
126
  /**
122
- * This method will populate `presentationIndex` for all legacy frames,
123
- * and keep the orderer of the legacy frames.
127
+ * Give a `presentationIndex` to legacy frames, keeping their order — but
128
+ * only on a document where NO frame has one yet. The comparator sorts
129
+ * keyless frames AFTER keyed ones, so as soon as one frame is keyed the first
130
+ * frame is keyed and this returns at once: a mix of keyed and keyless frames
131
+ * is left as it is. In practice a loaded frame always carries a key (the
132
+ * schema's default is written on load), so this only acts on a hand-built
133
+ * store. Idempotent; writes through the props proxy.
124
134
  */
125
135
  refreshLegacyFrameOrder(): void;
126
136
  removeAllChildrenFromFrame(frame: FrameBlockModel): void;