@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
@@ -1,4 +1,4 @@
1
- import { indexOverBackgrounds, Overlay, stackedElementsOf, } from '../affine-block-surface/index.js';
1
+ import { applyCreationLayer, indexOverBackgrounds, Overlay, stackedElementsOf, } from '../affine-block-surface/index.js';
2
2
  import { FrameworkBackgroundElementModel } from '../affine-model/index.js';
3
3
  import { EditPropsStore, getChromeAccentColor, translateKey, } from '../affine-shared/services/index.js';
4
4
  import { DisposableGroup } from '../global/disposable/index.js';
@@ -90,9 +90,9 @@ export const EdgelessFrameManagerIdentifier = GfxExtensionIdentifier('frame-mana
90
90
  export class EdgelessFrameManager extends GfxExtension {
91
91
  static { this.key = 'frame-manager'; }
92
92
  /**
93
- * Get all sorted frames by presentation orderer,
94
- * the legacy frame that uses `index` as presentation order
95
- * will be put at the beginning of the array.
93
+ * Every frame, in presentation order (`framePresentationComparator`): by
94
+ * `presentationIndex`, and the legacy frames that have none AFTER the keyed
95
+ * ones, ordered among themselves by their stacking `index`.
96
96
  */
97
97
  get frames() {
98
98
  return Object.values(this.gfx.doc.blocks.value)
@@ -103,6 +103,9 @@ export class EdgelessFrameManager extends GfxExtension {
103
103
  constructor(gfx) {
104
104
  super(gfx);
105
105
  this._disposable = new DisposableGroup();
106
+ /** Canvas elements added locally, waiting for the adoption microtask. */
107
+ this._pendingAdoptions = [];
108
+ this._pendingAdoptionTicks = 0;
106
109
  this._watchElementAdded();
107
110
  this._watchFrameMoved();
108
111
  }
@@ -158,6 +161,10 @@ export class EdgelessFrameManager extends GfxExtension {
158
161
  index: this.frameIndexAt(bound),
159
162
  presentationIndex: this.generatePresentationIndex(),
160
163
  });
164
+ // The viewer's active layer, like every new model (ADR 0031 §6). Not
165
+ // through the stamped CRUD `addBlock`: it would replace the index
166
+ // `frameIndexAt` just chose.
167
+ applyCreationLayer(this.gfx.std, props);
161
168
  const id = this.gfx.doc.addBlock('affine:frame', props, surfaceModel);
162
169
  const frameModel = this.gfx.getElementById(id);
163
170
  if (!frameModel || !isFrameBlock(frameModel)) {
@@ -231,7 +238,7 @@ export class EdgelessFrameManager extends GfxExtension {
231
238
  const { surface: surfaceModel, doc } = this.gfx;
232
239
  this._disposable.add(surfaceModel.elementAdded.subscribe(({ id, local }) => {
233
240
  const element = surfaceModel.getElementById(id);
234
- if (element && local) {
241
+ if (element && local && !surfaceModel.store.readonly) {
235
242
  // The entire frame detection logic must be in microtask for timing reasons:
236
243
  //
237
244
  // 1. For connectors: When elementAdded fires, connectors have invalid bounds [0,0,0,0]
@@ -248,22 +255,23 @@ export class EdgelessFrameManager extends GfxExtension {
248
255
  // - Connectors have proper bounds calculated (not [0,0,0,0])
249
256
  // - getFrameFromPoint() works correctly with valid element centers
250
257
  // - All element initialization is complete before frame detection
258
+ //
259
+ // One transaction (one update for the peers) adopts everything a
260
+ // single transaction added — a paste of N elements no longer sends N
261
+ // adoptions. Only the LAST microtask queued does the work, so each
262
+ // element is decided no earlier than its own microtask would have
263
+ // been, connector paths included.
264
+ this._pendingAdoptions.push(element);
265
+ this._pendingAdoptionTicks++;
251
266
  queueMicrotask(() => {
252
- const frame = this.getFrameFromPoint(element.elementBound.center);
253
- // if the container created with a frame, skip it.
254
- if (isGfxGroupCompatibleModel(element) &&
255
- frame &&
256
- element.hasChild(frame)) {
267
+ if (--this._pendingAdoptionTicks > 0)
268
+ return;
269
+ const elements = this._pendingAdoptions.splice(0);
270
+ if (surfaceModel.store.readonly)
257
271
  return;
258
- }
259
- // Only add elements that aren't already grouped and have a valid
260
- // frame, and never let the frame swallow a backdrop that encloses
261
- // it (e.g. a Wardley map background the frame was drawn on top of).
262
- if (!element.group &&
263
- frame &&
264
- !this._enclosesFrame(element, frame)) {
265
- this._adoptNewlyCreatedElement(frame, element);
266
- }
272
+ doc.transact(() => {
273
+ elements.forEach(element => this._adoptIfInFrame(element));
274
+ });
267
275
  });
268
276
  }
269
277
  }));
@@ -275,11 +283,18 @@ export class EdgelessFrameManager extends GfxExtension {
275
283
  // cannot write at all, which is how this surfaced (#251). See #242 for
276
284
  // the rule: a cascade reacts to local transactions, the receiving peer
277
285
  // trusts the sync.
278
- if (!payload.isLocal)
286
+ if (!payload.isLocal || doc.readonly)
279
287
  return;
280
288
  if (payload.type === 'add' &&
281
289
  payload.model instanceof GfxBlockElementModel &&
282
290
  renderableInEdgeless(doc, surfaceModel, payload.model)) {
291
+ // Same guard as the canvas half: a block that already has a parent
292
+ // (restored by undo with its group, or created by a transaction that
293
+ // also wrote its container) is not the frame's to take. Adopting it
294
+ // makes two containers claim one child, and the next duplicate
295
+ // copies that child twice.
296
+ if (payload.model.group)
297
+ return;
283
298
  const frame = this.getFrameFromPoint(payload.model.elementBound.center, isFrameBlock(payload.model) ? [payload.model] : []);
284
299
  if (!frame)
285
300
  return;
@@ -297,6 +312,22 @@ export class EdgelessFrameManager extends GfxExtension {
297
312
  }
298
313
  }));
299
314
  }
315
+ /** A canvas element just added locally: the frame under it adopts it. */
316
+ _adoptIfInFrame(element) {
317
+ const frame = this.getFrameFromPoint(element.elementBound.center);
318
+ if (!frame)
319
+ return;
320
+ // if the container created with a frame, skip it.
321
+ if (isGfxGroupCompatibleModel(element) && element.hasChild(frame)) {
322
+ return;
323
+ }
324
+ // Only add elements that aren't already grouped, and never let the frame
325
+ // swallow a backdrop that encloses it (e.g. a Wardley map background the
326
+ // frame was drawn on top of).
327
+ if (!element.group && !this._enclosesFrame(element, frame)) {
328
+ this._adoptNewlyCreatedElement(frame, element);
329
+ }
330
+ }
300
331
  /**
301
332
  * Whether `element` fully encloses `frame`.
302
333
  *
@@ -453,8 +484,13 @@ export class EdgelessFrameManager extends GfxExtension {
453
484
  return container && isFrameBlock(container) ? container : null;
454
485
  }
455
486
  /**
456
- * This method will populate `presentationIndex` for all legacy frames,
457
- * and keep the orderer of the legacy frames.
487
+ * Give a `presentationIndex` to legacy frames, keeping their order — but
488
+ * only on a document where NO frame has one yet. The comparator sorts
489
+ * keyless frames AFTER keyed ones, so as soon as one frame is keyed the first
490
+ * frame is keyed and this returns at once: a mix of keyed and keyless frames
491
+ * is left as it is. In practice a loaded frame always carries a key (the
492
+ * schema's default is written on load), so this only acts on a hand-built
493
+ * store. Idempotent; writes through the props proxy.
458
494
  */
459
495
  refreshLegacyFrameOrder() {
460
496
  const frames = this.frames.splice(0, this.frames.length);
@@ -0,0 +1,43 @@
1
+ import type { BlockStdScope } from '../std/index.js';
2
+ /**
3
+ * The one write of the frames' PRESENTATION order (ADR 0034): the
4
+ * order a presentation walks the frames in, held by each frame's
5
+ * `presentationIndex` — a fractional key, never a position.
6
+ *
7
+ * Why one function: two sites wrote that order by hand — the frame panel's
8
+ * drag and the presentation toolbar's order menu — each its own way, neither
9
+ * refusing a read-only document, and the panel taking its undo checkpoint
10
+ * AFTER the write, so the reorder merged into whatever gesture came before.
11
+ * Both now reach this through `canvas.frame.reorder`, and so does a host's own
12
+ * slide panel: the guards below live here, once.
13
+ *
14
+ * Mirrors the selection pane's `reorderPaneElement`
15
+ * (`blocks/surface/src/extensions/selection-pane/actions.ts`):
16
+ *
17
+ * - refuses on a read-only document before reading anything else;
18
+ * - writes nothing when nothing would change — an unchanged write is an empty
19
+ * undo step, and an undo that "does nothing" reads as a broken undo;
20
+ * - takes ONE `captureSync()` first, so one gesture is one undo step, the
21
+ * legacy keys `refreshLegacyFrameOrder` may write included (it writes in
22
+ * the same capture window, so it joins the gesture's step);
23
+ * - writes through `gfx.updateElement`, which is `store.updateBlock` for a
24
+ * frame — not the CRUD `updateElement`, which would also record the moved
25
+ * frame's props as the flavour's last-used props.
26
+ */
27
+ /**
28
+ * Move the frames `ids` so they sit, as one block, directly BEFORE `before` in
29
+ * the presentation order — `null` puts them at the end. The moved frames keep
30
+ * their current relative order, whatever order `ids` lists them in. Answers
31
+ * whether anything was written.
32
+ *
33
+ * Refused, with nothing written: a read-only document; an id that is not a
34
+ * frame of this document; a `before` that is one of the moved frames, or not
35
+ * a frame; and a target that is where the frames already are.
36
+ *
37
+ * Each moved frame gets a key between its new neighbours, so only the moved
38
+ * frames are written and nothing else shifts. Two neighbours with equal (or
39
+ * inverted) keys cannot be split — `generateKeyBetweenV2` throws on them, and
40
+ * the model's default key is random per frame, so a pasted, imported or
41
+ * hand-made document can carry them: refusing beats throwing in a drop.
42
+ */
43
+ export declare function reorderFramePresentation(std: BlockStdScope, ids: readonly string[], before: string | null): boolean;
@@ -0,0 +1,93 @@
1
+ import { generateKeyBetweenV2, GfxControllerIdentifier } from '../std/gfx/index.js';
2
+ import { EdgelessFrameManagerIdentifier } from './frame-manager.js';
3
+ /**
4
+ * The one write of the frames' PRESENTATION order (ADR 0034): the
5
+ * order a presentation walks the frames in, held by each frame's
6
+ * `presentationIndex` — a fractional key, never a position.
7
+ *
8
+ * Why one function: two sites wrote that order by hand — the frame panel's
9
+ * drag and the presentation toolbar's order menu — each its own way, neither
10
+ * refusing a read-only document, and the panel taking its undo checkpoint
11
+ * AFTER the write, so the reorder merged into whatever gesture came before.
12
+ * Both now reach this through `canvas.frame.reorder`, and so does a host's own
13
+ * slide panel: the guards below live here, once.
14
+ *
15
+ * Mirrors the selection pane's `reorderPaneElement`
16
+ * (`blocks/surface/src/extensions/selection-pane/actions.ts`):
17
+ *
18
+ * - refuses on a read-only document before reading anything else;
19
+ * - writes nothing when nothing would change — an unchanged write is an empty
20
+ * undo step, and an undo that "does nothing" reads as a broken undo;
21
+ * - takes ONE `captureSync()` first, so one gesture is one undo step, the
22
+ * legacy keys `refreshLegacyFrameOrder` may write included (it writes in
23
+ * the same capture window, so it joins the gesture's step);
24
+ * - writes through `gfx.updateElement`, which is `store.updateBlock` for a
25
+ * frame — not the CRUD `updateElement`, which would also record the moved
26
+ * frame's props as the flavour's last-used props.
27
+ */
28
+ /**
29
+ * Move the frames `ids` so they sit, as one block, directly BEFORE `before` in
30
+ * the presentation order — `null` puts them at the end. The moved frames keep
31
+ * their current relative order, whatever order `ids` lists them in. Answers
32
+ * whether anything was written.
33
+ *
34
+ * Refused, with nothing written: a read-only document; an id that is not a
35
+ * frame of this document; a `before` that is one of the moved frames, or not
36
+ * a frame; and a target that is where the frames already are.
37
+ *
38
+ * Each moved frame gets a key between its new neighbours, so only the moved
39
+ * frames are written and nothing else shifts. Two neighbours with equal (or
40
+ * inverted) keys cannot be split — `generateKeyBetweenV2` throws on them, and
41
+ * the model's default key is random per frame, so a pasted, imported or
42
+ * hand-made document can carry them: refusing beats throwing in a drop.
43
+ */
44
+ export function reorderFramePresentation(std, ids, before) {
45
+ if (std.store.readonly)
46
+ return false;
47
+ const manager = std.get(EdgelessFrameManagerIdentifier);
48
+ const frames = manager.frames;
49
+ const moving = new Set(ids);
50
+ if (moving.size === 0)
51
+ return false;
52
+ if (before !== null && moving.has(before))
53
+ return false;
54
+ const known = new Set(frames.map(frame => frame.id));
55
+ for (const id of moving)
56
+ if (!known.has(id))
57
+ return false;
58
+ if (before !== null && !known.has(before))
59
+ return false;
60
+ // `frames` is already in presentation order, so filtering keeps the moved
61
+ // frames' relative order.
62
+ const moved = frames.filter(frame => moving.has(frame.id));
63
+ const rest = frames.filter(frame => !moving.has(frame.id));
64
+ const position = before === null
65
+ ? rest.length
66
+ : rest.findIndex(frame => frame.id === before);
67
+ const target = [
68
+ ...rest.slice(0, position),
69
+ ...moved,
70
+ ...rest.slice(position),
71
+ ];
72
+ if (target.every((frame, i) => frame === frames[i]))
73
+ return false;
74
+ std.store.captureSync();
75
+ // Gives a key to legacy frames that have none, keeping their order, so the
76
+ // neighbours' keys below mean what the list shows. A no-op on any document
77
+ // where a frame already carries one.
78
+ manager.refreshLegacyFrameOrder();
79
+ const lower = rest[position - 1]?.props.presentationIndex || null;
80
+ const upper = rest[position]?.props.presentationIndex || null;
81
+ if (lower !== null && upper !== null && lower >= upper)
82
+ return false;
83
+ const gfx = std.get(GfxControllerIdentifier);
84
+ std.store.transact(() => {
85
+ let previous = lower;
86
+ for (const frame of moved) {
87
+ const presentationIndex = generateKeyBetweenV2(previous, upper);
88
+ gfx.updateElement(frame, { presentationIndex });
89
+ previous = presentationIndex;
90
+ }
91
+ });
92
+ return true;
93
+ }
@@ -1,4 +1,4 @@
1
- import { DefaultTool, OverlayIdentifier } from '../affine-block-surface/index.js';
1
+ import { applyCreationLayer, DefaultTool, OverlayIdentifier, } from '../affine-block-surface/index.js';
2
2
  import { EditPropsStore, TelemetryProvider, translateKey, } from '../affine-shared/services/index.js';
3
3
  import { Bound, Vec } from '../global/gfx/index.js';
4
4
  import { BaseTool, getTopElements } from '../std/gfx/index.js';
@@ -61,6 +61,8 @@ export class FrameTool extends BaseTool {
61
61
  index: this.frameManager.frameIndexAt(bound),
62
62
  presentationIndex: this.frameManager.generatePresentationIndex(),
63
63
  });
64
+ // The active layer, as `EdgelessFrameManager._addFrameBlock` does.
65
+ applyCreationLayer(this.std, props);
64
66
  const id = this.doc.addBlock('affine:frame', props, this.gfx.surface);
65
67
  this.std.getOptional(TelemetryProvider)?.track('CanvasElementAdded', {
66
68
  control: 'canvas:draw',
@@ -1,8 +1,10 @@
1
+ export * from './commands.js';
1
2
  export * from './edgeless-clipboard-config.js';
2
3
  export * from './edgeless-toolbar/index.js';
3
4
  export * from './frame-block.js';
4
5
  export * from './frame-highlight-manager.js';
5
6
  export * from './frame-manager.js';
7
+ export * from './frame-order.js';
6
8
  export * from './frame-spec.js';
7
9
  export * from './frame-tool.js';
8
10
  export * from './frame-toolbar.js';
@@ -1,8 +1,10 @@
1
+ export * from './commands.js';
1
2
  export * from './edgeless-clipboard-config.js';
2
3
  export * from './edgeless-toolbar/index.js';
3
4
  export * from './frame-block.js';
4
5
  export * from './frame-highlight-manager.js';
5
6
  export * from './frame-manager.js';
7
+ export * from './frame-order.js';
6
8
  export * from './frame-spec.js';
7
9
  export * from './frame-tool.js';
8
10
  export * from './frame-toolbar.js';
@@ -1,9 +1,17 @@
1
- import type { BlockComponent } from '../../std/index.js';
1
+ import { type BlockComponent } from '../../std/index.js';
2
2
  import { LitElement } from 'lit';
3
3
  declare const EdgelessFrameOrderMenu_base: typeof LitElement & import("../../global/utils/types.js").Constructor<import("../../global/lit/with-disposable.js").DisposableClass>;
4
+ /**
5
+ * The presentation toolbar's order menu. Its WRITE is `canvas.frame.reorder`
6
+ * (ADR 0034); its drag gesture is its own.
7
+ *
8
+ * ponytail: a drag-to-reorder gesture of its own, beside the frame panel's and
9
+ * the selection pane's — its ceiling is a 256px popover, which the panels' one
10
+ * controller (`createPanelReorderDrag`, ADR 0034) is not built for. If the
11
+ * menu ever becomes a panel, move it onto that controller and delete this one.
12
+ */
4
13
  export declare class EdgelessFrameOrderMenu extends EdgelessFrameOrderMenu_base {
5
14
  static styles: import("lit").CSSResult;
6
- get crud(): import("../../affine-block-surface/index.js").EdgelessCRUDExtension;
7
15
  private get _frameMgr();
8
16
  private get _frames();
9
17
  private _bindEvent;
@@ -32,14 +32,37 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
32
32
  }
33
33
  return useValue ? value : void 0;
34
34
  };
35
- import { EdgelessCRUDIdentifier } from '../../affine-block-surface/index.js';
36
35
  import { DisposableGroup } from '../../global/disposable/index.js';
37
36
  import { SignalWatcher, WithDisposable } from '../../global/lit/index.js';
38
- import { generateKeyBetweenV2 } from '../../std/gfx/index.js';
37
+ import { runCommand, } from '../../std/index.js';
39
38
  import { css, html, LitElement, nothing } from 'lit';
40
39
  import { property, query, state } from 'lit/decorators.js';
41
40
  import { repeat } from 'lit/directives/repeat.js';
41
+ import { frameCommands } from '../commands.js';
42
42
  import { EdgelessFrameManagerIdentifier } from '../frame-manager.js';
43
+ /**
44
+ * How the menu invokes the registry: from the editor's chrome, on the frames
45
+ * it names, like the selection pane's rows.
46
+ */
47
+ const MENU_INVOCATION = {
48
+ surface: 'contextual-toolbar',
49
+ source: 'toolbar:general',
50
+ };
51
+ function reorderCommand() {
52
+ const command = frameCommands.find(c => c.id === 'canvas.frame.reorder');
53
+ if (!command)
54
+ throw new Error('frame order menu: no canvas.frame.reorder');
55
+ return command;
56
+ }
57
+ /**
58
+ * The presentation toolbar's order menu. Its WRITE is `canvas.frame.reorder`
59
+ * (ADR 0034); its drag gesture is its own.
60
+ *
61
+ * ponytail: a drag-to-reorder gesture of its own, beside the frame panel's and
62
+ * the selection pane's — its ceiling is a 256px popover, which the panels' one
63
+ * controller (`createPanelReorderDrag`, ADR 0034) is not built for. If the
64
+ * menu ever becomes a panel, move it onto that controller and delete this one.
65
+ */
43
66
  let EdgelessFrameOrderMenu = (() => {
44
67
  let _classSuper = SignalWatcher(WithDisposable(LitElement));
45
68
  let __clone_decorators;
@@ -161,9 +184,6 @@ let EdgelessFrameOrderMenu = (() => {
161
184
  width: 90%;
162
185
  }
163
186
  `; }
164
- get crud() {
165
- return this.edgeless.std.get(EdgelessCRUDIdentifier);
166
- }
167
187
  get _frameMgr() {
168
188
  return this.edgeless.std.get(EdgelessFrameManagerIdentifier);
169
189
  }
@@ -225,20 +245,14 @@ let EdgelessFrameOrderMenu = (() => {
225
245
  this._disposables.addFromEvent(document, 'pointerup', () => {
226
246
  clone.style.visibility = 'hidden';
227
247
  indicatorLine.style.visibility = 'hidden';
228
- if (newIndex >= 0 &&
229
- newIndex <= this._frames.length &&
230
- newIndex !== index &&
231
- newIndex !== index + 1) {
232
- const frameMgr = this._frameMgr;
233
- // Legacy compatibility
234
- frameMgr.refreshLegacyFrameOrder();
235
- const before = this._frames[newIndex - 1]?.props.presentationIndex || null;
236
- const after = this._frames[newIndex]?.props.presentationIndex || null;
237
- const frame = this._frames[index];
238
- this.crud.updateElement(frame.id, {
239
- presentationIndex: generateKeyBetweenV2(before, after),
248
+ const frames = this._frames;
249
+ // A drop on its own slot (before itself) or on the next one is refused
250
+ // by the command: nothing is written, no undo step is pushed.
251
+ if (newIndex >= 0 && newIndex <= frames.length && frames[index]) {
252
+ runCommand(this.edgeless.std, reorderCommand(), MENU_INVOCATION, {
253
+ ids: [frames[index].id],
254
+ before: frames[newIndex]?.id ?? null,
240
255
  });
241
- this.edgeless.store.captureSync();
242
256
  this.requestUpdate();
243
257
  }
244
258
  this._disposables.dispose();
@@ -1,4 +1,6 @@
1
1
  import { ViewExtensionProvider, } from '../affine-ext-loader/index.js';
2
+ import { CommandExtension } from '../std/index.js';
3
+ import { frameCommands } from './commands.js';
2
4
  import { EdgelessClipboardFrameConfig } from './edgeless-clipboard-config.js';
3
5
  import { frameQuickTool } from './edgeless-toolbar/index.js';
4
6
  import { effects } from './effects.js';
@@ -30,6 +32,10 @@ export class FrameViewExtension extends ViewExtensionProvider {
30
32
  context.register(edgelessNavigatorBgWidget);
31
33
  context.register(EdgelessClipboardFrameConfig);
32
34
  context.register(FrameBlockInteraction);
35
+ // The presentation order's one write (ADR 0034). The frame panel also
36
+ // mounts in page mode: it runs the imported descriptor, not this
37
+ // registration, so its reorder works in both modes.
38
+ context.register(CommandExtension(frameCommands));
33
39
  }
34
40
  }
35
41
  }
@@ -1,4 +1,4 @@
1
- import { autoResizeElementsCommand } from '../affine-block-surface/index.js';
1
+ import { applyCreationLayer, autoResizeElementsCommand, } from '../affine-block-surface/index.js';
2
2
  import { toast } from '../affine-components/toast/index.js';
3
3
  import { ImageBlockSchema, } from '../affine-model/index.js';
4
4
  import { FileSizeLimitProvider, NativeClipboardProvider, TOAST_DOWNLOAD_IN_PROGRESS, TOAST_UPLOAD_SIZE_LIMIT, translateKey, } from '../affine-shared/services/index.js';
@@ -234,6 +234,9 @@ export async function addImages(std, files, options) {
234
234
  },
235
235
  };
236
236
  });
237
+ // The viewer's active layer, as the CRUD `addBlock` path stamps it
238
+ // (ADR 0031 §6): several blocks at once go straight to `store.addBlocks`.
239
+ blocks.forEach(({ blockProps }) => applyCreationLayer(std, blockProps));
237
240
  const blockIds = std.store.addBlocks(blocks, gfx.surface);
238
241
  gfx.selection.set({
239
242
  elements: blockIds,
@@ -1,4 +1,12 @@
1
1
  import { type MarkdownAdapterPreprocessor } from '../../../affine-shared/adapters/index.js';
2
+ /**
3
+ * Preprocess the content to protect code blocks and LaTeX expressions
4
+ * reference issue: https://github.com/remarkjs/react-markdown/issues/785
5
+ * reference comment: https://github.com/remarkjs/react-markdown/issues/785#issuecomment-2307567823
6
+ * @param content - The content to preprocess
7
+ * @returns The preprocessed content
8
+ */
9
+ export declare function preprocessLatex(content: string): string;
2
10
  export declare const LatexMarkdownPreprocessorExtension: import("../../../store/index.js").ExtensionType & {
3
11
  identifier: import("../../../global/di/types.js").ServiceIdentifier<MarkdownAdapterPreprocessor>;
4
12
  };
@@ -24,7 +24,7 @@ function escapeMhchem(text) {
24
24
  * @param content - The content to preprocess
25
25
  * @returns The preprocessed content
26
26
  */
27
- function preprocessLatex(content) {
27
+ export function preprocessLatex(content) {
28
28
  // Protect code blocks
29
29
  const codeBlocks = [];
30
30
  let preprocessedContent = content;
@@ -32,14 +32,18 @@ function preprocessLatex(content) {
32
32
  codeBlocks.push(code);
33
33
  return `<<CODE_BLOCK_${codeBlocks.length - 1}>>`;
34
34
  });
35
- // Protect existing LaTeX expressions
35
+ // Protect existing LaTeX expressions. Inline delimiters use Pandoc's
36
+ // whitespace and digit rules, with backslash parity preserved: a `$` opens
37
+ // math when not followed by a space, closes it when not preceded by one nor
38
+ // followed by a digit, and an odd backslash run escapes it.
36
39
  const latexExpressions = [];
37
- preprocessedContent = preprocessedContent.replace(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\(.*?\\\))/g, match => {
40
+ preprocessedContent = preprocessedContent.replace(/(\$\$[\s\S]*?\$\$|\\\[[\s\S]*?\\\]|\\\(.*?\\\)|(?<!\\)(?:\\\\)*\$(?!\s)(?:[^\n$\\]|\\.)*?(?<!\s)\$(?!\d))/g, match => {
38
41
  latexExpressions.push(match);
39
42
  return `<<LATEX_${latexExpressions.length - 1}>>`;
40
43
  });
41
- // Escape dollar signs that are likely currency indicators
42
- preprocessedContent = preprocessedContent.replace(/\$(?=\d)/g, '\\$');
44
+ // Escape dollar signs that are likely currency indicators. An odd backslash
45
+ // run already escapes the dollar sign, so only an even run (or none) gets one.
46
+ preprocessedContent = preprocessedContent.replace(/(?<!\\)((?:\\\\)*)\$(?=\d)/g, '$1\\$');
43
47
  // Restore LaTeX expressions
44
48
  preprocessedContent = preprocessedContent.replace(/<<LATEX_(\d+)>>/g, (_, index) => latexExpressions[parseInt(index)]);
45
49
  // Restore code blocks
@@ -1,2 +1,21 @@
1
+ import { NoteDisplayMode } from '../../affine-model/index.js';
2
+ import { type BlockStdScope } from '../../std/index.js';
1
3
  import type { ExtensionType } from '../../store/index.js';
4
+ /**
5
+ * The toast shown after a note's display mode changes. Its "View in TOC" link
6
+ * is offered only when the host registered an outline panel
7
+ * (`OutlinePanelExtension`, ADR 0034 §1): a link that opens nothing is a lie,
8
+ * so a host with no outline, or one that passed `null`, gets a toast with no
9
+ * link, and a body without the "Find it in the TOC" sentence that points at
10
+ * it.
11
+ */
12
+ export declare function displayModeToast(std: BlockStdScope, newMode: NoteDisplayMode): {
13
+ title: string;
14
+ message: string;
15
+ actions: {
16
+ key: string;
17
+ label: string;
18
+ onClick: () => void;
19
+ }[];
20
+ };
2
21
  export declare const createBuiltinToolbarConfigExtension: (flavour: string) => ExtensionType[];
@@ -1,6 +1,6 @@
1
1
  import { EdgelessLegacySlotIdentifier } from '../../affine-block-surface/index.js';
2
2
  import { NoteBlockModel, NoteDisplayMode } from '../../affine-model/index.js';
3
- import { NotificationProvider, SidebarExtensionIdentifier, TOAST_NOTE_REMOVED_FROM_PAGE, ToolbarModuleExtension, translateKey, } from '../../affine-shared/services/index.js';
3
+ import { NotificationProvider, OutlinePanelProvider, TOAST_NOTE_REMOVED_FROM_PAGE, ToolbarModuleExtension, translateKey, } from '../../affine-shared/services/index.js';
4
4
  import { Bound } from '../../global/gfx/index.js';
5
5
  import { AutoHeightIcon, CustomizedHeightIcon, InsertIntoPageIcon, ScissorsIcon, } from '@blocksuite/icons/lit';
6
6
  import { BlockFlavourIdentifier } from '../../std/index.js';
@@ -8,7 +8,7 @@ import { computed } from '@preact/signals-core';
8
8
  import { html } from 'lit';
9
9
  import { changeNoteDisplayMode } from '../commands/index.js';
10
10
  import { NoteConfigExtension } from '../config.js';
11
- import { NOTE_TOAST_ADDED_TO_PAGE_BODY, NOTE_TOAST_DISPLAYED_IN_PAGE_MODE, NOTE_TOAST_REMOVED_FROM_PAGE_BODY, NOTE_TOAST_VIEW_IN_TOC, NOTE_TOOLBAR_AUTO_HEIGHT, NOTE_TOOLBAR_CUSTOMIZED_HEIGHT, NOTE_TOOLBAR_CUTTING_MODE, NOTE_TOOLBAR_DISPLAY_IN_PAGE, NOTE_TOOLBAR_DISPLAYED_IN_PAGE, NOTE_TOOLBAR_REMOVE_FROM_PAGE_TOOLTIP, NOTE_TOOLBAR_SIZE, NOTE_TOOLBAR_SLICER, } from '../translations.js';
11
+ import { NOTE_TOAST_ADDED_TO_PAGE_BODY, NOTE_TOAST_ADDED_TO_PAGE_BODY_NO_TOC, NOTE_TOAST_DISPLAYED_IN_PAGE_MODE, NOTE_TOAST_REMOVED_FROM_PAGE_BODY, NOTE_TOAST_REMOVED_FROM_PAGE_BODY_NO_TOC, NOTE_TOAST_VIEW_IN_TOC, NOTE_TOOLBAR_AUTO_HEIGHT, NOTE_TOOLBAR_CUSTOMIZED_HEIGHT, NOTE_TOOLBAR_CUTTING_MODE, NOTE_TOOLBAR_DISPLAY_IN_PAGE, NOTE_TOOLBAR_DISPLAYED_IN_PAGE, NOTE_TOOLBAR_REMOVE_FROM_PAGE_TOOLTIP, NOTE_TOOLBAR_SIZE, NOTE_TOOLBAR_SLICER, } from '../translations.js';
12
12
  const trackBaseProps = {
13
13
  category: 'note',
14
14
  };
@@ -238,6 +238,41 @@ const builtinSurfaceToolbarConfig = {
238
238
  ],
239
239
  when: ctx => ctx.getSurfaceModelsByType(NoteBlockModel).length > 0,
240
240
  };
241
+ /**
242
+ * The toast shown after a note's display mode changes. Its "View in TOC" link
243
+ * is offered only when the host registered an outline panel
244
+ * (`OutlinePanelExtension`, ADR 0034 §1): a link that opens nothing is a lie,
245
+ * so a host with no outline, or one that passed `null`, gets a toast with no
246
+ * link, and a body without the "Find it in the TOC" sentence that points at
247
+ * it.
248
+ */
249
+ export function displayModeToast(std, newMode) {
250
+ const outline = std.getOptional(OutlinePanelProvider);
251
+ const removed = newMode === NoteDisplayMode.EdgelessOnly;
252
+ const title = removed
253
+ ? TOAST_NOTE_REMOVED_FROM_PAGE
254
+ : NOTE_TOAST_DISPLAYED_IN_PAGE_MODE;
255
+ const body = removed
256
+ ? outline
257
+ ? NOTE_TOAST_REMOVED_FROM_PAGE_BODY
258
+ : NOTE_TOAST_REMOVED_FROM_PAGE_BODY_NO_TOC
259
+ : outline
260
+ ? NOTE_TOAST_ADDED_TO_PAGE_BODY
261
+ : NOTE_TOAST_ADDED_TO_PAGE_BODY_NO_TOC;
262
+ return {
263
+ title: translateKey(std, ...title),
264
+ message: translateKey(std, ...body),
265
+ actions: outline
266
+ ? [
267
+ {
268
+ key: 'view-in-toc',
269
+ label: translateKey(std, ...NOTE_TOAST_VIEW_IN_TOC),
270
+ onClick: () => outline.open(),
271
+ },
272
+ ]
273
+ : [],
274
+ };
275
+ }
241
276
  function setDisplayMode(ctx, model, newMode) {
242
277
  const displayMode = model.props.displayMode;
243
278
  ctx.command.exec(changeNoteDisplayMode, {
@@ -249,31 +284,11 @@ function setDisplayMode(ctx, model, newMode) {
249
284
  if (newMode === NoteDisplayMode.DocOnly) {
250
285
  ctx.selection.clear();
251
286
  }
252
- const data = newMode === NoteDisplayMode.EdgelessOnly
253
- ? {
254
- title: translateKey(ctx.std, ...TOAST_NOTE_REMOVED_FROM_PAGE),
255
- message: translateKey(ctx.std, ...NOTE_TOAST_REMOVED_FROM_PAGE_BODY),
256
- }
257
- : {
258
- title: translateKey(ctx.std, ...NOTE_TOAST_DISPLAYED_IN_PAGE_MODE),
259
- message: translateKey(ctx.std, ...NOTE_TOAST_ADDED_TO_PAGE_BODY),
260
- };
261
287
  const notification = ctx.std.getOptional(NotificationProvider);
262
288
  notification?.notifyWithUndoAction({
263
- title: data.title,
264
- message: data.message,
289
+ ...displayModeToast(ctx.std, newMode),
265
290
  accent: 'success',
266
291
  duration: 5 * 1000,
267
- actions: [
268
- {
269
- key: 'view-in-toc',
270
- label: translateKey(ctx.std, ...NOTE_TOAST_VIEW_IN_TOC),
271
- onClick: () => {
272
- const sidebar = ctx.std.getOptional(SidebarExtensionIdentifier);
273
- sidebar?.open('outline');
274
- },
275
- },
276
- ],
277
292
  });
278
293
  ctx.track('NoteDisplayModeChanged', {
279
294
  ...trackBaseProps,
@@ -57,7 +57,6 @@ export declare const NOTE_BORDER_STYLE_LABEL: ChromeWording;
57
57
  /** An alias (L7 dedupe): the same word as {@link DISPLAY_MODE_SHOW_IN}, one key. */
58
58
  export declare const NOTE_DISPLAY_MODE_SHOW_IN: ChromeWording;
59
59
  export declare const NOTE_DISPLAY_MODE_LABEL: ChromeWording;
60
- export declare const NOTE_DISPLAY_MODE_TOOLTIP: ChromeWording;
61
60
  /** An alias (L7 dedupe): the same word as {@link DISPLAY_MODE_BOTH}, one key. */
62
61
  export declare const NOTE_DISPLAY_MODE_BOTH: ChromeWording;
63
62
  /** An alias (L7 dedupe): the same word as {@link DISPLAY_MODE_EDGELESS}, one key. */
@@ -67,6 +66,8 @@ export declare const NOTE_DISPLAY_MODE_PAGE: ChromeWording;
67
66
  export declare const NOTE_TOAST_DISPLAYED_IN_PAGE_MODE: ChromeWording;
68
67
  export declare const NOTE_TOAST_REMOVED_FROM_PAGE_BODY: ChromeWording;
69
68
  export declare const NOTE_TOAST_ADDED_TO_PAGE_BODY: ChromeWording;
69
+ export declare const NOTE_TOAST_REMOVED_FROM_PAGE_BODY_NO_TOC: ChromeWording;
70
+ export declare const NOTE_TOAST_ADDED_TO_PAGE_BODY_NO_TOC: ChromeWording;
70
71
  export declare const NOTE_TOAST_VIEW_IN_TOC: ChromeWording;
71
72
  export declare const NOTE_TOOLBAR_DISPLAY_IN_PAGE: ChromeWording;
72
73
  export declare const NOTE_TOOLBAR_DISPLAYED_IN_PAGE: ChromeWording;