@formicoidea/labre-core 0.42.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/dist/_pkgs/affine-block-attachment/utils.js +4 -0
  2. package/dist/_pkgs/affine-block-bookmark/configs/toolbar.js +17 -4
  3. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.d.ts +29 -0
  4. package/dist/_pkgs/affine-block-callout/commands/turn-into-callout.js +81 -0
  5. package/dist/_pkgs/affine-block-callout/configs/slash-menu.js +6 -4
  6. package/dist/_pkgs/affine-block-callout/configs/turn-into.d.ts +8 -0
  7. package/dist/_pkgs/affine-block-callout/configs/turn-into.js +19 -0
  8. package/dist/_pkgs/affine-block-callout/translations.d.ts +4 -2
  9. package/dist/_pkgs/affine-block-callout/translations.js +4 -2
  10. package/dist/_pkgs/affine-block-callout/view.js +3 -0
  11. package/dist/_pkgs/affine-block-code/code-block-service.d.ts +13 -0
  12. package/dist/_pkgs/affine-block-code/code-block-service.js +26 -0
  13. package/dist/_pkgs/affine-block-code/code-block.d.ts +6 -0
  14. package/dist/_pkgs/affine-block-code/code-block.js +11 -2
  15. package/dist/_pkgs/affine-block-code/code-toolbar/components/lang-button.js +31 -8
  16. package/dist/_pkgs/affine-block-data-view/configs/tooltips.js +1 -1
  17. package/dist/_pkgs/affine-block-database/configs/tooltips.js +1 -1
  18. package/dist/_pkgs/affine-block-edgeless-text/edgeless-text-block.js +4 -2
  19. package/dist/_pkgs/affine-block-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  20. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  21. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  22. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  23. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.d.ts +39 -0
  24. package/dist/_pkgs/affine-block-embed/common/iframe-sandbox.js +39 -0
  25. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  26. package/dist/_pkgs/affine-block-embed/embed-figma-block/embed-figma-block.js +2 -0
  27. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.d.ts +14 -1
  28. package/dist/_pkgs/affine-block-embed/embed-iframe-block/components/embed-iframe-error-card.js +21 -2
  29. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  30. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.d.ts +0 -2
  31. package/dist/_pkgs/affine-block-embed/embed-iframe-block/consts.js +2 -5
  32. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.d.ts +1 -1
  33. package/dist/_pkgs/affine-block-embed/embed-iframe-block/embed-iframe-block.js +14 -6
  34. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.d.ts +16 -0
  35. package/dist/_pkgs/affine-block-embed/embed-iframe-block/types.js +17 -1
  36. package/dist/_pkgs/affine-block-embed/embed-loom-block/embed-loom-block.js +2 -0
  37. package/dist/_pkgs/affine-block-embed/embed-youtube-block/embed-youtube-block.js +2 -0
  38. package/dist/_pkgs/affine-block-embed/index.d.ts +1 -0
  39. package/dist/_pkgs/affine-block-embed/index.js +1 -0
  40. package/dist/_pkgs/affine-block-embed/translations.d.ts +8 -0
  41. package/dist/_pkgs/affine-block-embed/translations.js +28 -0
  42. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  43. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-linked-doc-block.js +4 -2
  44. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  45. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  46. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-synced-doc-block.js +2 -2
  47. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  48. package/dist/_pkgs/affine-block-frame/frame-manager.js +53 -19
  49. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  50. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  51. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  52. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  53. package/dist/_pkgs/affine-block-list/utils/get-list-icon.js +3 -1
  54. package/dist/_pkgs/affine-block-note/configs/tooltips.js +1 -1
  55. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  56. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  57. package/dist/_pkgs/affine-block-root/adapters/html.js +2 -2
  58. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.d.ts +2 -0
  59. package/dist/_pkgs/affine-block-root/commands/copy-link-commands.js +155 -0
  60. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  61. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  62. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  63. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  64. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  65. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  66. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  67. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  68. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  69. package/dist/_pkgs/affine-block-root/index.d.ts +1 -0
  70. package/dist/_pkgs/affine-block-root/index.js +1 -0
  71. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  72. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  73. package/dist/_pkgs/affine-block-root/view.js +2 -0
  74. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  75. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  76. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  77. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  78. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  85. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  86. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  87. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  88. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  89. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  90. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  93. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  94. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  96. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  97. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  98. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  99. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  100. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  101. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  102. package/dist/_pkgs/affine-block-surface/extensions/interchange-import.js +13 -1
  103. package/dist/_pkgs/affine-block-surface/extensions/legend.d.ts +8 -0
  104. package/dist/_pkgs/affine-block-surface/extensions/legend.js +59 -3
  105. package/dist/_pkgs/affine-block-surface/extensions/morph-toolbar.js +4 -0
  106. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  107. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  108. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  109. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  110. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  111. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  112. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  113. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  114. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  115. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  116. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  117. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  118. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.d.ts +3 -0
  119. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch-translations.js +23 -0
  120. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  121. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +98 -19
  122. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  123. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  124. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  125. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  126. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  127. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  128. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  129. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  130. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  131. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  132. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  133. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  134. package/dist/_pkgs/affine-block-surface/framework-background/background-view.js +1 -1
  135. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  136. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  137. package/dist/_pkgs/affine-block-surface/framework-background/fit.d.ts +36 -0
  138. package/dist/_pkgs/affine-block-surface/framework-background/fit.js +30 -0
  139. package/dist/_pkgs/affine-block-surface/framework-background/index.d.ts +1 -0
  140. package/dist/_pkgs/affine-block-surface/framework-background/index.js +1 -0
  141. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  142. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  143. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  144. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  145. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  146. package/dist/_pkgs/affine-block-surface/renderer/element-highlight-overlay.js +2 -7
  147. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  148. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  149. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  150. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  151. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  152. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  153. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  154. package/dist/_pkgs/affine-block-surface-ref/configs/tooltips.js +2 -2
  155. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  156. package/dist/_pkgs/affine-components/color-picker/palette-carousel.js +5 -0
  157. package/dist/_pkgs/affine-components/color-picker/styles.js +1 -1
  158. package/dist/_pkgs/affine-components/context-menu/button.js +17 -1
  159. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  160. package/dist/_pkgs/affine-components/icons/ai.js +3 -3
  161. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  162. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  163. package/dist/_pkgs/affine-components/icons/list.js +7 -1
  164. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  165. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  166. package/dist/_pkgs/affine-components/size-dropdown-menu/dropdown-menu.js +6 -1
  167. package/dist/_pkgs/affine-components/toolbar/index.d.ts +1 -1
  168. package/dist/_pkgs/affine-components/toolbar/index.js +1 -1
  169. package/dist/_pkgs/affine-components/toolbar/menu-button.d.ts +7 -0
  170. package/dist/_pkgs/affine-components/toolbar/menu-button.js +30 -0
  171. package/dist/_pkgs/affine-components/toolbar/picker-menu.d.ts +16 -1
  172. package/dist/_pkgs/affine-components/toolbar/picker-menu.js +2 -2
  173. package/dist/_pkgs/affine-components/toolbar/toolbar.d.ts +1 -0
  174. package/dist/_pkgs/affine-components/toolbar/toolbar.js +67 -0
  175. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  176. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card-title-editor.js +1 -1
  177. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +3 -3
  178. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  179. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  180. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  181. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  182. package/dist/_pkgs/affine-gfx-brush/toolbar/components/eraser/icons.js +1 -1
  183. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.d.ts +11 -2
  184. package/dist/_pkgs/affine-gfx-connector/direction/direction-reveal.js +11 -2
  185. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  186. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  187. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +6 -4
  188. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +24 -8
  189. package/dist/_pkgs/affine-gfx-connector/translations.d.ts +3 -0
  190. package/dist/_pkgs/affine-gfx-connector/translations.js +23 -0
  191. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  192. package/dist/_pkgs/affine-gfx-mindmap/indicator-overlay/index.js +6 -2
  193. package/dist/_pkgs/affine-gfx-mindmap/toolbar/config.js +4 -2
  194. package/dist/_pkgs/affine-gfx-mindmap/translations.d.ts +6 -0
  195. package/dist/_pkgs/affine-gfx-mindmap/translations.js +10 -0
  196. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  197. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  198. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +5 -3
  199. package/dist/_pkgs/affine-gfx-shape/translations.d.ts +7 -0
  200. package/dist/_pkgs/affine-gfx-shape/translations.js +11 -0
  201. package/dist/_pkgs/affine-gfx-template/builtin/other.js +13 -7
  202. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  203. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  204. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  205. package/dist/_pkgs/affine-gfx-template/toolbar/template-loading.js +1 -1
  206. package/dist/_pkgs/affine-gfx-template/translations.d.ts +5 -0
  207. package/dist/_pkgs/affine-gfx-template/translations.js +38 -0
  208. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +5 -3
  209. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  210. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  211. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  212. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  213. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +56 -3
  214. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  215. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  216. package/dist/_pkgs/affine-gfx-text/translations.d.ts +8 -0
  217. package/dist/_pkgs/affine-gfx-text/translations.js +12 -0
  218. package/dist/_pkgs/affine-inline-latex/latex-node/latex-editor-menu.js +2 -1
  219. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  220. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  221. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  222. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  223. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  224. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  225. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  226. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  227. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  228. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  229. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  230. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  231. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  232. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  233. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  234. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  235. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  236. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  237. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  238. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  239. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  240. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  241. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  242. package/dist/_pkgs/affine-model/consts/text.d.ts +41 -2
  243. package/dist/_pkgs/affine-model/consts/text.js +50 -1
  244. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  245. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  246. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  247. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  248. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  249. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  250. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  251. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  252. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  253. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  254. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  255. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  256. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  257. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  258. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  259. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  260. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  261. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  262. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  263. package/dist/_pkgs/affine-shared/services/font-loader/config.d.ts +13 -2
  264. package/dist/_pkgs/affine-shared/services/font-loader/config.js +43 -54
  265. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  266. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  267. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  268. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  269. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  270. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  271. package/dist/_pkgs/affine-shared/services/theme-service.d.ts +19 -0
  272. package/dist/_pkgs/affine-shared/services/theme-service.js +24 -0
  273. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +25 -0
  274. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +90 -0
  275. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  276. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  277. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  278. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  279. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  280. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  281. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  282. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  283. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  284. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  285. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  286. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  287. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  288. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  289. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  290. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  291. package/dist/_pkgs/affine-widget-edgeless-dragging-area/edgeless-dragging-area-rect.js +2 -2
  292. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +15 -4
  293. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  294. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/types.d.ts +15 -0
  295. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.d.ts +1 -1
  296. package/dist/_pkgs/affine-widget-edgeless-toolbar/config/utils.js +7 -2
  297. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  298. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  299. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  300. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  301. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.d.ts +18 -0
  302. package/dist/_pkgs/affine-widget-edgeless-toolbar/panel/font-family-panel.js +52 -6
  303. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  304. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  305. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  306. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  307. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  308. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  309. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  310. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  311. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  312. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  313. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +58 -0
  314. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +171 -1
  315. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  316. package/dist/_pkgs/affine-widget-frame-title/edgeless-frame-title-editor.js +2 -1
  317. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  318. package/dist/_pkgs/affine-widget-slash-menu/translations.d.ts +16 -0
  319. package/dist/_pkgs/affine-widget-slash-menu/translations.js +23 -1
  320. package/dist/_pkgs/affine-widget-toolbar/utils.js +57 -14
  321. package/dist/_pkgs/data-view/core/detail/field.js +2 -1
  322. package/dist/_pkgs/data-view/core/filter/literal/define.js +3 -1
  323. package/dist/_pkgs/data-view/core/group-by/renderer/boolean-group.js +1 -1
  324. package/dist/_pkgs/data-view/property-presets/checkbox/cell-renderer.js +8 -2
  325. package/dist/_pkgs/data-view/view-presets/kanban/pc/cell.js +1 -1
  326. package/dist/_pkgs/data-view/view-presets/kanban/pc/controller/drag.js +2 -1
  327. package/dist/_pkgs/data-view/view-presets/table/pc/controller/drag.js +2 -1
  328. package/dist/_pkgs/data-view/view-presets/table/pc/controller/selection.js +1 -1
  329. package/dist/_pkgs/data-view/view-presets/table/pc/header/vertical-indicator.js +2 -1
  330. package/dist/_pkgs/data-view/view-presets/table/pc/row/row-select-checkbox.js +3 -1
  331. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/drag.js +2 -1
  332. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/controller/selection.js +1 -1
  333. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/group/top/header/vertical-indicator.js +2 -1
  334. package/dist/_pkgs/data-view/view-presets/table/pc-virtual/row/row-header.js +3 -1
  335. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  336. package/dist/_pkgs/std/gfx/controller.js +22 -2
  337. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  338. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  339. package/dist/_pkgs/std/gfx/index.js +3 -1
  340. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  341. package/dist/_pkgs/std/gfx/layer.js +73 -5
  342. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  343. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  344. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  345. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  346. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  347. package/dist/_pkgs/std/gfx/model/surface/role.d.ts +10 -5
  348. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  349. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  350. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  351. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  352. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  353. package/dist/_pkgs/std/utils/layer.js +64 -13
  354. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  355. package/dist/commands.js +6 -2
  356. package/dist/translations.js +15 -6
  357. package/package.json +13 -2
  358. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  359. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  360. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  361. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  362. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  363. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  364. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  365. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  366. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  367. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -1,6 +1,28 @@
1
- import { generateElementId, sortIndex } from '../../affine-block-surface/index.js';
1
+ import { applyCreationLayer, generateElementId, sortIndex, } from '../../affine-block-surface/index.js';
2
2
  import { Bound } from '../../global/gfx/index.js';
3
3
  import { assertType } from '../../global/utils/index.js';
4
+ /**
5
+ * Everything a template inserts lands in the viewer's active layer (ADR 0031
6
+ * §6). The insertion bypasses both stamped paths — its elements are merged
7
+ * straight into the surface's elements map, its blocks go through
8
+ * `store.addBlock` — so the layer is stamped on the snapshot before it is
9
+ * written, with the same rule as every other creation.
10
+ */
11
+ export const createActiveLayerMiddleware = (std) => {
12
+ return (job) => {
13
+ job.slots.beforeInsert.subscribe(payload => {
14
+ if (payload.type !== 'block')
15
+ return;
16
+ const { props, flavour } = payload.data.blockJson;
17
+ if (flavour === 'affine:surface') {
18
+ Object.values(props.elements).forEach(element => applyCreationLayer(std, element));
19
+ return;
20
+ }
21
+ if (typeof props.xywh === 'string')
22
+ applyCreationLayer(std, props);
23
+ });
24
+ };
25
+ };
4
26
  export const replaceIdMiddleware = (job) => {
5
27
  const regeneratedIdMap = new Map();
6
28
  job.slots.beforeInsert.subscribe(payload => {
@@ -5,7 +5,7 @@ import { assertType } from '../../global/utils/index.js';
5
5
  import { GfxControllerIdentifier } from '../../std/gfx/index.js';
6
6
  import { DocSnapshotSchema, } from '../../store/index.js';
7
7
  import { Subject } from 'rxjs';
8
- import { createInsertPlaceMiddleware, createRegenerateIndexMiddleware, createStickerMiddleware, replaceIdMiddleware, } from './template-middlewares.js';
8
+ import { createActiveLayerMiddleware, createInsertPlaceMiddleware, createRegenerateIndexMiddleware, createStickerMiddleware, replaceIdMiddleware, } from './template-middlewares.js';
9
9
  /**
10
10
  * Those block contains other block's id
11
11
  * should defer the loading
@@ -243,6 +243,7 @@ export function createTemplateJob(std, type, center) {
243
243
  middlewares.push(createStickerMiddleware(center || viewport.center, () => layer.generateIndex()));
244
244
  }
245
245
  middlewares.push(replaceIdMiddleware);
246
+ middlewares.push(createActiveLayerMiddleware(std));
246
247
  return TemplateJob.create({
247
248
  model: surface,
248
249
  type,
@@ -22,7 +22,7 @@ export class AffineTemplateLoading extends LitElement {
22
22
  height: 20px;
23
23
  position: relative;
24
24
  background: conic-gradient(
25
- rgba(30, 150, 235, 1) 90deg,
25
+ var(--affine-primary-color) 90deg,
26
26
  rgba(0, 0, 0, 0.1) 90deg 360deg
27
27
  );
28
28
  border-radius: 50%;
@@ -20,6 +20,11 @@ export declare const TEMPLATE_PANEL_SEARCH_PLACEHOLDER: ChromeWording;
20
20
  export declare const TEMPLATE_PANEL_CATEGORY_OTHER: ChromeWording;
21
21
  /** The "Template" senior tool's own button name (`SeniorTool.labelKey`). */
22
22
  export declare const TEMPLATE_SENIOR_TOOL_NAME: ChromeWording;
23
+ export declare const TEMPLATE_NAME_SWOT: ChromeWording;
24
+ export declare const TEMPLATE_NAME_KANBAN_BOARD: ChromeWording;
25
+ export declare const TEMPLATE_NAME_BUSINESS_MODEL_CANVAS: ChromeWording;
26
+ export declare const TEMPLATE_NAME_FISHBONE: ChromeWording;
27
+ export declare const TEMPLATE_NAME_GANTT_CHART: ChromeWording;
23
28
  export declare const TEMPLATE_PACKAGE_WORDINGS: readonly ChromeWording[];
24
29
  /**
25
30
  * The generic ("Other") diagrams' own seeds: the captions painted onto the
@@ -29,10 +29,48 @@ export const TEMPLATE_SENIOR_TOOL_NAME = [
29
29
  'com.labre.template.senior-tool.name',
30
30
  'Template',
31
31
  ];
32
+ /* ── The five "Other" tiles' own names (#390) ─────────────────────────────
33
+ *
34
+ * A hand-composed template derives no tile name from a command, so it needs a
35
+ * `nameKey` of its own — the same seam every framework category already uses
36
+ * for its hand-written templates (`gfx/bpmn`, `gfx/edgy`, `gfx/mindmap`…).
37
+ * Only the NAME is chrome here; the captions painted into each scene are
38
+ * seeds, declared further down and resolved through `Template.localize`.
39
+ *
40
+ * `TEMPLATE_NAME_BUSINESS_MODEL_CANVAS` and `BMC_SEED_TITLE` share the same
41
+ * English words on purpose and do NOT collide: the seed is written once into
42
+ * the document, the tile is redrawn every time the panel opens, and the
43
+ * "un mot chrome, une clé" test groups `source: 'chrome'` only.
44
+ */
45
+ export const TEMPLATE_NAME_SWOT = [
46
+ 'com.labre.template.name.swot',
47
+ 'SWOT',
48
+ ];
49
+ export const TEMPLATE_NAME_KANBAN_BOARD = [
50
+ 'com.labre.template.name.kanban-board',
51
+ 'Kanban board',
52
+ ];
53
+ export const TEMPLATE_NAME_BUSINESS_MODEL_CANVAS = [
54
+ 'com.labre.template.name.business-model-canvas',
55
+ 'Business model canvas',
56
+ ];
57
+ export const TEMPLATE_NAME_FISHBONE = [
58
+ 'com.labre.template.name.fishbone',
59
+ 'Fishbone (Ishikawa)',
60
+ ];
61
+ export const TEMPLATE_NAME_GANTT_CHART = [
62
+ 'com.labre.template.name.gantt-chart',
63
+ 'Gantt chart',
64
+ ];
32
65
  export const TEMPLATE_PACKAGE_WORDINGS = [
33
66
  TEMPLATE_PANEL_ADD,
34
67
  TEMPLATE_PANEL_SEARCH_PLACEHOLDER,
35
68
  TEMPLATE_SENIOR_TOOL_NAME,
69
+ TEMPLATE_NAME_SWOT,
70
+ TEMPLATE_NAME_KANBAN_BOARD,
71
+ TEMPLATE_NAME_BUSINESS_MODEL_CANVAS,
72
+ TEMPLATE_NAME_FISHBONE,
73
+ TEMPLATE_NAME_GANTT_CHART,
36
74
  ];
37
75
  /**
38
76
  * The generic ("Other") diagrams' own seeds: the captions painted onto the
@@ -46,7 +46,7 @@ import { css, html, nothing } from 'lit';
46
46
  import { property, query } from 'lit/decorators.js';
47
47
  import { styleMap } from 'lit/directives/style-map.js';
48
48
  import * as Y from 'yjs';
49
- import { getCursorByCoord, getLineHeight } from './element-renderer/utils.js';
49
+ import { getCursorByCoord, getLineHeight, textDecorationLine, } from './element-renderer/utils.js';
50
50
  import { TEXT_EDITOR_PLACEHOLDER } from './translations.js';
51
51
  export function mountTextElementEditor(textElement, edgeless, focusCoord) {
52
52
  let cursorIndex = textElement.text.length;
@@ -176,9 +176,10 @@ let EdgelessTextEditor = (() => {
176
176
  transform-origin: left top;
177
177
  font-kerning: none;
178
178
  border: ${EdgelessTextEditor.BORDER_WIDTH}px solid
179
- var(--affine-primary-color, #1e96eb);
179
+ var(--affine-primary-color);
180
180
  border-radius: 4px;
181
- box-shadow: 0px 0px 0px 2px rgba(30, 150, 235, 0.3);
181
+ box-shadow: 0px 0px 0px 2px
182
+ color-mix(in srgb, var(--affine-primary-color) 30%, transparent);
182
183
  padding: ${EdgelessTextEditor.PADDING_VERTICAL}px
183
184
  ${EdgelessTextEditor.PADDING_HORIZONTAL}px;
184
185
  overflow: visible;
@@ -365,6 +366,7 @@ let EdgelessTextEditor = (() => {
365
366
  fontStyle,
366
367
  color,
367
368
  textAlign,
369
+ textDecorationLine: textDecorationLine(this.element.textDecoration),
368
370
  lineHeight: `${lineHeight}px`,
369
371
  boxSizing: 'content-box',
370
372
  })}
@@ -1,9 +1,9 @@
1
1
  import { ElementRendererExtension, } from '../../affine-block-surface/index.js';
2
2
  import { DefaultTheme } from '../../affine-model/index.js';
3
3
  import { deltaInsertsToChunks } from '../../std/inline/index.js';
4
- import { getFontString, getLineHeight, getTextWidth, isRTL, wrapTextDeltas, } from './utils.js';
4
+ import { alphabeticBaselineOffset, getFontString, getLineHeight, getTextWidth, isRTL, paintTextDecoration, wrapTextDeltas, } from './utils.js';
5
5
  export const text = (model, ctx, matrix, renderer) => {
6
- const { fontSize, fontWeight, fontStyle, fontFamily, textAlign, rotate } = model;
6
+ const { fontSize, fontWeight, fontStyle, fontFamily, textAlign, textDecoration, rotate, } = model;
7
7
  const [, , w, h] = model.deserializedXYWH;
8
8
  const cx = w / 2;
9
9
  const cy = h / 2;
@@ -38,7 +38,24 @@ export const text = (model, ctx, matrix, renderer) => {
38
38
  ctx.canvas.setAttribute('dir', rtl ? 'rtl' : 'ltr');
39
39
  // 0.5 comes from v-line padding
40
40
  const offset = textAlign === 'center' ? 0 : textAlign === 'right' ? -0.5 : 0.5;
41
- ctx.fillText(str, horizontalOffset + beforeTextWidth + offset, (lineIndex + 1) * lineHeightPx);
41
+ const x = horizontalOffset + beforeTextWidth + offset;
42
+ const y = (lineIndex + 1) * lineHeightPx;
43
+ ctx.fillText(str, x, y);
44
+ if (textDecoration) {
45
+ paintTextDecoration(ctx, {
46
+ decoration: textDecoration,
47
+ lineText: str,
48
+ font,
49
+ x,
50
+ // Painted on the ideographic baseline (the bottom of the font box);
51
+ // the line hangs off the alphabetic one, a descent above it.
52
+ baselineY: y + alphabeticBaselineOffset(font, 'ideographic'),
53
+ fontFamily,
54
+ fontSize,
55
+ fontWeight,
56
+ color,
57
+ });
58
+ }
42
59
  beforeTextWidth += getTextWidth(str, font);
43
60
  if (shouldTemporarilyAttach) {
44
61
  ctx.canvas.remove();
@@ -1,4 +1,4 @@
1
- import type { FontFamily, FontStyle, FontWeight, TextElementModel } from '../../affine-model/index.js';
1
+ import { type FontFamily, type FontStyle, type FontWeight, TextDecoration, type TextElementModel } from '../../affine-model/index.js';
2
2
  import type { Bound } from '../../global/gfx/index.js';
3
3
  import type * as Y from 'yjs';
4
4
  export type TextDelta = {
@@ -21,6 +21,71 @@ export declare function isRTL(text: string): boolean;
21
21
  export declare function splitIntoLines(text: string): string[];
22
22
  export declare function getLineWidth(text: string, font: string): number;
23
23
  export declare function getTextWidth(text: string, font: string): number;
24
+ /**
25
+ * How far BELOW a `textBaseline` line the alphabetic baseline sits, measured
26
+ * rather than derived: Chromium puts `middle` at half the x-height, not half
27
+ * the font box, so no ratio of the font metrics gets it right. Negative when
28
+ * the alphabetic baseline is above the line (`ideographic`, the font box's
29
+ * bottom).
30
+ */
31
+ export declare function alphabeticBaselineOffset(font: string, baseline: CanvasTextBaseline): number;
32
+ /** The decoration tokens this build paints; any other token is skipped. */
33
+ type KnownTextDecorationToken = 'underline' | 'overline';
34
+ /**
35
+ * The tokens of a stored `textDecoration` this build knows (ADR 0030).
36
+ *
37
+ * Token by token on purpose: the stored value is an append-only CSS token
38
+ * list, so a token a newer client adds is dropped here one at a time and
39
+ * `'underline line-through'` still reads as underlined. Never a `switch` on the
40
+ * whole string, which would lose the underline with the unknown token.
41
+ */
42
+ export declare function parseTextDecoration(value: string | undefined): {
43
+ underline: boolean;
44
+ overline: boolean;
45
+ };
46
+ /**
47
+ * The CSS `text-decoration-line` the DOM twins of a canvas text use — the
48
+ * known tokens only, so an unknown one cannot invalidate the declaration.
49
+ */
50
+ export declare function textDecorationLine(value: string | undefined): string;
51
+ /**
52
+ * The stored value after one toggle: `token` turned on or off, every other
53
+ * token kept — an unknown one included, so a toggle in this build never erases
54
+ * what a newer client wrote. Nothing left writes `None`, never `undefined`
55
+ * (ADR 0030 §2).
56
+ */
57
+ export declare function toggleTextDecoration(value: string | undefined, token: KnownTextDecorationToken, on: boolean): TextDecoration;
58
+ /**
59
+ * Strokes the underline and the overline of ONE painted run of a canvas text
60
+ * (ADR 0030 §3) — shared by the text, shape and connector-label renderers, and
61
+ * replayed as is by the SVG export, which runs those renderers on svgcanvas.
62
+ *
63
+ * - Width is the run's measured advance, never the element's box, with the
64
+ * same measurement the wrap uses, offset by the `ctx.textAlign` the run was
65
+ * painted with.
66
+ * - Offsets are ratios of the size the renderer paints with: canvas
67
+ * `TextMetrics` exposes no underline position.
68
+ * - `fillRect`, not `stroke`: a rectangle ignores whatever `lineDash`,
69
+ * `lineCap` or `lineWidth` a shape left on the context, and svgcanvas writes
70
+ * it as one `<rect>`.
71
+ *
72
+ * Paints nothing at all — not even a `fillStyle` write — when the value holds
73
+ * no known token, so an undecorated text draws exactly the calls it drew
74
+ * before the field existed.
75
+ */
76
+ export declare function paintTextDecoration(ctx: CanvasRenderingContext2D, { decoration, lineText, font, x, baselineY, fontFamily, fontSize, fontWeight, color, }: {
77
+ decoration: string | undefined;
78
+ lineText: string;
79
+ font: string;
80
+ /** The x passed to `fillText`, read with the context's `textAlign`. */
81
+ x: number;
82
+ /** The ALPHABETIC baseline of the run, whatever `textBaseline` painted it. */
83
+ baselineY: number;
84
+ fontFamily: string;
85
+ fontSize: number;
86
+ fontWeight: string;
87
+ color: string;
88
+ }): void;
24
89
  export declare function wrapTextDeltas(text: Y.Text, font: string, w: number): TextDelta[];
25
90
  export declare const truncateTextByWidth: (text: string, font: string, width: number) => string;
26
91
  export declare function getTextCursorPosition(model: TextElementModel, coord: {
@@ -50,3 +115,4 @@ export declare const charWidth: {
50
115
  getCache: (font: string) => number[] | undefined;
51
116
  };
52
117
  export declare function wrapText(text: string, font: string, maxWidth: number): string;
118
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { TextUtils } from '../../affine-block-surface/index.js';
2
+ import { TextDecoration, } from '../../affine-model/index.js';
2
3
  import { getPointsFromBoundWithRotation, rotatePoints, } from '../../global/gfx/index.js';
3
4
  import { deltaInsertsToChunks } from '../../std/inline/index.js';
4
5
  const { getFontFacesByFontFamily, wrapFontFamily } = TextUtils;
@@ -107,6 +108,106 @@ export function getTextWidth(text, font) {
107
108
  });
108
109
  return width;
109
110
  }
111
+ /**
112
+ * How far BELOW a `textBaseline` line the alphabetic baseline sits, measured
113
+ * rather than derived: Chromium puts `middle` at half the x-height, not half
114
+ * the font box, so no ratio of the font metrics gets it right. Negative when
115
+ * the alphabetic baseline is above the line (`ideographic`, the font box's
116
+ * bottom).
117
+ */
118
+ export function alphabeticBaselineOffset(font, baseline) {
119
+ const ctx = getMeasureCtx();
120
+ if (font !== ctx.font)
121
+ ctx.font = font;
122
+ const previous = ctx.textBaseline;
123
+ ctx.textBaseline = baseline;
124
+ const { alphabeticBaseline } = ctx.measureText('x');
125
+ ctx.textBaseline = previous;
126
+ return -(alphabeticBaseline ?? 0) || 0;
127
+ }
128
+ /**
129
+ * The tokens of a stored `textDecoration` this build knows (ADR 0030).
130
+ *
131
+ * Token by token on purpose: the stored value is an append-only CSS token
132
+ * list, so a token a newer client adds is dropped here one at a time and
133
+ * `'underline line-through'` still reads as underlined. Never a `switch` on the
134
+ * whole string, which would lose the underline with the unknown token.
135
+ */
136
+ export function parseTextDecoration(value) {
137
+ const tokens = value ? value.split(/\s+/) : [];
138
+ return {
139
+ underline: tokens.includes('underline'),
140
+ overline: tokens.includes('overline'),
141
+ };
142
+ }
143
+ /**
144
+ * The CSS `text-decoration-line` the DOM twins of a canvas text use — the
145
+ * known tokens only, so an unknown one cannot invalidate the declaration.
146
+ */
147
+ export function textDecorationLine(value) {
148
+ const { underline, overline } = parseTextDecoration(value);
149
+ const line = [underline && 'underline', overline && 'overline']
150
+ .filter(Boolean)
151
+ .join(' ');
152
+ return line || 'none';
153
+ }
154
+ /**
155
+ * The stored value after one toggle: `token` turned on or off, every other
156
+ * token kept — an unknown one included, so a toggle in this build never erases
157
+ * what a newer client wrote. Nothing left writes `None`, never `undefined`
158
+ * (ADR 0030 §2).
159
+ */
160
+ export function toggleTextDecoration(value, token, on) {
161
+ const tokens = new Set((value ?? '')
162
+ .split(/\s+/)
163
+ .filter(t => t && t !== TextDecoration.None && t !== token));
164
+ if (on)
165
+ tokens.add(token);
166
+ const known = ['underline', 'overline'].filter(t => tokens.has(t));
167
+ const unknown = [...tokens].filter(t => t !== 'underline' && t !== 'overline');
168
+ const next = [...known, ...unknown].join(' ');
169
+ return (next || TextDecoration.None);
170
+ }
171
+ /**
172
+ * Strokes the underline and the overline of ONE painted run of a canvas text
173
+ * (ADR 0030 §3) — shared by the text, shape and connector-label renderers, and
174
+ * replayed as is by the SVG export, which runs those renderers on svgcanvas.
175
+ *
176
+ * - Width is the run's measured advance, never the element's box, with the
177
+ * same measurement the wrap uses, offset by the `ctx.textAlign` the run was
178
+ * painted with.
179
+ * - Offsets are ratios of the size the renderer paints with: canvas
180
+ * `TextMetrics` exposes no underline position.
181
+ * - `fillRect`, not `stroke`: a rectangle ignores whatever `lineDash`,
182
+ * `lineCap` or `lineWidth` a shape left on the context, and svgcanvas writes
183
+ * it as one `<rect>`.
184
+ *
185
+ * Paints nothing at all — not even a `fillStyle` write — when the value holds
186
+ * no known token, so an undecorated text draws exactly the calls it drew
187
+ * before the field existed.
188
+ */
189
+ export function paintTextDecoration(ctx, { decoration, lineText, font, x, baselineY, fontFamily, fontSize, fontWeight, color, }) {
190
+ const { underline, overline } = parseTextDecoration(decoration);
191
+ if (!underline && !overline)
192
+ return;
193
+ const width = getLineWidth(lineText, font);
194
+ if (!(width > 0))
195
+ return;
196
+ const left = ctx.textAlign === 'center'
197
+ ? x - width / 2
198
+ : ctx.textAlign === 'right'
199
+ ? x - width
200
+ : x;
201
+ const thickness = Math.max(1, fontSize / 16);
202
+ ctx.fillStyle = color;
203
+ if (underline) {
204
+ ctx.fillRect(left, baselineY + Math.max(1, fontSize * 0.08), width, thickness);
205
+ }
206
+ if (overline) {
207
+ const { fontBoundingBoxAscent } = getFontMetrics(fontFamily, fontSize, fontWeight);
208
+ ctx.fillRect(left, baselineY - fontBoundingBoxAscent, width, thickness);
209
+ }
210
+ }
110
211
  export function wrapTextDeltas(text, font, w) {
111
212
  if (!text)
112
213
  return [];
@@ -15,6 +15,17 @@ export declare function createTextActions<K extends abstract new (...args: any)
15
15
  }, {
16
16
  readonly id: "c.font-style";
17
17
  readonly content: (ctx: ToolbarContext) => import("lit-html").TemplateResult<1> | null;
18
+ }, {
19
+ readonly id: "c.text-decoration";
20
+ readonly when: boolean;
21
+ readonly actions: {
22
+ id: "a.underline" | "b.overline";
23
+ icon: import("lit-html").TemplateResult<1>;
24
+ tooltipWording: import("../../affine-shared/services/index.js").ChromeWording;
25
+ when: (ctx: ToolbarContext) => boolean;
26
+ active: (ctx: ToolbarContext) => boolean;
27
+ run: (ctx: ToolbarContext) => void;
28
+ }[];
18
29
  }, {
19
30
  readonly id: "d.font-size";
20
31
  readonly when: boolean;
@@ -1,16 +1,17 @@
1
1
  import { EdgelessCRUDIdentifier, TextUtils } from '../../affine-block-surface/index.js';
2
2
  import { frameworkPaletteGroups, packColor, } from '../../affine-components/color-picker/index.js';
3
+ import { OverlineIcon, UnderlineIcon } from '../../affine-components/icons/index.js';
3
4
  import { EditorChevronDown } from '../../affine-components/toolbar/index.js';
4
5
  import { DefaultTheme, FontFamily, FontStyle, FontWeight, resolveColor, TextAlign, } from '../../affine-model/index.js';
5
- import { translateKey, } from '../../affine-shared/services/index.js';
6
+ import { TEXT_FORMAT_OVERLINE, TEXT_FORMAT_UNDERLINE, translateKey, } from '../../affine-shared/services/index.js';
6
7
  import { getMostCommonResolvedValue, getMostCommonValue, } from '../../affine-shared/utils/index.js';
7
8
  import { renderMenu, resolveMenuItemLabel, } from '../../affine-widget-edgeless-toolbar/index.js';
8
9
  import { TextAlignCenterIcon, TextAlignLeftIcon, TextAlignRightIcon, } from '@blocksuite/icons/lit';
9
10
  import { signal } from '@preact/signals-core';
10
11
  import { html } from 'lit';
11
12
  import { styleMap } from 'lit/directives/style-map.js';
12
- import { isFontStyleSupported, isFontWeightSupported, } from '../element-renderer/utils.js';
13
- import { TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_TOOLBAR_ALIGNMENT, TEXT_TOOLBAR_FONT, TEXT_TOOLBAR_FONT_STYLE, TEXT_TOOLBAR_FONT_STYLE_ITALIC, TEXT_TOOLBAR_FONT_WEIGHT_BOLD, TEXT_TOOLBAR_FONT_WEIGHT_LIGHT, TEXT_TOOLBAR_FONT_WEIGHT_REGULAR, TEXT_TOOLBAR_FONT_WEIGHT_SEMIBOLD, TEXT_TOOLBAR_FONT_SIZE, TEXT_TOOLBAR_TEXT_COLOR, } from '../translations.js';
13
+ import { isFontStyleSupported, isFontWeightSupported, parseTextDecoration, toggleTextDecoration, } from '../element-renderer/utils.js';
14
+ import { TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_TOOLBAR_ALIGNMENT, TEXT_TOOLBAR_ALIGNMENT_MENU_ARIA, TEXT_TOOLBAR_FONT, TEXT_TOOLBAR_FONT_STYLE, TEXT_TOOLBAR_FONT_STYLE_ITALIC, TEXT_TOOLBAR_FONT_WEIGHT_BOLD, TEXT_TOOLBAR_FONT_WEIGHT_LIGHT, TEXT_TOOLBAR_FONT_WEIGHT_REGULAR, TEXT_TOOLBAR_FONT_WEIGHT_SEMIBOLD, TEXT_TOOLBAR_FONT_SIZE, TEXT_TOOLBAR_TEXT_COLOR, } from '../translations.js';
14
15
  const FONT_WEIGHT_LIST = [
15
16
  {
16
17
  key: 'Light',
@@ -71,6 +72,24 @@ const TEXT_ALIGN_LIST = [
71
72
  icon: TextAlignRightIcon(),
72
73
  },
73
74
  ];
75
+ /**
76
+ * The decoration toggles, in the order they sit on the row (the toolbar orders
77
+ * a group's children by id).
78
+ */
79
+ const TEXT_DECORATION_TOGGLES = [
80
+ {
81
+ id: 'a.underline',
82
+ token: 'underline',
83
+ icon: UnderlineIcon,
84
+ wording: TEXT_FORMAT_UNDERLINE,
85
+ },
86
+ {
87
+ id: 'b.overline',
88
+ token: 'overline',
89
+ icon: OverlineIcon,
90
+ wording: TEXT_FORMAT_OVERLINE,
91
+ },
92
+ ];
74
93
  export function createTextActions(klass, type, update = (ctx, model, props) => ctx.std.get(EdgelessCRUDIdentifier).updateElement(model.id, props), mapInto = model => model, stash = (model, type, field) => model[type](field)) {
75
94
  return [
76
95
  {
@@ -119,6 +138,7 @@ export function createTextActions(klass, type, update = (ctx, model, props) => c
119
138
  <edgeless-font-family-panel
120
139
  .value=${fontFamily}
121
140
  .onSelect=${onPick}
141
+ .std=${ctx.std}
122
142
  ></edgeless-font-family-panel>
123
143
  </editor-menu-button>
124
144
  `;
@@ -249,6 +269,38 @@ export function createTextActions(klass, type, update = (ctx, model, props) => c
249
269
  `;
250
270
  },
251
271
  },
272
+ {
273
+ // Two element-level toggles, drawn like the format bar's underline:
274
+ // the decoration applies to the whole text, never to one run (ADR 0030
275
+ // §1, §6). `affine:edgeless-text` decorates its paragraphs per run
276
+ // through the inline schema instead, so it has no such field.
277
+ id: 'c.text-decoration',
278
+ when: type !== 'edgeless-text',
279
+ actions: TEXT_DECORATION_TOGGLES.map(({ id, token, icon, wording }) => ({
280
+ id,
281
+ icon,
282
+ tooltipWording: wording,
283
+ when: (ctx) => {
284
+ const models = ctx.getSurfaceModelsByType(klass);
285
+ return (models.length > 0 &&
286
+ models.every(model => isSurfaceTextModel(model, klass, type)));
287
+ },
288
+ active: (ctx) => ctx
289
+ .getSurfaceModelsByType(klass)
290
+ .every(model => parseTextDecoration(mapInto(model).textDecoration)[token]),
291
+ run: (ctx) => {
292
+ const models = ctx.getSurfaceModelsByType(klass);
293
+ const on = !models.every(model => parseTextDecoration(mapInto(model).textDecoration)[token]);
294
+ // One click, one undo step, whatever the selection holds.
295
+ ctx.store.captureSync();
296
+ for (const model of models) {
297
+ update(ctx, model, {
298
+ textDecoration: toggleTextDecoration(mapInto(model).textDecoration, token, on),
299
+ });
300
+ }
301
+ },
302
+ })),
303
+ },
252
304
  {
253
305
  id: 'd.font-size',
254
306
  when: type !== 'edgeless-text',
@@ -295,6 +347,7 @@ export function createTextActions(klass, type, update = (ctx, model, props) => c
295
347
  return renderMenu({
296
348
  label: 'Alignment',
297
349
  labelWording: TEXT_TOOLBAR_ALIGNMENT,
350
+ menuAriaWording: TEXT_TOOLBAR_ALIGNMENT_MENU_ARIA,
298
351
  items: TEXT_ALIGN_LIST,
299
352
  currentValue: textAlign,
300
353
  onPick,
@@ -8,6 +8,17 @@ export declare const textToolbarConfig: {
8
8
  }, {
9
9
  readonly id: "c.font-style";
10
10
  readonly content: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => import("lit-html").TemplateResult<1> | null;
11
+ }, {
12
+ readonly id: "c.text-decoration";
13
+ readonly when: boolean;
14
+ readonly actions: {
15
+ id: "a.underline" | "b.overline";
16
+ icon: import("lit-html").TemplateResult<1>;
17
+ tooltipWording: import("../../affine-shared/services/index.js").ChromeWording;
18
+ when: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => boolean;
19
+ active: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => boolean;
20
+ run: (ctx: import("../../affine-shared/services/index.js").ToolbarContext) => void;
21
+ }[];
11
22
  }, {
12
23
  readonly id: "d.font-size";
13
24
  readonly when: boolean;
@@ -8,7 +8,7 @@ import { createTextActions } from './actions.js';
8
8
  export const textToolbarConfig = {
9
9
  actions: createTextActions(TextElementModel, 'text', (ctx, model, props) => {
10
10
  // No need to adjust element bounds
11
- if (props['textAlign']) {
11
+ if (props['textAlign'] || props['textDecoration']) {
12
12
  ctx.std.get(EdgelessCRUDIdentifier).updateElement(model.id, props);
13
13
  return;
14
14
  }
@@ -17,6 +17,14 @@ export declare const TEXT_TOOLBAR_FONT: ChromeWording;
17
17
  export declare const TEXT_TOOLBAR_TEXT_COLOR: ChromeWording;
18
18
  export declare const TEXT_TOOLBAR_FONT_STYLE: ChromeWording;
19
19
  export declare const TEXT_TOOLBAR_ALIGNMENT: ChromeWording;
20
+ /**
21
+ * The accessible name of the alignment menu SHELL (#390) — its own wording,
22
+ * not `` `${TEXT_TOOLBAR_ALIGNMENT}-menu` ``, which read "alignement-menu" in
23
+ * French. Distinct from `ROOT_ALIGNMENT_MENU_ARIA`: that one names the
24
+ * edgeless menu that aligns ELEMENTS on the board, this one the menu that
25
+ * aligns TEXT inside an element. Two menus, two names.
26
+ */
27
+ export declare const TEXT_TOOLBAR_ALIGNMENT_MENU_ARIA: ChromeWording;
20
28
  /**
21
29
  * The three alignment values — a different concept from a mindmap's own
22
30
  * "Left" / "Right" layout direction (`gfx/mindmap`'s
@@ -29,6 +29,17 @@ export const TEXT_TOOLBAR_ALIGNMENT = [
29
29
  'com.labre.text-toolbar.alignment',
30
30
  'Alignment',
31
31
  ];
32
+ /**
33
+ * The accessible name of the alignment menu SHELL (#390) — its own wording,
34
+ * not `` `${TEXT_TOOLBAR_ALIGNMENT}-menu` ``, which read "alignement-menu" in
35
+ * French. Distinct from `ROOT_ALIGNMENT_MENU_ARIA`: that one names the
36
+ * edgeless menu that aligns ELEMENTS on the board, this one the menu that
37
+ * aligns TEXT inside an element. Two menus, two names.
38
+ */
39
+ export const TEXT_TOOLBAR_ALIGNMENT_MENU_ARIA = [
40
+ 'com.labre.text-toolbar.alignment-menu',
41
+ 'text alignment-menu',
42
+ ];
32
43
  /**
33
44
  * The three alignment values — a different concept from a mindmap's own
34
45
  * "Left" / "Right" layout direction (`gfx/mindmap`'s
@@ -58,6 +69,7 @@ export const TEXT_WORDINGS = [
58
69
  TEXT_TOOLBAR_TEXT_COLOR,
59
70
  TEXT_TOOLBAR_FONT_STYLE,
60
71
  TEXT_TOOLBAR_ALIGNMENT,
72
+ TEXT_TOOLBAR_ALIGNMENT_MENU_ARIA,
61
73
  TEXT_ALIGN_LEFT,
62
74
  TEXT_ALIGN_CENTER,
63
75
  TEXT_ALIGN_RIGHT,
@@ -101,7 +101,8 @@ let LatexEditorMenu = (() => {
101
101
  background: ${unsafeCSSVar('white10')};
102
102
 
103
103
  /* light/activeShadow */
104
- box-shadow: 0px 0px 0px 2px rgba(30, 150, 235, 0.3);
104
+ box-shadow: 0px 0px 0px 2px
105
+ color-mix(in srgb, var(--affine-primary-color) 30%, transparent);
105
106
 
106
107
  font-family: ${unsafeCSSVar('fontCodeFamily')};
107
108
  border: 1px solid transparent;
@@ -25,6 +25,9 @@ export declare const htmlDelElementToDeltaMatcher: import("../../../store/index.
25
25
  export declare const htmlUnderlineElementToDeltaMatcher: import("../../../store/index.js").ExtensionType & {
26
26
  identifier: import("../../../global/di/types.js").ServiceIdentifier<import("../../../affine-shared/adapters/index.js").HtmlASTToDeltaMatcher>;
27
27
  };
28
+ export declare const htmlOverlineElementToDeltaMatcher: import("../../../store/index.js").ExtensionType & {
29
+ identifier: import("../../../global/di/types.js").ServiceIdentifier<import("../../../affine-shared/adapters/index.js").HtmlASTToDeltaMatcher>;
30
+ };
28
31
  export declare const htmlMarkElementToDeltaMatcher: import("../../../store/index.js").ExtensionType & {
29
32
  identifier: import("../../../global/di/types.js").ServiceIdentifier<import("../../../affine-shared/adapters/index.js").HtmlASTToDeltaMatcher>;
30
33
  };
@@ -90,6 +90,22 @@ const isUnderlineElement = (ast) => {
90
90
  const isUnderlineStyle = /text-decoration:\s*underline/.test(style);
91
91
  return isUnderlineTag || isUnderlineStyle;
92
92
  };
93
+ /**
94
+ * Check if the element is an overline element through its style — HTML has
95
+ * no overline tag, so `text-decoration: overline;` is the only spelling, and
96
+ * the one the HTML export writes (ADR 0030 §5).
97
+ * @example
98
+ * ```html
99
+ * <span style="text-decoration: overline;">Hello</span>
100
+ * ```
101
+ */
102
+ const isOverlineElement = (ast) => {
103
+ if (!isElement(ast)) {
104
+ return false;
105
+ }
106
+ const style = typeof ast.properties.style === 'string' ? ast.properties.style : '';
107
+ return /text-decoration:\s*overline/.test(style);
108
+ };
93
109
  /**
94
110
  * Check if the element is a line-through element through style or tag
95
111
  * If the element tag is <del> or the style is `text-decoration: line-through;`,
@@ -124,6 +140,7 @@ const isTextLikeElement = (ast) => {
124
140
  !isStrongElement(ast) &&
125
141
  !isItalicElement(ast) &&
126
142
  !isUnderlineElement(ast) &&
143
+ !isOverlineElement(ast) &&
127
144
  !isLineThroughElement(ast));
128
145
  };
129
146
  export const htmlTextToDeltaMatcher = HtmlASTToDeltaExtension({
@@ -256,6 +273,19 @@ export const htmlUnderlineElementToDeltaMatcher = HtmlASTToDeltaExtension({
256
273
  }));
257
274
  },
258
275
  });
276
+ export const htmlOverlineElementToDeltaMatcher = HtmlASTToDeltaExtension({
277
+ name: 'overline-element',
278
+ match: ast => isOverlineElement(ast),
279
+ toDelta: (ast, context) => {
280
+ if (!isElement(ast)) {
281
+ return [];
282
+ }
283
+ return ast.children.flatMap(child => context.toDelta(child, { trim: false }).map(delta => {
284
+ delta.attributes = { ...delta.attributes, overline: true };
285
+ return delta;
286
+ }));
287
+ },
288
+ });
259
289
  export const htmlMarkElementToDeltaMatcher = HtmlASTToDeltaExtension({
260
290
  name: 'mark-element',
261
291
  match: ast => isElement(ast) && ast.tagName === 'mark',
@@ -285,6 +315,7 @@ export const HtmlInlineToDeltaAdapterExtensions = [
285
315
  htmlCodeElementToDeltaMatcher,
286
316
  htmlDelElementToDeltaMatcher,
287
317
  htmlUnderlineElementToDeltaMatcher,
318
+ htmlOverlineElementToDeltaMatcher,
288
319
  htmlMarkElementToDeltaMatcher,
289
320
  htmlBrElementToDeltaMatcher,
290
321
  ];