@formicoidea/labre-core 0.42.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
  2. package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
  3. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  5. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  6. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  7. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  8. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  9. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  10. package/dist/_pkgs/affine-block-callout/view.js +3 -0
  11. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  12. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  13. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  14. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  15. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  16. package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
  17. package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
  18. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
  19. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  20. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  23. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
  24. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
  25. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -0
  27. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
  28. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
  29. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  30. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +0 -2
  31. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -5
  32. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -1
  33. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +14 -6
  34. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
  35. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
  36. package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -0
  37. package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -0
  38. package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
  39. package/dist/_pkgs/affine-block-embed/index.js +1 -0
  40. package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
  41. package/dist/_pkgs/affine-block-embed/translations.js +28 -0
  42. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  43. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
  44. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  45. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  46. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
  47. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  48. package/dist/_pkgs/affine-block-frame/frame-manager.js +53 -19
  49. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  50. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  51. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  52. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  53. package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
  54. package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
  55. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  56. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  57. package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
  58. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
  59. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
  60. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  61. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  62. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  63. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  64. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  65. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  66. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  67. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  68. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  69. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  70. package/dist/_pkgs/affine-block-root/index.js +1 -0
  71. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  72. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  73. package/dist/_pkgs/affine-block-root/view.js +2 -0
  74. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  75. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  76. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  77. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  78. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  87. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  88. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  89. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  90. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  93. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  94. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  96. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  97. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  98. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +13 -1
  103. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +8 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/legend.js +59 -3
  105. package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  107. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  108. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  109. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  110. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  115. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  116. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  117. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  118. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
  119. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
  120. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  121. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +98 -19
  122. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  123. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  124. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  125. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  126. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  127. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  128. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  129. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  130. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  131. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  132. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  133. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  134. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +1 -1
  135. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  136. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  137. package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
  138. package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
  139. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
  140. package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
  141. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  142. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  143. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  144. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  145. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  146. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
  147. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  148. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  149. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  150. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  151. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  152. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  153. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  154. package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
  155. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  156. package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +5 -0
  157. package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
  158. package/dist/_pkgs/affine-components/context-menu/button.js +17 -1
  159. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  160. package/dist/_pkgs/affine-components/icons/ai.js +3 -3
  161. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  162. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  163. package/dist/_pkgs/affine-components/icons/list.js +7 -1
  164. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  165. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  166. package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
  167. package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
  168. package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
  169. package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
  170. package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
  171. package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
  172. package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
  173. package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
  174. package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
  175. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  176. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
  177. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +3 -3
  178. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  179. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  180. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  181. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  182. package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
  183. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
  184. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
  185. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  186. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  187. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +6 -4
  188. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +24 -8
  189. package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
  190. package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
  191. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  192. package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
  193. package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
  194. package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +6 -0
  195. package/dist/_pkgs/affine-gfx-mindmap/translations.js +10 -0
  196. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  197. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  198. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +5 -3
  199. package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
  200. package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
  201. package/dist/_pkgs/affine-gfx-template/builtin/other.js +13 -7
  202. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  203. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  204. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  205. package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
  206. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  207. package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
  208. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +5 -3
  209. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  210. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  211. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  212. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  213. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +56 -3
  214. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  215. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  216. package/dist/_pkgs/affine-gfx-text/translations.d.ts +8 -0
  217. package/dist/_pkgs/affine-gfx-text/translations.js +12 -0
  218. package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
  219. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  220. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  221. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  222. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  223. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  224. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  225. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  226. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  227. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  228. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  229. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  230. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  231. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  232. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  233. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  234. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  235. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  236. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  237. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  238. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  239. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  240. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  241. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  242. package/dist/_pkgs/affine-model/consts/text.d.ts +41 -2
  243. package/dist/_pkgs/affine-model/consts/text.js +50 -1
  244. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  245. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  246. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  247. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  248. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  249. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  250. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  251. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  252. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  253. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  254. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  255. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  256. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  257. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  258. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  259. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  260. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  261. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  262. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  263. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +13 -2
  264. package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -54
  265. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  266. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  267. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  268. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  269. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  270. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  271. package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
  272. package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
  273. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +25 -0
  274. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +90 -0
  275. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  276. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  277. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  278. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  279. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  280. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  281. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  282. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  283. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  284. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  285. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  286. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  287. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  288. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  289. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  290. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  291. package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
  292. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +15 -4
  293. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  294. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
  295. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
  296. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
  297. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  298. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  299. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  300. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  301. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  304. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  305. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  306. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  307. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  308. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  309. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  310. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  311. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  312. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  313. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +58 -0
  314. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +171 -1
  315. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  316. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
  317. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  318. package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
  319. package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
  320. package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
  321. package/dist/_pkgs/data-view/core/detail/field.js +2 -1
  322. package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
  323. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
  324. package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
  325. package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
  326. package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
  327. package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
  328. package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
  329. package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
  330. package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
  331. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
  332. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
  333. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
  334. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
  335. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  336. package/dist/_pkgs/std/gfx/controller.js +22 -2
  337. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  338. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  339. package/dist/_pkgs/std/gfx/index.js +3 -1
  340. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  341. package/dist/_pkgs/std/gfx/layer.js +73 -5
  342. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  343. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  344. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  345. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  346. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  347. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
  348. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  349. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  350. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  351. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  352. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  353. package/dist/_pkgs/std/utils/layer.js +64 -13
  354. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  355. package/dist/commands.js +6 -2
  356. package/dist/translations.js +15 -6
  357. package/package.json +13 -2
  358. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  359. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  360. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  361. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  362. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  363. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  364. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  365. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  366. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  367. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -0,0 +1,61 @@
1
+ import { css } from 'lit';
2
+ import { fontSMStyle } from './font.js';
3
+ /**
4
+ * The header of a side panel, as the frame panel draws it
5
+ * (`fragments/frame-panel`, `header/frame-panel-header.ts`): one 36px row,
6
+ * 8px side padding, no divider under it, a 14px / 500 secondary-text title
7
+ * and icon buttons whose glyph is secondary until hovered or active.
8
+ *
9
+ * Every side panel's header takes it from here — the frame panel, the
10
+ * selection pane and the artefact catalogue — so the three cannot drift
11
+ * apart (held by `panel-header-parity.unit.spec.ts` in `affine/all`). It lives
12
+ * this low because a widget may not import the frame panel: the frame panel
13
+ * depends on the frame block, which depends on the edgeless toolbar.
14
+ *
15
+ * A component opts in by adding the three classes to its own markup:
16
+ * `affine-panel-header` on the row, `affine-panel-header-title` on the title,
17
+ * `affine-panel-header-button` on each icon button.
18
+ */
19
+ export const panelHeaderStyles = css `
20
+ .affine-panel-header {
21
+ display: flex;
22
+ flex: none;
23
+ width: 100%;
24
+ height: 36px;
25
+ align-items: center;
26
+ justify-content: space-between;
27
+ gap: 8px;
28
+ box-sizing: border-box;
29
+ padding: 0 8px;
30
+ }
31
+
32
+ ${fontSMStyle('.affine-panel-header-title')}
33
+
34
+ .affine-panel-header-title {
35
+ min-width: 0;
36
+ overflow: hidden;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap;
39
+ color: var(--affine-text-secondary-color);
40
+ }
41
+
42
+ .affine-panel-header-button svg {
43
+ color: var(--affine-icon-secondary);
44
+ }
45
+
46
+ .affine-panel-header-button:hover svg,
47
+ .affine-panel-header-button.active svg {
48
+ color: var(--affine-icon-color);
49
+ }
50
+ `;
51
+ /**
52
+ * Pointer travel, on either axis, before a press on a card or a row of a side
53
+ * panel becomes a drag rather than a click — the frame panel's threshold,
54
+ * shared with the selection pane so the two panels start a drag alike.
55
+ */
56
+ export const PANEL_DRAG_THRESHOLD_PX = 5;
57
+ /** Whether a press at `from` moved to `to` has travelled far enough to drag. */
58
+ export function panelDragStarted(from, to) {
59
+ return (Math.abs(from.x - to.x) >= PANEL_DRAG_THRESHOLD_PX ||
60
+ Math.abs(from.y - to.y) >= PANEL_DRAG_THRESHOLD_PX);
61
+ }
@@ -1,11 +1,11 @@
1
1
  export function affineTextStyles(props, override) {
2
- let textDecorations = '';
3
- if (props.underline) {
4
- textDecorations += 'underline';
5
- }
6
- if (props.strike) {
7
- textDecorations += ' line-through';
8
- }
2
+ const textDecorations = [
3
+ props.underline && 'underline',
4
+ props.overline && 'overline',
5
+ props.strike && 'line-through',
6
+ ]
7
+ .filter(Boolean)
8
+ .join(' ');
9
9
  let inlineCodeStyle = {};
10
10
  if (props.code) {
11
11
  inlineCodeStyle = {
@@ -24,6 +24,12 @@ export type AffineTextStyleAttributes = {
24
24
  bold?: true | null;
25
25
  italic?: true | null;
26
26
  underline?: true | null;
27
+ /**
28
+ * Declared at the affine level only, like `color`: the store's base
29
+ * attributes do not know it (ADR 0030 §5), and the editor schema is the
30
+ * intersection of those and every inline spec.
31
+ */
32
+ overline?: true | null;
27
33
  strike?: true | null;
28
34
  code?: true | null;
29
35
  color?: string | null;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Turns one colour the browser understands into `rgb()` / `rgba()`.
3
+ */
4
+ export type ResolveLegacyColor = (color: string) => string;
5
+ /**
6
+ * `value` with every modern colour function in it replaced by what `resolve`
7
+ * makes of it — the whole of `oklch(0.7 0.1 200)`, or each colour of a
8
+ * `box-shadow` list. A value with none comes back as the same string. Also
9
+ * what the `backgroundColor` option of html2canvas goes through.
10
+ */
11
+ export declare function toLegacyColors(value: string, resolve?: ResolveLegacyColor): string;
12
+ /**
13
+ * Rewrites, inline on the html2canvas CLONE, every computed colour html2canvas
14
+ * would choke on, so a host theme in `oklch()` (or the library's own
15
+ * `color-mix()`) cannot abort a PNG/PDF export or a "copy as image". Call it
16
+ * first in every `onclone`.
17
+ *
18
+ * html2canvas parses the computed style of the captured subtree AND of the
19
+ * clone's `<html>` and `<body>` (their background), so those two are covered
20
+ * too; shadow roots are already flattened into the clone by then. The resolved
21
+ * value is written over whatever produced it — a CSS variable, a stylesheet
22
+ * rule — as an `!important` inline declaration, which is what the computed
23
+ * style then reports. Every value is read before any is written, so the
24
+ * cascade is recomputed once rather than once per node.
25
+ */
26
+ export declare function normalizeCanvasExportColors(documentClone: Document, subtree: Element, resolve?: ResolveLegacyColor): void;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * The colour functions html2canvas 1.4.1 cannot parse. Its parser knows hex,
3
+ * `rgb[a]()`, `hsl[a]()` and keywords and THROWS on anything else, aborting
4
+ * the whole export. `color(` is what Chrome computes `color-mix(in srgb, …)`
5
+ * to; `color-mix` and `light-dark` are here for a computed value that keeps
6
+ * them. `color-mix` precedes `color` so the longer name wins.
7
+ */
8
+ const MODERN_COLOR_FUNCTION = /\b(?:oklch|oklab|lch|lab|hwb|color-mix|color|light-dark)\(/gi;
9
+ /**
10
+ * Every computed property html2canvas reads a colour from. Shorthands are
11
+ * absent on purpose: html2canvas reads the longhands.
12
+ */
13
+ const COLOR_PROPERTIES = [
14
+ 'color',
15
+ 'background-color',
16
+ 'background-image',
17
+ 'border-top-color',
18
+ 'border-right-color',
19
+ 'border-bottom-color',
20
+ 'border-left-color',
21
+ 'outline-color',
22
+ 'text-decoration-color',
23
+ '-webkit-text-stroke-color',
24
+ 'text-shadow',
25
+ 'box-shadow',
26
+ 'caret-color',
27
+ 'fill',
28
+ 'stroke',
29
+ ];
30
+ let probe;
31
+ const resolved = new Map();
32
+ /**
33
+ * The browser's own reading of a colour, through a 1×1 canvas: paint it, read
34
+ * the pixel back. Reading `fillStyle` back is not enough — recent engines keep
35
+ * the modern syntax there. Cached per string, since a theme repeats a handful
36
+ * of colours across every node. Where no 2D context exists the colour comes
37
+ * back unchanged: there is nothing to rasterise with either.
38
+ */
39
+ const resolveColorThroughCanvas = color => {
40
+ const cached = resolved.get(color);
41
+ if (cached !== undefined)
42
+ return cached;
43
+ probe ??= Object.assign(document.createElement('canvas'), {
44
+ width: 1,
45
+ height: 1,
46
+ }).getContext('2d', { willReadFrequently: true });
47
+ if (!probe)
48
+ return color;
49
+ probe.clearRect(0, 0, 1, 1);
50
+ probe.fillStyle = color;
51
+ probe.fillRect(0, 0, 1, 1);
52
+ const [r, g, b, a] = probe.getImageData(0, 0, 1, 1).data;
53
+ const legacy = a === 255
54
+ ? `rgb(${r}, ${g}, ${b})`
55
+ : `rgba(${r}, ${g}, ${b}, ${Number((a / 255).toFixed(3))})`;
56
+ resolved.set(color, legacy);
57
+ return legacy;
58
+ };
59
+ /**
60
+ * `value` with every modern colour function in it replaced by what `resolve`
61
+ * makes of it — the whole of `oklch(0.7 0.1 200)`, or each colour of a
62
+ * `box-shadow` list. A value with none comes back as the same string. Also
63
+ * what the `backgroundColor` option of html2canvas goes through.
64
+ */
65
+ export function toLegacyColors(value, resolve = resolveColorThroughCanvas) {
66
+ MODERN_COLOR_FUNCTION.lastIndex = 0;
67
+ let match = MODERN_COLOR_FUNCTION.exec(value);
68
+ if (!match)
69
+ return value;
70
+ let out = '';
71
+ let from = 0;
72
+ while (match) {
73
+ // Balanced parentheses: `color-mix()` nests whole colours.
74
+ let end = match.index + match[0].length;
75
+ for (let depth = 1; end < value.length && depth > 0; end++) {
76
+ if (value[end] === '(')
77
+ depth++;
78
+ else if (value[end] === ')')
79
+ depth--;
80
+ }
81
+ out +=
82
+ value.slice(from, match.index) + resolve(value.slice(match.index, end));
83
+ from = end;
84
+ MODERN_COLOR_FUNCTION.lastIndex = end;
85
+ match = MODERN_COLOR_FUNCTION.exec(value);
86
+ }
87
+ return out + value.slice(from);
88
+ }
89
+ /**
90
+ * Rewrites, inline on the html2canvas CLONE, every computed colour html2canvas
91
+ * would choke on, so a host theme in `oklch()` (or the library's own
92
+ * `color-mix()`) cannot abort a PNG/PDF export or a "copy as image". Call it
93
+ * first in every `onclone`.
94
+ *
95
+ * html2canvas parses the computed style of the captured subtree AND of the
96
+ * clone's `<html>` and `<body>` (their background), so those two are covered
97
+ * too; shadow roots are already flattened into the clone by then. The resolved
98
+ * value is written over whatever produced it — a CSS variable, a stylesheet
99
+ * rule — as an `!important` inline declaration, which is what the computed
100
+ * style then reports. Every value is read before any is written, so the
101
+ * cascade is recomputed once rather than once per node.
102
+ */
103
+ export function normalizeCanvasExportColors(documentClone, subtree, resolve = resolveColorThroughCanvas) {
104
+ const view = documentClone.defaultView ?? window;
105
+ const nodes = new Set([
106
+ documentClone.documentElement,
107
+ documentClone.body,
108
+ subtree,
109
+ ...subtree.querySelectorAll('*'),
110
+ ]);
111
+ const writes = [];
112
+ for (const node of nodes) {
113
+ const style = node?.style;
114
+ if (!node || !style)
115
+ continue;
116
+ const computed = view.getComputedStyle(node);
117
+ for (const property of COLOR_PROPERTIES) {
118
+ const value = computed.getPropertyValue(property);
119
+ const legacy = toLegacyColors(value, resolve);
120
+ if (legacy !== value)
121
+ writes.push([style, property, legacy]);
122
+ }
123
+ }
124
+ for (const [style, property, legacy] of writes) {
125
+ style.setProperty(property, legacy, 'important');
126
+ }
127
+ }
@@ -55,17 +55,14 @@ export declare function getImageFilesFromLocal(): Promise<File[]>;
55
55
  /**
56
56
  * A name a file system will accept, minus the extension.
57
57
  *
58
- * The sanitiser the framework exports each wrote for themselves
59
- * (`wardleySafeFilename`, `c4SafeFilename`, BPMN's) — same five steps, same
60
- * 120-character ceiling — lifted here for the callers that belong to no
61
- * framework at all. The generic SVG export (ADR 0025) is the first of them: it
62
- * writes a file for ELEVEN kinds of board, so it has no framework's fallback to
63
- * borrow and takes one as a parameter instead.
64
- *
65
- * The three framework copies stay where they are: each is part of an
66
- * interchange capability with its own format id and its own declared fallback
67
- * (`map`, `board`, `process`), and rewriting them to call this one would touch
68
- * three exported APIs for no behaviour change.
58
+ * Every file the library writes is named through it: the generic SVG export
59
+ * (ADR 0025), which writes a file for every kind of board and so takes its
60
+ * fallback as a parameter, and the framework interchanges, whose exported
61
+ * sanitisers (`wardleySafeFilename`, `c4SafeFilename`, `bpmnSafeFilename`,
62
+ * `umlSafeFilename`) keep their names and signatures and only supply their own
63
+ * fallback word. They were verbatim copies of this rule;
64
+ * `safe-filename-parity.unit.spec.ts` in `packages/affine/all` holds every one
65
+ * to it, because what a downloaded file is called is visible behaviour.
69
66
  */
70
67
  export declare function safeFilename(raw: string | undefined, fallback: string): string;
71
68
  export declare function downloadBlob(blob: Blob, name: string): void;
@@ -191,17 +191,14 @@ export async function getImageFilesFromLocal() {
191
191
  /**
192
192
  * A name a file system will accept, minus the extension.
193
193
  *
194
- * The sanitiser the framework exports each wrote for themselves
195
- * (`wardleySafeFilename`, `c4SafeFilename`, BPMN's) — same five steps, same
196
- * 120-character ceiling — lifted here for the callers that belong to no
197
- * framework at all. The generic SVG export (ADR 0025) is the first of them: it
198
- * writes a file for ELEVEN kinds of board, so it has no framework's fallback to
199
- * borrow and takes one as a parameter instead.
200
- *
201
- * The three framework copies stay where they are: each is part of an
202
- * interchange capability with its own format id and its own declared fallback
203
- * (`map`, `board`, `process`), and rewriting them to call this one would touch
204
- * three exported APIs for no behaviour change.
194
+ * Every file the library writes is named through it: the generic SVG export
195
+ * (ADR 0025), which writes a file for every kind of board and so takes its
196
+ * fallback as a parameter, and the framework interchanges, whose exported
197
+ * sanitisers (`wardleySafeFilename`, `c4SafeFilename`, `bpmnSafeFilename`,
198
+ * `umlSafeFilename`) keep their names and signatures and only supply their own
199
+ * fallback word. They were verbatim copies of this rule;
200
+ * `safe-filename-parity.unit.spec.ts` in `packages/affine/all` holds every one
201
+ * to it, because what a downloaded file is called is visible behaviour.
205
202
  */
206
203
  export function safeFilename(raw, fallback) {
207
204
  const safe = (raw ?? '')
@@ -1,5 +1,6 @@
1
1
  export * from './auto-scroll.js';
2
2
  export * from './button-popper.js';
3
+ export * from './canvas-export-colors.js';
3
4
  export * from './collapsed/index.js';
4
5
  export * from './computing.js';
5
6
  export * from './dnd/index.js';
@@ -13,6 +14,7 @@ export * from './fractional-indexing.js';
13
14
  export * from './image.js';
14
15
  export * from './insert.js';
15
16
  export * from './is-abort-error.js';
17
+ export * from './label-mode.js';
16
18
  export * from './link-preview-refresh.js';
17
19
  export * from './math.js';
18
20
  export * from './model/index.js';
@@ -1,5 +1,6 @@
1
1
  export * from './auto-scroll.js';
2
2
  export * from './button-popper.js';
3
+ export * from './canvas-export-colors.js';
3
4
  export * from './collapsed/index.js';
4
5
  export * from './computing.js';
5
6
  export * from './dnd/index.js';
@@ -13,6 +14,7 @@ export * from './fractional-indexing.js';
13
14
  export * from './image.js';
14
15
  export * from './insert.js';
15
16
  export * from './is-abort-error.js';
17
+ export * from './label-mode.js';
16
18
  export * from './link-preview-refresh.js';
17
19
  export * from './math.js';
18
20
  export * from './model/index.js';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Whether a catalogue symbol can carry its name INSIDE it, or the name must
3
+ * GRAVITATE around it (rule R38, `docs/add-a-framework/02-framework-rules.md`;
4
+ * ADR 0029).
5
+ *
6
+ * The rule has one criterion, the symbol's size: a normal-size text — 18 model
7
+ * units, the size Wardley's prominent labels and BPMN's inner text use — of two
8
+ * five-letter words must fit legibly inside the shape at its canonical creation
9
+ * size, without enlarging it. If it does not, the label is a free text element
10
+ * grouped with the symbol (R16) instead of the shape's own `text`.
11
+ *
12
+ * The test is arithmetic on the preset, so a framework's spec can assert its
13
+ * label mode for every kind without a canvas:
14
+ *
15
+ * - the inner box is the shape minus the native shape text insets
16
+ * (`SHAPE_TEXT_VERTICAL_PADDING` = 10, `SHAPE_TEXT_PADDING` = 20 in
17
+ * `@labre/affine-model`, the defaults below);
18
+ * - a non-rectangular silhouette only offers the rectangle inscribed in it:
19
+ * ≈ 1/√2 of each side for an ellipse (0.7), half of each side for a diamond;
20
+ * - the probe is "Hello World" (two five-letter words and a space), set on one
21
+ * line or broken into two lines of five letters; it fits if either layout
22
+ * fits.
23
+ *
24
+ * Average advance 0.5 em: Inter's advances for the probe itself ("Hello World"
25
+ * ≈ 5.4 em) average 0.49 em, which is what decides a 140-wide annotation at 18
26
+ * units — a generic 0.55 em prose average would reject a box the probe
27
+ * visibly fits. Line height 1.2 em, the renderer's default for single-spaced
28
+ * canvas text.
29
+ *
30
+ * ponytail: no real font metrics — a fixed per-glyph average and a fixed line
31
+ * height, so a shape within a few units of the threshold may be judged wrongly
32
+ * for a font other than Inter. The upgrade is to measure the probe with the
33
+ * shape renderer's `wrapText` / `getLineHeight` in a browser-mode spec.
34
+ */
35
+ export interface InscribedLabelProbe {
36
+ /** Canonical creation width, model units. */
37
+ w: number;
38
+ /** Canonical creation height, model units. */
39
+ h: number;
40
+ /** Native shape type: `ellipse`, `diamond`, `rect`, or a polygon name. */
41
+ shapeType: string;
42
+ /** Reference size of the fit test, not a mandate for the label's own size. */
43
+ fontSize?: number;
44
+ /** `[vertical, horizontal]` inset, as the native shape pads its text. */
45
+ padding?: [number, number];
46
+ }
47
+ export declare const fitsInscribedLabel: ({ w, h, shapeType, fontSize, padding, }: InscribedLabelProbe) => boolean;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Whether a catalogue symbol can carry its name INSIDE it, or the name must
3
+ * GRAVITATE around it (rule R38, `docs/add-a-framework/02-framework-rules.md`;
4
+ * ADR 0029).
5
+ *
6
+ * The rule has one criterion, the symbol's size: a normal-size text — 18 model
7
+ * units, the size Wardley's prominent labels and BPMN's inner text use — of two
8
+ * five-letter words must fit legibly inside the shape at its canonical creation
9
+ * size, without enlarging it. If it does not, the label is a free text element
10
+ * grouped with the symbol (R16) instead of the shape's own `text`.
11
+ *
12
+ * The test is arithmetic on the preset, so a framework's spec can assert its
13
+ * label mode for every kind without a canvas:
14
+ *
15
+ * - the inner box is the shape minus the native shape text insets
16
+ * (`SHAPE_TEXT_VERTICAL_PADDING` = 10, `SHAPE_TEXT_PADDING` = 20 in
17
+ * `@labre/affine-model`, the defaults below);
18
+ * - a non-rectangular silhouette only offers the rectangle inscribed in it:
19
+ * ≈ 1/√2 of each side for an ellipse (0.7), half of each side for a diamond;
20
+ * - the probe is "Hello World" (two five-letter words and a space), set on one
21
+ * line or broken into two lines of five letters; it fits if either layout
22
+ * fits.
23
+ *
24
+ * Average advance 0.5 em: Inter's advances for the probe itself ("Hello World"
25
+ * ≈ 5.4 em) average 0.49 em, which is what decides a 140-wide annotation at 18
26
+ * units — a generic 0.55 em prose average would reject a box the probe
27
+ * visibly fits. Line height 1.2 em, the renderer's default for single-spaced
28
+ * canvas text.
29
+ *
30
+ * ponytail: no real font metrics — a fixed per-glyph average and a fixed line
31
+ * height, so a shape within a few units of the threshold may be judged wrongly
32
+ * for a font other than Inter. The upgrade is to measure the probe with the
33
+ * shape renderer's `wrapText` / `getLineHeight` in a browser-mode spec.
34
+ */
35
+ /** The probe: two five-letter words, as in "Hello World". */
36
+ const PROBE_WORD_LENGTH = 5;
37
+ const PROBE_ONE_LINE_LENGTH = 2 * PROBE_WORD_LENGTH + 1;
38
+ /** Average Inter advance over the probe, in em. */
39
+ const AVERAGE_ADVANCE_EM = 0.5;
40
+ const LINE_HEIGHT_EM = 1.2;
41
+ /** Share of each side of the inner box a silhouette leaves usable. */
42
+ const INSCRIBED_FACTOR = Object.assign(Object.create(null), { ellipse: 0.7, diamond: 0.5 });
43
+ export const fitsInscribedLabel = ({ w, h, shapeType, fontSize = 18, padding = [10, 20], }) => {
44
+ const factor = INSCRIBED_FACTOR[shapeType] ?? 1;
45
+ const innerW = (w - 2 * padding[1]) * factor;
46
+ const innerH = (h - 2 * padding[0]) * factor;
47
+ if (innerW <= 0 || innerH <= 0)
48
+ return false;
49
+ const advance = AVERAGE_ADVANCE_EM * fontSize;
50
+ const lineHeight = LINE_HEIGHT_EM * fontSize;
51
+ const oneLine = PROBE_ONE_LINE_LENGTH * advance <= innerW && lineHeight <= innerH;
52
+ if (oneLine)
53
+ return true;
54
+ return PROBE_WORD_LENGTH * advance <= innerW && 2 * lineHeight <= innerH;
55
+ };
@@ -18,7 +18,13 @@ export function mergeToCodeModel(models) {
18
18
  })
19
19
  .filter(Boolean)
20
20
  .join('\n');
21
- models.forEach(model => doc.deleteBlock(model));
21
+ // Add first and delete only once the code block exists: `addBlock` returns
22
+ // an id even when the parent rejected the flavour (a callout only takes
23
+ // paragraphs and lists), and deleting first lost the text (#418).
22
24
  const id = doc.addBlock('affine:code', { text: new Text(text) }, parent, index);
25
+ if (!doc.getModelById(id)) {
26
+ return null;
27
+ }
28
+ models.forEach(model => doc.deleteBlock(model));
23
29
  return id;
24
30
  }
@@ -12,7 +12,12 @@ export function transformModel(model, flavour, props) {
12
12
  const index = parent.children.indexOf(model);
13
13
  // Sometimes the new block can not be added due to some reason, e.g. invalid schema check.
14
14
  // So we need to try to add the new block first, and if it fails, we will not delete the old block.
15
+ // `addBlock` returns an id even when the schema check threw (`transact`
16
+ // swallows it), so only `getModelById` proves the block exists (#418).
15
17
  const id = doc.addBlock(flavour, blockProps, parent, index);
18
+ if (!doc.getModelById(id)) {
19
+ return null;
20
+ }
16
21
  doc.deleteBlock(model, {
17
22
  deleteChildren: false,
18
23
  });
@@ -10,11 +10,11 @@ export class EdgelessDraggingAreaRectWidget extends WidgetComponent {
10
10
  static { this.styles = css `
11
11
  .affine-edgeless-dragging-area {
12
12
  position: absolute;
13
- background: ${unsafeCSS(cssVarV2('edgeless/selection/selectionMarqueeBackground', '#1E96EB14'))};
13
+ background: ${unsafeCSS(cssVarV2('edgeless/selection/selectionMarqueeBackground'))};
14
14
  box-sizing: border-box;
15
15
  border-width: 1px;
16
16
  border-style: solid;
17
- border-color: ${unsafeCSS(cssVarV2('edgeless/selection/selectionMarqueeBorder', '#1E96EB'))};
17
+ border-color: ${unsafeCSS(cssVarV2('edgeless/selection/selectionMarqueeBorder'))};
18
18
 
19
19
  z-index: 1;
20
20
  pointer-events: none;
@@ -1,6 +1,7 @@
1
- import { EdgelessCRUDIdentifier, isNoteBlock, Overlay, } from '../affine-block-surface/index.js';
1
+ import { applyCreationLayer, EdgelessCRUDIdentifier, isNoteBlock, Overlay, sourceLayerOf, } from '../affine-block-surface/index.js';
2
2
  import { ShapeFactory } from '../affine-gfx-shape/index.js';
3
3
  import { getShapeRadius, getShapeType, GroupElementModel, ShapeElementModel, } from '../affine-model/index.js';
4
+ import { getChromeAccentColor } from '../affine-shared/services/index.js';
4
5
  import { BlockSuiteError, ErrorCode } from '../global/exceptions/index.js';
5
6
  import { Bound, normalizeDegAngle } from '../global/gfx/index.js';
6
7
  import { assertType } from '../global/utils/index.js';
@@ -33,7 +34,10 @@ export class AutoCompleteTextOverlay extends AutoCompleteTargetOverlay {
33
34
  render(ctx, _rc) {
34
35
  const [x, y, w, h] = this.xywh;
35
36
  ctx.globalAlpha = 0.4;
36
- ctx.strokeStyle = '#1e96eb';
37
+ // The accent read from the theme, not a literal: a canvas context cannot
38
+ // take a `var(…)`, so the token is resolved here (DESIGN.md, The Borrowed
39
+ // Blue Rule).
40
+ ctx.strokeStyle = getChromeAccentColor(this.gfx.std);
37
41
  ctx.lineWidth = 1;
38
42
  ctx.strokeRect(x, y, w, h);
39
43
  // fill text placeholder
@@ -226,6 +230,9 @@ export function createEdgelessElement(edgeless, current, bound) {
226
230
  ...current.serialize(),
227
231
  text: new Y.Text(),
228
232
  xywh: bound.serialize(),
233
+ // `serialize()` names no layer for a default-layer shape: ask for the
234
+ // source's explicitly, or the clone lands in the active layer.
235
+ layer: sourceLayerOf(current),
229
236
  });
230
237
  if (!id)
231
238
  return null;
@@ -233,12 +240,16 @@ export function createEdgelessElement(edgeless, current, bound) {
233
240
  }
234
241
  else if (isNoteBlock(current)) {
235
242
  const { store } = edgeless;
236
- id = store.addBlock('affine:note', {
243
+ const props = {
237
244
  background: current.props.background,
238
245
  displayMode: current.props.displayMode,
239
246
  edgeless: current.props.edgeless,
240
247
  xywh: bound.serialize(),
241
- }, edgeless.model.id);
248
+ // Beside its source, not in the viewer's active layer (ADR 0031 §6).
249
+ layer: sourceLayerOf(current),
250
+ };
251
+ applyCreationLayer(edgeless.std, props);
252
+ id = store.addBlock('affine:note', props, edgeless.model.id);
242
253
  const note = store.getBlock(id)?.model;
243
254
  if (!note) {
244
255
  throw new BlockSuiteError(ErrorCode.GfxBlockElementError, 'Note block is not found after creation');
@@ -35,9 +35,11 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
35
35
  import { EDITOR_ANCHORED_PANEL_Z_INDEX } from '../../affine-block-surface/index.js';
36
36
  import { TOUCH_TARGET_MIN_PX } from '../../affine-shared/consts/index.js';
37
37
  import { CATALOGUE_OTHER, translateKey } from '../../affine-shared/services/index.js';
38
+ import { panelHeaderStyles } from '../../affine-shared/styles/index.js';
38
39
  import { IS_MAC } from '../../global/env/index.js';
39
40
  import { getCommandIcon, CommandUsageIdentifier, getCommandsForSurface, isCommandAvailable, normalizeLegacyCombo, rankCommandsByUsage, runCommand, ShortcutOverrideIdentifier, WidgetComponent, WidgetViewExtension, } from '../../std/index.js';
40
41
  import { GfxControllerIdentifier } from '../../std/gfx/index.js';
42
+ import { CloseIcon } from '@blocksuite/icons/lit';
41
43
  import { css, html, nothing, unsafeCSS } from 'lit';
42
44
  import { state } from 'lit/decorators.js';
43
45
  import { literal, unsafeStatic } from 'lit/static-html.js';
@@ -218,49 +220,13 @@ let EdgelessArtefactCatalogueWidget = (() => {
218
220
  outline-offset: -2px;
219
221
  }
220
222
 
221
- .artefact-catalogue-head {
222
- display: flex;
223
- align-items: center;
224
- justify-content: space-between;
225
- gap: 8px;
226
- padding: 8px 8px 8px 16px;
227
- border-bottom: 1px solid var(--affine-border-color);
228
- font-weight: 600;
229
- }
230
-
231
- .artefact-catalogue-title {
232
- overflow: hidden;
233
- text-overflow: ellipsis;
234
- white-space: nowrap;
235
- }
236
-
237
223
  /*
238
- A close button a finger can hit. Square at the touch minimum rather than
239
- the 6px-padded × the anchored panels use: this one is the only way out of
240
- a full-height surface on a tablet, where there is no Escape key.
224
+ The header row, its title and its close button are the frame panel's,
225
+ shared with the selection pane through panelHeaderStyles. The close is
226
+ the frame panel's 20px icon button, no longer the touch-sized ×: one
227
+ header design across the side panels was the product owner's call.
241
228
  */
242
- .artefact-catalogue-close {
243
- flex: none;
244
- display: flex;
245
- align-items: center;
246
- justify-content: center;
247
- width: ${unsafeCSS(TOUCH_TARGET_MIN_PX)}px;
248
- height: ${unsafeCSS(TOUCH_TARGET_MIN_PX)}px;
249
- border: none;
250
- border-radius: 8px;
251
- background: transparent;
252
- color: var(--affine-text-secondary-color);
253
- font-family: inherit;
254
- font-size: 20px;
255
- line-height: 1;
256
- cursor: pointer;
257
- }
258
-
259
- .artefact-catalogue-close:hover,
260
- .artefact-catalogue-close:focus-visible {
261
- background: var(--affine-hover-color);
262
- color: var(--affine-text-primary-color);
263
- }
229
+ ${panelHeaderStyles}
264
230
 
265
231
  .artefact-catalogue-body {
266
232
  flex: 1;
@@ -536,6 +502,7 @@ let EdgelessArtefactCatalogueWidget = (() => {
536
502
  // prose, and a host with a catalogue always wins.
537
503
  const frameworkLabel = translateKey(this.std, `com.labre.framework.${owner}`, humanizeCategory(owner));
538
504
  const catalogueTitle = translateKey(this.std, 'com.labre.catalogue.title', 'Artefacts');
505
+ const closeLabel = translateKey(this.std, 'com.labre.catalogue.close', 'Close');
539
506
  return html `<div
540
507
  class="artefact-catalogue-panel"
541
508
  role="dialog"
@@ -547,17 +514,26 @@ let EdgelessArtefactCatalogueWidget = (() => {
547
514
  @pointerup=${this._swallow}
548
515
  @click=${this._swallow}
549
516
  >
550
- <div class="artefact-catalogue-head">
551
- <span class="artefact-catalogue-title">${frameworkLabel}</span>
552
- <button
553
- class="artefact-catalogue-close"
554
- type="button"
517
+ <div
518
+ class="artefact-catalogue-head affine-panel-header"
519
+ data-testid="artefact-catalogue-header"
520
+ >
521
+ <span
522
+ class="artefact-catalogue-title affine-panel-header-title"
523
+ data-testid="artefact-catalogue-title"
524
+ >${frameworkLabel}</span
525
+ >
526
+ <edgeless-tool-icon-button
527
+ class="artefact-catalogue-close affine-panel-header-button"
555
528
  data-testid="artefact-catalogue-close"
556
- aria-label=${translateKey(this.std, 'com.labre.catalogue.close', 'Close')}
529
+ aria-label=${closeLabel}
530
+ .tooltip=${closeLabel}
531
+ .tipPosition=${'top'}
532
+ .activeMode=${'background'}
557
533
  @click=${this.closePanel}
558
534
  >
559
- ×
560
- </button>
535
+ ${CloseIcon({ width: '20px', height: '20px' })}
536
+ </edgeless-tool-icon-button>
561
537
  </div>
562
538
  <div
563
539
  class="artefact-catalogue-body"