@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,3 +1,4 @@
1
+ import { applyCreationLayer } from '../affine-block-surface/index.js';
1
2
  import { toast } from '../affine-components/toast/index.js';
2
3
  import { AttachmentBlockSchema, } from '../affine-model/index.js';
3
4
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../affine-shared/consts/index.js';
@@ -142,6 +143,9 @@ export async function addAttachments(std, files, point, shouldTransformPoint //
142
143
  const xywh = Bound.fromCenter(center, width, height).serialize();
143
144
  return { flavour, blockProps: { ...props, style, xywh } };
144
145
  });
146
+ // The viewer's active layer, as the CRUD `addBlock` path stamps it
147
+ // (ADR 0031 §6): several blocks at once go straight to `store.addBlocks`.
148
+ blocks.forEach(({ blockProps }) => applyCreationLayer(std, blockProps));
145
149
  const blockIds = std.store.addBlocks(blocks, gfx.surface);
146
150
  gfx.selection.set({
147
151
  elements: blockIds,
@@ -1,5 +1,5 @@
1
1
  import { canEmbedAsEmbedBlock, canEmbedAsIframe, EMBED_IFRAME_DEFAULT_HEIGHT_IN_SURFACE, EMBED_IFRAME_DEFAULT_WIDTH_IN_SURFACE, } from '../../affine-block-embed/index.js';
2
- import { reassociateConnectorsCommand } from '../../affine-block-surface/index.js';
2
+ import { applyCreationLayer, reassociateConnectorsCommand, sourceLayerOf, } from '../../affine-block-surface/index.js';
3
3
  import { toast } from '../../affine-components/toast/index.js';
4
4
  import { BookmarkBlockModel, BookmarkStyles, } from '../../affine-model/index.js';
5
5
  import { EMBED_CARD_HEIGHT, EMBED_CARD_WIDTH, } from '../../affine-shared/consts/index.js';
@@ -291,6 +291,13 @@ const builtinSurfaceToolbarConfig = {
291
291
  return;
292
292
  const { id: oldId, xywh, parent } = model;
293
293
  const { url, caption, title, description } = model.props;
294
+ // The replacement takes the bookmark's place, layer included
295
+ // (ADR 0031 §6).
296
+ const withLayer = (props) => {
297
+ props.layer = sourceLayerOf(model);
298
+ applyCreationLayer(ctx.std, props);
299
+ return props;
300
+ };
294
301
  let newId;
295
302
  // first try to embed as a custom embed block
296
303
  if (canEmbedAsEmbedBlock(ctx.std, url)) {
@@ -307,14 +314,14 @@ const builtinSurfaceToolbarConfig = {
307
314
  const bound = Bound.deserialize(xywh);
308
315
  bound.w = EMBED_CARD_WIDTH[style];
309
316
  bound.h = EMBED_CARD_HEIGHT[style];
310
- newId = ctx.store.addBlock(flavour, {
317
+ newId = ctx.store.addBlock(flavour, withLayer({
311
318
  url,
312
319
  caption,
313
320
  title,
314
321
  description,
315
322
  style,
316
323
  xywh: bound.serialize(),
317
- }, parent);
324
+ }), parent);
318
325
  }
319
326
  else if (canEmbedAsIframe(ctx.std, url)) {
320
327
  const embedIframeService = ctx.std.get(EmbedIframeService);
@@ -328,7 +335,13 @@ const builtinSurfaceToolbarConfig = {
328
335
  bound.w = widthInSurface ?? EMBED_IFRAME_DEFAULT_WIDTH_IN_SURFACE;
329
336
  bound.h =
330
337
  heightInSurface ?? EMBED_IFRAME_DEFAULT_HEIGHT_IN_SURFACE;
331
- newId = ctx.store.addBlock('affine:embed-iframe', { url, caption, title, description, xywh: bound.serialize() }, parent);
338
+ newId = ctx.store.addBlock('affine:embed-iframe', withLayer({
339
+ url,
340
+ caption,
341
+ title,
342
+ description,
343
+ xywh: bound.serialize(),
344
+ }), parent);
332
345
  }
333
346
  if (!newId)
334
347
  return;
@@ -0,0 +1,43 @@
1
+ import { CalloutBlockModel } from '../../affine-model/index.js';
2
+ import { type Command } from '../../std/index.js';
3
+ import { type BlockModel, type Store } from '../../store/index.js';
4
+ /**
5
+ * The selected callouts "Turn into → <text kind>" would unwrap, or none at all.
6
+ *
7
+ * Decided BEFORE anything is written, and all-or-nothing: if one callout
8
+ * cannot be converted, none is (#468). A callout cannot be when its parent
9
+ * does not accept the target flavour (a code block under a database row),
10
+ * or when a grandchild could not live under the block its own parent becomes
11
+ * — and a code block keeps no children at all, so a callout whose content
12
+ * has nested blocks is not turned into code (the merge would drop them).
13
+ * Anything that is not a callout is skipped, and a callout nested in another
14
+ * selected callout moves with it rather than being converted twice.
15
+ */
16
+ export declare function calloutUnwrapTargets(store: Store, models: BlockModel[], flavour: string): CalloutBlockModel[];
17
+ /**
18
+ * "Turn into → <text kind>" on a selected callout (#468): the exact inverse of
19
+ * `turnIntoCalloutCommand`. The callout is a HUB whose own `text` is unused
20
+ * and whose words live in its children, so the conversion UNWRAPS: each child
21
+ * becomes a block of the target kind at the callout's place, in order, its
22
+ * own children moved under it; a target of `affine:code` merges a callout's
23
+ * children into one code block, the way `mergeToCodeModel` merges a
24
+ * selection; an empty callout yields one empty block. The callout's emoji is
25
+ * dropped with it — it belongs to the frame being removed.
26
+ *
27
+ * Add first, prove with `getModelById`, delete only after (#418, #423): every
28
+ * new block is built before anything moves, and if one cannot be, the ones
29
+ * already built are deleted and every callout stays as it was. Only then are
30
+ * the grandchildren moved (validated up front by `calloutUnwrapTargets`) and
31
+ * the callouts deleted. The lifted blocks are therefore NEW blocks carrying
32
+ * the text, like the paragraph `turnIntoCalloutCommand` creates, while the
33
+ * grandchildren keep their identity.
34
+ */
35
+ export declare const turnCalloutIntoCommand: Command<{
36
+ models: BlockModel[];
37
+ flavour: string;
38
+ props?: {
39
+ type?: string;
40
+ };
41
+ }, {
42
+ updatedBlocks: BlockModel[];
43
+ }>;
@@ -0,0 +1,109 @@
1
+ import { CalloutBlockModel } from '../../affine-model/index.js';
2
+ import { matchModels } from '../../affine-shared/utils/index.js';
3
+ import { BlockSelection } from '../../std/index.js';
4
+ import { Text } from '../../store/index.js';
5
+ const isAncestor = (store, ancestor, block) => {
6
+ for (let at = store.getParent(block); at; at = store.getParent(at)) {
7
+ if (at === ancestor)
8
+ return true;
9
+ }
10
+ return false;
11
+ };
12
+ /**
13
+ * The selected callouts "Turn into → <text kind>" would unwrap, or none at all.
14
+ *
15
+ * Decided BEFORE anything is written, and all-or-nothing: if one callout
16
+ * cannot be converted, none is (#468). A callout cannot be when its parent
17
+ * does not accept the target flavour (a code block under a database row),
18
+ * or when a grandchild could not live under the block its own parent becomes
19
+ * — and a code block keeps no children at all, so a callout whose content
20
+ * has nested blocks is not turned into code (the merge would drop them).
21
+ * Anything that is not a callout is skipped, and a callout nested in another
22
+ * selected callout moves with it rather than being converted twice.
23
+ */
24
+ export function calloutUnwrapTargets(store, models, flavour) {
25
+ const { schema } = store;
26
+ const callouts = models.filter((model) => matchModels(model, [CalloutBlockModel]));
27
+ const outermost = callouts.filter(callout => !callouts.some(other => isAncestor(store, other, callout)));
28
+ const feasible = outermost.every(callout => {
29
+ const parent = store.getParent(callout);
30
+ if (!parent || !schema.isValid(flavour, parent.flavour))
31
+ return false;
32
+ return callout.children.every(child => flavour === 'affine:code'
33
+ ? child.children.length === 0
34
+ : child.children.every(grandchild => schema.isValid(grandchild.flavour, flavour)));
35
+ });
36
+ return feasible ? outermost : [];
37
+ }
38
+ /**
39
+ * "Turn into → <text kind>" on a selected callout (#468): the exact inverse of
40
+ * `turnIntoCalloutCommand`. The callout is a HUB whose own `text` is unused
41
+ * and whose words live in its children, so the conversion UNWRAPS: each child
42
+ * becomes a block of the target kind at the callout's place, in order, its
43
+ * own children moved under it; a target of `affine:code` merges a callout's
44
+ * children into one code block, the way `mergeToCodeModel` merges a
45
+ * selection; an empty callout yields one empty block. The callout's emoji is
46
+ * dropped with it — it belongs to the frame being removed.
47
+ *
48
+ * Add first, prove with `getModelById`, delete only after (#418, #423): every
49
+ * new block is built before anything moves, and if one cannot be, the ones
50
+ * already built are deleted and every callout stays as it was. Only then are
51
+ * the grandchildren moved (validated up front by `calloutUnwrapTargets`) and
52
+ * the callouts deleted. The lifted blocks are therefore NEW blocks carrying
53
+ * the text, like the paragraph `turnIntoCalloutCommand` creates, while the
54
+ * grandchildren keep their identity.
55
+ */
56
+ export const turnCalloutIntoCommand = (ctx, next) => {
57
+ const { std, models, flavour, props } = ctx;
58
+ const store = std.store;
59
+ if (store.readonly)
60
+ return;
61
+ const callouts = calloutUnwrapTargets(store, models, flavour);
62
+ if (callouts.length === 0)
63
+ return;
64
+ store.captureSync();
65
+ const created = [];
66
+ const adoptions = [];
67
+ const add = (callout, text) => {
68
+ const parent = store.getParent(callout);
69
+ // Inserted right before the callout, so the blocks keep their order.
70
+ const block = parent
71
+ ? store.getModelById(store.addBlock(flavour, { ...props, ...(text && { text }) }, parent, parent.children.indexOf(callout)))
72
+ : null;
73
+ if (block)
74
+ created.push(block);
75
+ return block;
76
+ };
77
+ // `addBlock` returns an id even for a block the store refused, so only
78
+ // `getModelById` proves the block exists (`add` above).
79
+ const build = (callout) => {
80
+ const sources = callout.children;
81
+ if (flavour === 'affine:code') {
82
+ const joined = sources
83
+ .map(source => source.text?.toString())
84
+ .filter(Boolean)
85
+ .join('\n');
86
+ return add(callout, new Text(joined)) !== null;
87
+ }
88
+ if (sources.length === 0)
89
+ return add(callout) !== null;
90
+ return sources.every(source => {
91
+ const block = add(callout, source.text?.clone());
92
+ if (block && source.children.length > 0)
93
+ adoptions.push([source.children, block]);
94
+ return block !== null;
95
+ });
96
+ };
97
+ if (!callouts.every(build)) {
98
+ created.forEach(block => store.deleteBlock(block));
99
+ return;
100
+ }
101
+ adoptions.forEach(([children, block]) => store.moveBlocks(children, block));
102
+ callouts.forEach(callout => store.deleteBlock(callout));
103
+ // The gesture started from a block selection (the callout's handle), so it
104
+ // ends on one; deferred a frame so the new blocks have rendered.
105
+ requestAnimationFrame(() => {
106
+ std.selection.setGroup('note', created.map(block => std.selection.create(BlockSelection, { blockId: block.id })));
107
+ });
108
+ return next({ updatedBlocks: created });
109
+ };
@@ -0,0 +1,29 @@
1
+ import type { Command } from '../../std/index.js';
2
+ import type { BlockModel, Store } from '../../store/index.js';
3
+ /**
4
+ * The selected blocks "Turn into → Callout" would actually wrap.
5
+ *
6
+ * Decided BEFORE anything is written, so that a refusal costs nothing: a
7
+ * block already inside a callout (a callout never nests) or inside an
8
+ * edgeless text (where the slash item is not offered either), a parent that
9
+ * does not accept a callout, or a child the inner paragraph could not adopt —
10
+ * `deleteBlock({ bringChildrenTo })` detaches the source before it validates
11
+ * the children, so a refused child there would orphan the whole block. A
12
+ * selected child of another selected block is dropped too: it moves with its
13
+ * parent.
14
+ */
15
+ export declare function calloutConversionTargets(store: Store, models: BlockModel[]): BlockModel[];
16
+ /**
17
+ * Wraps each selected paragraph, list item or code block in a callout (#418).
18
+ *
19
+ * A callout is a hub with no text of its own, so this cannot be
20
+ * `transformModel`: the callout takes the block's place, a paragraph inside it
21
+ * takes the text, and the block's children move under that paragraph. Every
22
+ * callout is built before any source is removed; if one cannot be, the ones
23
+ * already built are deleted and every source stays as it was.
24
+ */
25
+ export declare const turnIntoCalloutCommand: Command<{
26
+ models: BlockModel[];
27
+ }, {
28
+ updatedBlocks: BlockModel[];
29
+ }>;
@@ -0,0 +1,81 @@
1
+ import { CodeBlockModel, ListBlockModel, ParagraphBlockModel, } from '../../affine-model/index.js';
2
+ import { focusTextModel } from '../../affine-rich-text/index.js';
3
+ import { isInsideBlockByFlavour, matchModels, } from '../../affine-shared/utils/index.js';
4
+ const isAncestor = (store, ancestor, block) => {
5
+ for (let at = store.getParent(block); at; at = store.getParent(at)) {
6
+ if (at === ancestor)
7
+ return true;
8
+ }
9
+ return false;
10
+ };
11
+ /**
12
+ * The selected blocks "Turn into → Callout" would actually wrap.
13
+ *
14
+ * Decided BEFORE anything is written, so that a refusal costs nothing: a
15
+ * block already inside a callout (a callout never nests) or inside an
16
+ * edgeless text (where the slash item is not offered either), a parent that
17
+ * does not accept a callout, or a child the inner paragraph could not adopt —
18
+ * `deleteBlock({ bringChildrenTo })` detaches the source before it validates
19
+ * the children, so a refused child there would orphan the whole block. A
20
+ * selected child of another selected block is dropped too: it moves with its
21
+ * parent.
22
+ */
23
+ export function calloutConversionTargets(store, models) {
24
+ const { schema } = store;
25
+ const convertible = models.filter(model => {
26
+ if (!matchModels(model, [ParagraphBlockModel, ListBlockModel, CodeBlockModel]))
27
+ return false;
28
+ if (isInsideBlockByFlavour(store, model, 'affine:callout'))
29
+ return false;
30
+ if (isInsideBlockByFlavour(store, model, 'affine:edgeless-text'))
31
+ return false;
32
+ const parent = store.getParent(model);
33
+ if (!parent || !schema.isValid('affine:callout', parent.flavour))
34
+ return false;
35
+ return model.children.every(child => schema.isValid(child.flavour, 'affine:paragraph'));
36
+ });
37
+ return convertible.filter(model => !convertible.some(other => isAncestor(store, other, model)));
38
+ }
39
+ /**
40
+ * Wraps each selected paragraph, list item or code block in a callout (#418).
41
+ *
42
+ * A callout is a hub with no text of its own, so this cannot be
43
+ * `transformModel`: the callout takes the block's place, a paragraph inside it
44
+ * takes the text, and the block's children move under that paragraph. Every
45
+ * callout is built before any source is removed; if one cannot be, the ones
46
+ * already built are deleted and every source stays as it was.
47
+ */
48
+ export const turnIntoCalloutCommand = (ctx, next) => {
49
+ const { std, models } = ctx;
50
+ const store = std.store;
51
+ if (store.readonly)
52
+ return;
53
+ const targets = calloutConversionTargets(store, models);
54
+ if (targets.length === 0)
55
+ return;
56
+ store.captureSync();
57
+ const callouts = [];
58
+ const paragraphs = [];
59
+ for (const model of targets) {
60
+ const parent = store.getParent(model);
61
+ const callout = parent
62
+ ? store.getModelById(store.addBlock('affine:callout', {}, parent, parent.children.indexOf(model)))
63
+ : null;
64
+ if (callout)
65
+ callouts.push(callout);
66
+ // `addBlock` returns an id even for a block the store refused, so only
67
+ // `getModelById` proves the block exists.
68
+ const paragraph = callout
69
+ ? store.getModelById(store.addBlock('affine:paragraph', { text: model.text?.clone() }, callout))
70
+ : null;
71
+ if (!paragraph) {
72
+ callouts.forEach(created => store.deleteBlock(created));
73
+ return;
74
+ }
75
+ paragraphs.push(paragraph);
76
+ }
77
+ targets.forEach((model, i) => store.deleteBlock(model, { bringChildrenTo: paragraphs[i] }));
78
+ const first = paragraphs[0];
79
+ focusTextModel(std, first.id, first.text?.length ?? 0);
80
+ return next({ updatedBlocks: paragraphs });
81
+ };
@@ -1,10 +1,13 @@
1
1
  import { focusBlockEnd } from '../../affine-shared/commands/index.js';
2
- import { FeatureFlagService } from '../../affine-shared/services/index.js';
3
2
  import { isInsideBlockByFlavour } from '../../affine-shared/utils/index.js';
4
3
  import {} from '../../affine-widget-slash-menu/index.js';
5
4
  import { FontIcon } from '@blocksuite/icons/lit';
6
5
  import { CALLOUT_SLASH_CAPTION, CALLOUT_SLASH_DESCRIPTION, CALLOUT_SLASH_NAME, } from '../translations.js';
7
6
  import { calloutTooltip } from './tooltips.js';
7
+ // Gated by the `callout` block flag alone: `CalloutViewExtension` registers
8
+ // this config and is itself flag-gated (ADR 0009). The deprecated
9
+ // `enable_callout` feature flag is not read.
10
+ //
8
11
  // No `disableWhen` here on purpose. The widget ORs every config's `disableWhen`
9
12
  // together and then refuses to open at all, so the callout's own guard used to
10
13
  // silence the WHOLE slash menu inside a callout — every block, every framework,
@@ -24,9 +27,8 @@ export const calloutSlashMenuConfig = {
24
27
  },
25
28
  searchAlias: ['callout'],
26
29
  group: '0_Basic@9',
27
- when: ({ std, model }) => {
28
- return (std.get(FeatureFlagService).getFlag('enable_callout') &&
29
- !isInsideBlockByFlavour(model.store, model, 'affine:edgeless-text') &&
30
+ when: ({ model }) => {
31
+ return (!isInsideBlockByFlavour(model.store, model, 'affine:edgeless-text') &&
30
32
  // The schema forbids a callout inside a callout, so offering the item
31
33
  // there would only produce a thrown insertion.
32
34
  !isInsideBlockByFlavour(model.store, model, 'affine:callout'));
@@ -0,0 +1,65 @@
1
+ import { ActionPlacement, type ToolbarContext } from '../../affine-shared/services/index.js';
2
+ /**
3
+ * The callout's block toolbar, opened by its drag handle (#468). Without a
4
+ * module for `affine:callout` the toolbar widget shows no row for a selected
5
+ * callout at all, so a callout could not be converted back. Copy, duplicate
6
+ * and delete are the note row's, restricted to the block selection — except
7
+ * that they take the selection in `flat` mode, descendants included, where
8
+ * the note row's Duplicate takes `highest`: a callout is a hub, and drafted
9
+ * without its children it would copy as an empty frame.
10
+ *
11
+ * Centred above the block (`top`) like the note row a paragraph or a code
12
+ * block opens; without a placement of its own the widget sets a block's row
13
+ * at `top-start`, which left the callout's row hanging off its left edge.
14
+ */
15
+ export declare const calloutToolbarConfig: {
16
+ readonly placement: "top";
17
+ readonly actions: [{
18
+ readonly id: "a.conversions";
19
+ readonly when: (ctx: ToolbarContext) => boolean;
20
+ readonly content: (ctx: ToolbarContext) => import("lit-html").TemplateResult<1> | null;
21
+ }, {
22
+ readonly variant?: "destructive";
23
+ readonly content?: ((cx: ToolbarContext) => import("lit-html").TemplateResult | null) | (import("lit-html").TemplateResult | null);
24
+ readonly label?: string;
25
+ readonly icon?: import("lit-html").TemplateResult;
26
+ readonly active?: ((cx: ToolbarContext) => boolean) | boolean;
27
+ readonly disabled?: ((cx: ToolbarContext) => boolean) | boolean;
28
+ readonly placement?: ActionPlacement;
29
+ readonly tooltip?: string | import("lit-html").TemplateResult;
30
+ readonly score?: number;
31
+ readonly when?: ((cx: ToolbarContext) => boolean) | boolean;
32
+ readonly priority?: number;
33
+ readonly labelWording?: import("../../affine-shared/services/index.js").ChromeWording;
34
+ readonly showLabel?: boolean;
35
+ readonly tooltipWording?: import("../../affine-shared/services/index.js").ChromeWording;
36
+ readonly run?: (cx: ToolbarContext) => void;
37
+ readonly id: "g.comment";
38
+ }, {
39
+ readonly placement: ActionPlacement.More;
40
+ readonly id: "a.clipboard";
41
+ readonly actions: [{
42
+ readonly id: "copy";
43
+ readonly labelWording: import("../../affine-shared/services/index.js").ChromeWording;
44
+ readonly icon: import("lit-html").TemplateResult<1>;
45
+ readonly run: ({ chain, host, std }: ToolbarContext) => void;
46
+ }, {
47
+ readonly id: "duplicate";
48
+ readonly labelWording: import("../../affine-shared/services/index.js").ChromeWording;
49
+ readonly icon: import("lit-html").TemplateResult<1>;
50
+ readonly run: (ctx: ToolbarContext) => void;
51
+ }];
52
+ readonly when: (ctx: ToolbarContext) => boolean;
53
+ }, {
54
+ readonly placement: ActionPlacement.More;
55
+ readonly id: "c.delete";
56
+ readonly actions: [{
57
+ readonly id: "delete";
58
+ readonly labelWording: import("../../affine-shared/services/index.js").ChromeWording;
59
+ readonly icon: import("lit-html").TemplateResult<1>;
60
+ readonly variant: "destructive";
61
+ readonly run: ({ chain }: ToolbarContext) => void;
62
+ }];
63
+ readonly when: (ctx: ToolbarContext) => boolean;
64
+ }];
65
+ };
@@ -0,0 +1,178 @@
1
+ import { toast } from '../../affine-components/toast/index.js';
2
+ import { EditorChevronDown } from '../../affine-components/toolbar/index.js';
3
+ import { CalloutBlockModel } from '../../affine-model/index.js';
4
+ import { textConversionConfigs } from '../../affine-rich-text/index.js';
5
+ import { copySelectedModelsCommand, deleteSelectedModelsCommand, draftSelectedModelsCommand, duplicateSelectedModelsCommand, getSelectedModelsCommand, } from '../../affine-shared/commands/index.js';
6
+ import { ActionPlacement, blockCommentToolbarButton, TOAST_COPIED_TO_CLIPBOARD, TOOLBAR_CONVERSIONS_ARIA, TOOLBAR_COPY, TOOLBAR_DELETE, TOOLBAR_DUPLICATE, TOOLBAR_TURN_INTO, translateKey, } from '../../affine-shared/services/index.js';
7
+ import { matchModels } from '../../affine-shared/utils/index.js';
8
+ import { CopyIcon, DeleteIcon, DuplicateIcon, FontIcon, } from '@blocksuite/icons/lit';
9
+ import { html } from 'lit';
10
+ import { repeat } from 'lit/directives/repeat.js';
11
+ import { calloutUnwrapTargets, turnCalloutIntoCommand, } from '../commands/turn-callout-into.js';
12
+ /** The block-selected callouts — the row only opens on a block selection. */
13
+ const selectedCallouts = ({ chain }) => {
14
+ const [ok, { selectedModels = [] }] = chain
15
+ .pipe(getSelectedModelsCommand, { types: ['block'], mode: 'highest' })
16
+ .run();
17
+ return ok
18
+ ? selectedModels.filter(model => matchModels(model, [CalloutBlockModel]))
19
+ : [];
20
+ };
21
+ /**
22
+ * "Turn into" on a callout (#468): the text kinds of the note's own row, minus
23
+ * the divider (which is not a conversion of a block's words), each offered
24
+ * only when `calloutUnwrapTargets` says the whole conversion can complete —
25
+ * a refusal is an absent entry, never a click that does nothing.
26
+ *
27
+ * Like the note row, which offers "Turn into" on a paragraph or a code block
28
+ * only once it holds words (`isFormatSupported`), the entry waits for the
29
+ * callout to hold some: an empty callout shows the "⋮" menu alone (PO
30
+ * recette of #468, for one behaviour across blocks).
31
+ */
32
+ const conversionsAction = {
33
+ id: 'a.conversions',
34
+ when: ctx => !ctx.readonly,
35
+ content(ctx) {
36
+ const { std, store } = ctx;
37
+ const callouts = selectedCallouts(ctx);
38
+ if (callouts.length === 0)
39
+ return null;
40
+ const holdsWords = callouts.some(callout => callout.children.some(child => (child.text?.length ?? 0) > 0));
41
+ if (!holdsWords)
42
+ return null;
43
+ const conversions = textConversionConfigs.filter(({ flavour }) => flavour !== 'affine:divider' &&
44
+ calloutUnwrapTargets(store, callouts, flavour).length > 0);
45
+ if (conversions.length === 0)
46
+ return null;
47
+ return html `
48
+ <editor-menu-button
49
+ .contentPadding="${'8px'}"
50
+ .button=${html `
51
+ <editor-icon-button
52
+ aria-label="${translateKey(std, ...TOOLBAR_CONVERSIONS_ARIA)}"
53
+ .tooltip="${translateKey(std, ...TOOLBAR_TURN_INTO)}"
54
+ >
55
+ ${FontIcon()} ${EditorChevronDown}
56
+ </editor-icon-button>
57
+ `}
58
+ >
59
+ <div data-size="large" data-orientation="vertical">
60
+ ${repeat(conversions, item => item.name, ({ flavour, type, name, nameWording, icon }) => {
61
+ const label = nameWording
62
+ ? translateKey(std, ...nameWording)
63
+ : name;
64
+ return html `
65
+ <editor-menu-action
66
+ aria-label=${label}
67
+ @click=${() => std.command.exec(turnCalloutIntoCommand, {
68
+ models: callouts,
69
+ flavour,
70
+ ...(type && { props: { type } }),
71
+ })}
72
+ >
73
+ ${icon}<span class="label">${label}</span>
74
+ </editor-menu-action>
75
+ `;
76
+ })}
77
+ </div>
78
+ </editor-menu-button>
79
+ `;
80
+ },
81
+ };
82
+ /**
83
+ * The callout's block toolbar, opened by its drag handle (#468). Without a
84
+ * module for `affine:callout` the toolbar widget shows no row for a selected
85
+ * callout at all, so a callout could not be converted back. Copy, duplicate
86
+ * and delete are the note row's, restricted to the block selection — except
87
+ * that they take the selection in `flat` mode, descendants included, where
88
+ * the note row's Duplicate takes `highest`: a callout is a hub, and drafted
89
+ * without its children it would copy as an empty frame.
90
+ *
91
+ * Centred above the block (`top`) like the note row a paragraph or a code
92
+ * block opens; without a placement of its own the widget sets a block's row
93
+ * at `top-start`, which left the callout's row hanging off its left edge.
94
+ */
95
+ export const calloutToolbarConfig = {
96
+ placement: 'top',
97
+ actions: [
98
+ conversionsAction,
99
+ {
100
+ id: 'g.comment',
101
+ ...blockCommentToolbarButton,
102
+ },
103
+ {
104
+ placement: ActionPlacement.More,
105
+ id: 'a.clipboard',
106
+ actions: [
107
+ {
108
+ id: 'copy',
109
+ labelWording: TOOLBAR_COPY,
110
+ icon: CopyIcon(),
111
+ run({ chain, host, std }) {
112
+ // `flat`, not `highest`: the callout's words are its children,
113
+ // and the draft keeps only the children that are selected too.
114
+ const [ok] = chain
115
+ .pipe(getSelectedModelsCommand, {
116
+ types: ['block'],
117
+ mode: 'flat',
118
+ })
119
+ .pipe(draftSelectedModelsCommand)
120
+ .pipe(copySelectedModelsCommand)
121
+ .run();
122
+ if (!ok)
123
+ return;
124
+ toast(host, translateKey(std, ...TOAST_COPIED_TO_CLIPBOARD));
125
+ },
126
+ },
127
+ {
128
+ id: 'duplicate',
129
+ labelWording: TOOLBAR_DUPLICATE,
130
+ icon: DuplicateIcon(),
131
+ run(ctx) {
132
+ const { chain, store } = ctx;
133
+ // The copy lands right after the (last) callout. Said explicitly:
134
+ // the command's default anchors on the LAST selected model, which
135
+ // in `flat` mode is one of the callout's descendants.
136
+ const last = selectedCallouts(ctx).at(-1);
137
+ const parentModel = last && store.getParent(last);
138
+ if (!last || !parentModel)
139
+ return;
140
+ store.captureSync();
141
+ // `flat`, not `highest`, for the same reason as Copy: a callout
142
+ // drafted without its children duplicates as an empty frame.
143
+ chain
144
+ .pipe(getSelectedModelsCommand, {
145
+ types: ['block'],
146
+ mode: 'flat',
147
+ })
148
+ .pipe(duplicateSelectedModelsCommand, {
149
+ parentModel,
150
+ index: parentModel.children.indexOf(last) + 1,
151
+ })
152
+ .run();
153
+ },
154
+ },
155
+ ],
156
+ when: ctx => !ctx.flags.isNative(),
157
+ },
158
+ {
159
+ placement: ActionPlacement.More,
160
+ id: 'c.delete',
161
+ actions: [
162
+ {
163
+ id: 'delete',
164
+ labelWording: TOOLBAR_DELETE,
165
+ icon: DeleteIcon(),
166
+ variant: 'destructive',
167
+ run({ chain }) {
168
+ chain
169
+ .pipe(getSelectedModelsCommand, { types: ['block'] })
170
+ .pipe(deleteSelectedModelsCommand)
171
+ .run();
172
+ },
173
+ },
174
+ ],
175
+ when: ctx => !ctx.flags.isNative(),
176
+ },
177
+ ],
178
+ };
@@ -0,0 +1,8 @@
1
+ import type { TextConversionEntry } from '../../affine-rich-text/index.js';
2
+ /**
3
+ * "Callout" in the "Turn into" menu, registered by `CalloutViewExtension` so
4
+ * the `callout` flag removes it with the slash item (ADR 0009). That flag is
5
+ * the only switch: the deprecated `enable_callout` feature flag is not read,
6
+ * so the two entries always appear and disappear together.
7
+ */
8
+ export declare const calloutTurnIntoEntry: TextConversionEntry;
@@ -0,0 +1,19 @@
1
+ import { FontIcon } from '@blocksuite/icons/lit';
2
+ import { calloutConversionTargets, turnIntoCalloutCommand, } from '../commands/turn-into-callout.js';
3
+ import { CALLOUT_TURN_INTO_NAME } from '../translations.js';
4
+ /**
5
+ * "Callout" in the "Turn into" menu, registered by `CalloutViewExtension` so
6
+ * the `callout` flag removes it with the slash item (ADR 0009). That flag is
7
+ * the only switch: the deprecated `enable_callout` feature flag is not read,
8
+ * so the two entries always appear and disappear together.
9
+ */
10
+ export const calloutTurnIntoEntry = {
11
+ flavour: 'affine:callout',
12
+ name: 'Callout',
13
+ nameWording: CALLOUT_TURN_INTO_NAME,
14
+ icon: FontIcon(),
15
+ when: (std, models) => calloutConversionTargets(std.store, models).length > 0,
16
+ run: (std, models) => {
17
+ std.command.exec(turnIntoCalloutCommand, { models });
18
+ },
19
+ };
@@ -7,10 +7,12 @@ export declare const CALLOUT_SLASH_NAME: ChromeWording;
7
7
  export declare const CALLOUT_SLASH_DESCRIPTION: ChromeWording;
8
8
  /** The item's tooltip caption says the exact same word as its name. */
9
9
  export declare const CALLOUT_SLASH_CAPTION: ChromeWording;
10
+ /** "Turn into → Callout" names the block with the slash item's own word. */
11
+ export declare const CALLOUT_TURN_INTO_NAME: ChromeWording;
10
12
  /**
11
13
  * Every wording declared above, in declaration order — walked by
12
14
  * `PACKAGE_WORDINGS` in `packages/affine/all/src/translations.ts`. The
13
- * caption alias is not listed again, same rule other packages' chrome
14
- * aliases already follow.
15
+ * caption and turn-into aliases are not listed again, same rule other
16
+ * packages' chrome aliases already follow.
15
17
  */
16
18
  export declare const CALLOUT_WORDINGS: readonly ChromeWording[];