@formicoidea/labre-core 0.43.1 → 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 (263) 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-edgeless-text/edgeless-toolbar/config.d.ts +11 -0
  17. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.d.ts +20 -0
  18. package/dist/_pkgs/affine-block-edgeless-text/svg-painter.js +76 -0
  19. package/dist/_pkgs/affine-block-edgeless-text/view.js +2 -0
  20. package/dist/_pkgs/affine-block-embed/configs/toolbar.js +11 -2
  21. package/dist/_pkgs/affine-block-embed/embed-iframe-block/configs/toolbar.js +11 -2
  22. package/dist/_pkgs/affine-block-embed-doc/embed-linked-doc-block/embed-edgeless-linked-doc-block.js +3 -1
  23. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/configs/toolbar.js +7 -2
  24. package/dist/_pkgs/affine-block-embed-doc/embed-synced-doc-block/embed-edgeless-synced-doc-block.js +3 -1
  25. package/dist/_pkgs/affine-block-frame/frame-manager.d.ts +5 -0
  26. package/dist/_pkgs/affine-block-frame/frame-manager.js +48 -17
  27. package/dist/_pkgs/affine-block-frame/frame-tool.js +3 -1
  28. package/dist/_pkgs/affine-block-image/utils.js +4 -1
  29. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.d.ts +8 -0
  30. package/dist/_pkgs/affine-block-latex/adapters/markdown/preprocessor.js +9 -5
  31. package/dist/_pkgs/affine-block-note/translations.d.ts +0 -1
  32. package/dist/_pkgs/affine-block-note/translations.js +0 -5
  33. package/dist/_pkgs/affine-block-root/configs/toolbar.js +17 -1
  34. package/dist/_pkgs/affine-block-root/edgeless/clipboard/clipboard.js +2 -1
  35. package/dist/_pkgs/affine-block-root/edgeless/clipboard/command.js +161 -83
  36. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.d.ts +21 -0
  37. package/dist/_pkgs/affine-block-root/edgeless/clipboard/paste-order.js +85 -0
  38. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.d.ts +6 -0
  39. package/dist/_pkgs/affine-block-root/edgeless/edgeless-root-block.js +18 -1
  40. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.d.ts +9 -0
  41. package/dist/_pkgs/affine-block-root/edgeless/utils/clone-utils.js +28 -0
  42. package/dist/_pkgs/affine-block-root/keyboard/commands.js +9 -6
  43. package/dist/_pkgs/affine-block-root/preview/edgeless-root-preview-block.js +15 -2
  44. package/dist/_pkgs/affine-block-surface/adapters/markdown/element-adapter/type.d.ts +1 -1
  45. package/dist/_pkgs/affine-block-surface/element-model/index.d.ts +1 -1
  46. package/dist/_pkgs/affine-block-surface/element-model/index.js +1 -1
  47. package/dist/_pkgs/affine-block-surface/extensions/audit.js +13 -61
  48. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.d.ts +2 -0
  49. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/commands.js +71 -0
  50. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.d.ts +1 -0
  51. package/dist/_pkgs/affine-block-surface/extensions/canvas-grid/index.js +1 -0
  52. package/dist/_pkgs/affine-block-surface/extensions/clipboard-config.js +4 -0
  53. package/dist/_pkgs/affine-block-surface/extensions/crud-extension.js +4 -0
  54. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.d.ts +12 -0
  55. package/dist/_pkgs/affine-block-surface/extensions/export-manager/export-manager.js +27 -7
  56. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.d.ts +2 -1
  57. package/dist/_pkgs/affine-block-surface/extensions/export-svg/command.js +22 -3
  58. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.d.ts +6 -3
  59. package/dist/_pkgs/affine-block-surface/extensions/export-svg/index.js +4 -2
  60. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.d.ts +63 -0
  61. package/dist/_pkgs/affine-block-surface/extensions/export-svg/parts.js +67 -0
  62. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.d.ts +62 -5
  63. package/dist/_pkgs/affine-block-surface/extensions/export-svg/render.js +98 -18
  64. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.d.ts +14 -0
  65. package/dist/_pkgs/affine-block-surface/extensions/export-svg/svg-context.js +82 -1
  66. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.d.ts +2 -2
  67. package/dist/_pkgs/affine-block-surface/extensions/export-svg/toolbar.js +112 -10
  68. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.d.ts +13 -0
  69. package/dist/_pkgs/affine-block-surface/extensions/export-svg/translations.js +33 -0
  70. package/dist/_pkgs/affine-block-surface/extensions/index.d.ts +3 -0
  71. package/dist/_pkgs/affine-block-surface/extensions/index.js +3 -0
  72. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.d.ts +13 -6
  73. package/dist/_pkgs/affine-block-surface/extensions/reading-widget.js +26 -10
  74. package/dist/_pkgs/affine-block-surface/extensions/reading.d.ts +82 -6
  75. package/dist/_pkgs/affine-block-surface/extensions/reading.js +99 -21
  76. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.d.ts +80 -0
  77. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/actions.js +248 -0
  78. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.d.ts +82 -0
  79. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/commands.js +342 -0
  80. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.d.ts +3 -0
  81. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/index.js +3 -0
  82. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.d.ts +137 -0
  83. package/dist/_pkgs/affine-block-surface/extensions/selection-pane/tree.js +323 -0
  84. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.d.ts +112 -4
  85. package/dist/_pkgs/affine-block-surface/extensions/svg-sketch.js +86 -15
  86. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.d.ts +76 -0
  87. package/dist/_pkgs/affine-block-surface/extensions/user-layers/actions.js +299 -0
  88. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.d.ts +20 -0
  89. package/dist/_pkgs/affine-block-surface/extensions/user-layers/active-layer.js +34 -0
  90. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.d.ts +67 -0
  91. package/dist/_pkgs/affine-block-surface/extensions/user-layers/commands.js +172 -0
  92. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.d.ts +40 -0
  93. package/dist/_pkgs/affine-block-surface/extensions/user-layers/creation.js +69 -0
  94. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.d.ts +5 -0
  95. package/dist/_pkgs/affine-block-surface/extensions/user-layers/index.js +5 -0
  96. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.d.ts +10 -0
  97. package/dist/_pkgs/affine-block-surface/extensions/user-layers/translations.js +14 -0
  98. package/dist/_pkgs/affine-block-surface/framework-background/facts.d.ts +55 -2
  99. package/dist/_pkgs/affine-block-surface/framework-background/facts.js +63 -1
  100. package/dist/_pkgs/affine-block-surface/framework-background/stacking.d.ts +16 -8
  101. package/dist/_pkgs/affine-block-surface/framework-background/stacking.js +26 -14
  102. package/dist/_pkgs/affine-block-surface/renderer/canvas-renderer.js +17 -3
  103. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.d.ts +3 -1
  104. package/dist/_pkgs/affine-block-surface/renderer/dom-renderer.js +22 -2
  105. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.d.ts +30 -0
  106. package/dist/_pkgs/affine-block-surface/renderer/paint-predicate.js +29 -0
  107. package/dist/_pkgs/affine-block-surface/surface-block.js +6 -0
  108. package/dist/_pkgs/affine-block-surface/surface-model.js +5 -0
  109. package/dist/_pkgs/affine-block-surface/surface-transformer.js +5 -0
  110. package/dist/_pkgs/affine-block-surface/tool/default-tool.js +28 -5
  111. package/dist/_pkgs/affine-block-surface/view.js +23 -1
  112. package/dist/_pkgs/affine-block-surface-ref/surface-ref-block.js +12 -2
  113. package/dist/_pkgs/affine-components/context-menu/button.js +14 -0
  114. package/dist/_pkgs/affine-components/filterable-list/index.js +30 -9
  115. package/dist/_pkgs/affine-components/icons/index.d.ts +0 -1
  116. package/dist/_pkgs/affine-components/icons/index.js +0 -1
  117. package/dist/_pkgs/affine-components/icons/text.d.ts +1 -0
  118. package/dist/_pkgs/affine-components/icons/text.js +11 -0
  119. package/dist/_pkgs/affine-fragment-adapter-panel/adapter-panel.d.ts +2 -2
  120. package/dist/_pkgs/affine-fragment-frame-panel/card/frame-card.js +2 -2
  121. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.d.ts +1 -1
  122. package/dist/_pkgs/affine-fragment-frame-panel/header/frame-panel-header.js +8 -27
  123. package/dist/_pkgs/affine-fragment-frame-panel/index.d.ts +1 -0
  124. package/dist/_pkgs/affine-fragment-frame-panel/index.js +1 -0
  125. package/dist/_pkgs/affine-gfx-connector/element-renderer/connector-dom/index.js +3 -1
  126. package/dist/_pkgs/affine-gfx-connector/element-renderer/index.js +21 -4
  127. package/dist/_pkgs/affine-gfx-connector/text/edgeless-connector-label-editor.js +3 -2
  128. package/dist/_pkgs/affine-gfx-connector/toolbar/config.js +1 -1
  129. package/dist/_pkgs/affine-gfx-group/command/group-api.js +52 -1
  130. package/dist/_pkgs/affine-gfx-shape/element-renderer/shape/index.js +21 -3
  131. package/dist/_pkgs/affine-gfx-shape/text/edgeless-shape-text-editor.js +2 -0
  132. package/dist/_pkgs/affine-gfx-shape/toolbar/config.js +1 -1
  133. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.d.ts +9 -0
  134. package/dist/_pkgs/affine-gfx-template/services/template-middlewares.js +23 -1
  135. package/dist/_pkgs/affine-gfx-template/services/template.js +2 -1
  136. package/dist/_pkgs/affine-gfx-text/edgeless-text-editor.js +2 -1
  137. package/dist/_pkgs/affine-gfx-text/element-renderer/index.js +20 -3
  138. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.d.ts +67 -1
  139. package/dist/_pkgs/affine-gfx-text/element-renderer/utils.js +101 -0
  140. package/dist/_pkgs/affine-gfx-text/toolbar/actions.d.ts +11 -0
  141. package/dist/_pkgs/affine-gfx-text/toolbar/actions.js +53 -2
  142. package/dist/_pkgs/affine-gfx-text/toolbar/config.d.ts +11 -0
  143. package/dist/_pkgs/affine-gfx-text/toolbar/config.js +1 -1
  144. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.d.ts +3 -0
  145. package/dist/_pkgs/affine-inline-preset/adapters/html/html-inline.js +31 -0
  146. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.d.ts +4 -0
  147. package/dist/_pkgs/affine-inline-preset/adapters/html/inline-delta.js +14 -0
  148. package/dist/_pkgs/affine-inline-preset/command/config.js +21 -3
  149. package/dist/_pkgs/affine-inline-preset/command/index.d.ts +1 -1
  150. package/dist/_pkgs/affine-inline-preset/command/index.js +1 -1
  151. package/dist/_pkgs/affine-inline-preset/command/text-style.d.ts +2 -1
  152. package/dist/_pkgs/affine-inline-preset/command/text-style.js +1 -0
  153. package/dist/_pkgs/affine-inline-preset/default-inline-manager.js +2 -1
  154. package/dist/_pkgs/affine-inline-preset/inline-spec.d.ts +4 -0
  155. package/dist/_pkgs/affine-inline-preset/inline-spec.js +14 -0
  156. package/dist/_pkgs/affine-inline-preset/translations.d.ts +2 -2
  157. package/dist/_pkgs/affine-inline-preset/translations.js +2 -2
  158. package/dist/_pkgs/affine-model/blocks/attachment/attachment-model.js +2 -0
  159. package/dist/_pkgs/affine-model/blocks/bookmark/bookmark-model.js +2 -0
  160. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.d.ts +1 -1
  161. package/dist/_pkgs/affine-model/blocks/edgeless-text/edgeless-text-model.js +2 -0
  162. package/dist/_pkgs/affine-model/blocks/embed/iframe/iframe-model.js +2 -0
  163. package/dist/_pkgs/affine-model/blocks/frame/frame-model.js +2 -0
  164. package/dist/_pkgs/affine-model/blocks/image/image-model.js +2 -0
  165. package/dist/_pkgs/affine-model/blocks/latex/latex-model.js +2 -0
  166. package/dist/_pkgs/affine-model/blocks/note/note-model.js +2 -0
  167. package/dist/_pkgs/affine-model/consts/text.d.ts +26 -0
  168. package/dist/_pkgs/affine-model/consts/text.js +25 -0
  169. package/dist/_pkgs/affine-model/elements/shape/shape.d.ts +6 -1
  170. package/dist/_pkgs/affine-model/elements/shape/shape.js +14 -1
  171. package/dist/_pkgs/affine-model/elements/text/text.d.ts +6 -1
  172. package/dist/_pkgs/affine-model/elements/text/text.js +13 -1
  173. package/dist/_pkgs/affine-model/utils/helper.js +2 -0
  174. package/dist/_pkgs/affine-rich-text/conversion.d.ts +25 -0
  175. package/dist/_pkgs/affine-rich-text/conversion.js +9 -0
  176. package/dist/_pkgs/affine-rich-text/index.d.ts +1 -1
  177. package/dist/_pkgs/affine-rich-text/index.js +1 -1
  178. package/dist/_pkgs/affine-shared/commands/model-crud/replace-selected-text-with-blocks.d.ts +1 -1
  179. package/dist/_pkgs/affine-shared/services/canvas-grid.d.ts +63 -0
  180. package/dist/_pkgs/affine-shared/services/canvas-grid.js +109 -0
  181. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.d.ts +64 -0
  182. package/dist/_pkgs/affine-shared/services/canvas-local-visibility.js +192 -0
  183. package/dist/_pkgs/affine-shared/services/edit-props-store.d.ts +27 -0
  184. package/dist/_pkgs/affine-shared/services/edit-props-store.js +34 -0
  185. package/dist/_pkgs/affine-shared/services/editor-setting-service.d.ts +3 -0
  186. package/dist/_pkgs/affine-shared/services/editor-setting-service.js +7 -0
  187. package/dist/_pkgs/affine-shared/services/feature-flag-service.d.ts +4 -0
  188. package/dist/_pkgs/affine-shared/services/index.d.ts +3 -0
  189. package/dist/_pkgs/affine-shared/services/index.js +3 -0
  190. package/dist/_pkgs/affine-shared/services/selection-pane-service.d.ts +44 -0
  191. package/dist/_pkgs/affine-shared/services/selection-pane-service.js +28 -0
  192. package/dist/_pkgs/affine-shared/services/telemetry-service/lifecycle.d.ts +69 -0
  193. package/dist/_pkgs/affine-shared/services/telemetry-service/telemetry-service.d.ts +2 -2
  194. package/dist/_pkgs/affine-shared/services/translation-service/chrome.d.ts +5 -0
  195. package/dist/_pkgs/affine-shared/services/translation-service/chrome.js +9 -0
  196. package/dist/_pkgs/affine-shared/styles/index.d.ts +1 -0
  197. package/dist/_pkgs/affine-shared/styles/index.js +1 -0
  198. package/dist/_pkgs/affine-shared/styles/panel-header.d.ts +31 -0
  199. package/dist/_pkgs/affine-shared/styles/panel-header.js +61 -0
  200. package/dist/_pkgs/affine-shared/styles/text.js +7 -7
  201. package/dist/_pkgs/affine-shared/types/index.d.ts +6 -0
  202. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.d.ts +26 -0
  203. package/dist/_pkgs/affine-shared/utils/canvas-export-colors.js +127 -0
  204. package/dist/_pkgs/affine-shared/utils/file/filesys.d.ts +8 -11
  205. package/dist/_pkgs/affine-shared/utils/file/filesys.js +8 -11
  206. package/dist/_pkgs/affine-shared/utils/index.d.ts +2 -0
  207. package/dist/_pkgs/affine-shared/utils/index.js +2 -0
  208. package/dist/_pkgs/affine-shared/utils/label-mode.d.ts +47 -0
  209. package/dist/_pkgs/affine-shared/utils/label-mode.js +55 -0
  210. package/dist/_pkgs/affine-shared/utils/model/merge-to-code-model.js +7 -1
  211. package/dist/_pkgs/affine-shared/utils/model/transform-model.js +5 -0
  212. package/dist/_pkgs/affine-widget-edgeless-selected-rect/utils.js +10 -3
  213. package/dist/_pkgs/affine-widget-edgeless-toolbar/catalogue/artefact-catalogue-widget.js +25 -49
  214. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.d.ts +4 -0
  215. package/dist/_pkgs/affine-widget-edgeless-toolbar/effects.js +4 -0
  216. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.d.ts +4 -0
  217. package/dist/_pkgs/affine-widget-edgeless-toolbar/index.js +4 -0
  218. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.d.ts +61 -0
  219. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/drop.js +91 -0
  220. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.d.ts +17 -0
  221. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/labels.js +95 -0
  222. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.d.ts +10 -0
  223. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-default.js +31 -0
  224. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.d.ts +26 -0
  225. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-tool.js +82 -0
  226. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.d.ts +170 -0
  227. package/dist/_pkgs/affine-widget-edgeless-toolbar/selection-pane/selection-pane-widget.js +1381 -0
  228. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.d.ts +52 -0
  229. package/dist/_pkgs/affine-widget-edgeless-toolbar/translations.js +161 -1
  230. package/dist/_pkgs/affine-widget-edgeless-toolbar/view.js +10 -0
  231. package/dist/_pkgs/affine-widget-note-slicer/note-slicer.js +7 -3
  232. package/dist/_pkgs/std/gfx/controller.d.ts +13 -0
  233. package/dist/_pkgs/std/gfx/controller.js +22 -2
  234. package/dist/_pkgs/std/gfx/grid.d.ts +31 -2
  235. package/dist/_pkgs/std/gfx/index.d.ts +3 -1
  236. package/dist/_pkgs/std/gfx/index.js +3 -1
  237. package/dist/_pkgs/std/gfx/interactivity/manager.js +7 -0
  238. package/dist/_pkgs/std/gfx/layer.js +73 -5
  239. package/dist/_pkgs/std/gfx/local-visibility.d.ts +88 -0
  240. package/dist/_pkgs/std/gfx/local-visibility.js +217 -0
  241. package/dist/_pkgs/std/gfx/model/gfx-block-model.d.ts +13 -0
  242. package/dist/_pkgs/std/gfx/model/surface/element-model.d.ts +34 -0
  243. package/dist/_pkgs/std/gfx/model/surface/element-model.js +65 -1
  244. package/dist/_pkgs/std/gfx/model/surface/surface-model.d.ts +27 -0
  245. package/dist/_pkgs/std/gfx/model/surface/surface-model.js +43 -0
  246. package/dist/_pkgs/std/gfx/model/surface/user-layers.d.ts +68 -0
  247. package/dist/_pkgs/std/gfx/model/surface/user-layers.js +127 -0
  248. package/dist/_pkgs/std/utils/layer.d.ts +10 -0
  249. package/dist/_pkgs/std/utils/layer.js +64 -13
  250. package/dist/_pkgs/std/view/element/gfx-block-component.js +10 -2
  251. package/dist/commands.js +4 -1
  252. package/dist/translations.js +10 -6
  253. package/package.json +9 -2
  254. package/dist/_pkgs/affine-components/icons/file-icons-rc.d.ts +0 -1
  255. package/dist/_pkgs/affine-components/icons/file-icons-rc.js +0 -130
  256. package/dist/_pkgs/affine-shared/test-utils/affine-template.d.ts +0 -6
  257. package/dist/_pkgs/affine-shared/test-utils/affine-template.js +0 -258
  258. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.d.ts +0 -8
  259. package/dist/_pkgs/affine-shared/test-utils/affine-test-utils.js +0 -81
  260. package/dist/_pkgs/affine-shared/test-utils/create-test-host.d.ts +0 -23
  261. package/dist/_pkgs/affine-shared/test-utils/create-test-host.js +0 -187
  262. package/dist/_pkgs/affine-shared/test-utils/index.d.ts +0 -3
  263. package/dist/_pkgs/affine-shared/test-utils/index.js +0 -3
@@ -320,3 +320,72 @@ export interface DocumentDamagedEvent extends TelemetryEvent {
320
320
  export type DocumentHealthEvents = {
321
321
  DocumentDamaged: DocumentDamagedEvent;
322
322
  };
323
+ /**
324
+ * The selection pane was opened (ADR 0031 §14).
325
+ *
326
+ * Worth measuring for the reason any optional surface is: a pane nobody opens
327
+ * is chrome the toolbar pays a slot for. `source` is how the user got there —
328
+ * the edgeless toolbar's button, the palette (or the agent, which invokes by
329
+ * name as the palette does), or a bound chord. Opening only: closing reports
330
+ * nothing, and neither does a toggle that closes the pane.
331
+ *
332
+ * No ids at all: the event is about the pane, never about what it lists.
333
+ */
334
+ export interface SelectionPaneOpenedEvent extends TelemetryEvent {
335
+ page?: 'whiteboard editor';
336
+ source: 'toolbar' | 'palette' | 'shortcut';
337
+ }
338
+ /**
339
+ * Something on the canvas was hidden or shown (ADR 0031 §14).
340
+ *
341
+ * `scope: 'local'` is the viewer's own hide, which writes nothing to the
342
+ * document; `'everyone'` is "hide for everyone", which stores
343
+ * `hiddenForEveryone` on each element and syncs it.
344
+ * `target: 'layer'` is reserved for the layers stage. `count` is how many
345
+ * elements the ONE gesture actually changed — a gesture that changes nothing
346
+ * reports nothing.
347
+ *
348
+ * Counts only: never an element id, a type, a group title or any text.
349
+ */
350
+ export interface CanvasVisibilityChangedEvent extends TelemetryEvent {
351
+ page?: 'whiteboard editor';
352
+ target: 'element' | 'layer';
353
+ scope: 'local' | 'everyone';
354
+ hidden: boolean;
355
+ count: number;
356
+ }
357
+ /**
358
+ * The canvas grid was turned on or off (ADR 0031 §14).
359
+ *
360
+ * `scope: 'local'` is the viewer's own toggle, which writes nothing to the
361
+ * document; `'everyone'` is "Save for everyone", which stores the grid on the
362
+ * document. `visible` is the state after the gesture. A save that changes
363
+ * nothing in the document reports nothing.
364
+ */
365
+ export interface CanvasGridToggledEvent extends TelemetryEvent {
366
+ page?: 'whiteboard editor';
367
+ scope: 'local' | 'everyone';
368
+ visible: boolean;
369
+ }
370
+ /**
371
+ * The user layers changed (ADR 0031 §14).
372
+ *
373
+ * `layerCount` is how many layers the surface holds AFTER the gesture;
374
+ * `memberCount` is how many models the gesture moved (for `move-elements`)
375
+ * or deleted with the layer (for `delete`). A gesture that changes nothing
376
+ * reports nothing.
377
+ *
378
+ * Counts only: never a layer name, a layer id or any element text.
379
+ */
380
+ export interface CanvasLayerChangedEvent extends TelemetryEvent {
381
+ page?: 'whiteboard editor';
382
+ action: 'create' | 'rename' | 'reorder' | 'delete' | 'move-elements';
383
+ layerCount: number;
384
+ memberCount?: number;
385
+ }
386
+ export type CanvasPaneEvents = {
387
+ SelectionPaneOpened: SelectionPaneOpenedEvent;
388
+ CanvasVisibilityChanged: CanvasVisibilityChangedEvent;
389
+ CanvasGridToggled: CanvasGridToggledEvent;
390
+ CanvasLayerChanged: CanvasLayerChangedEvent;
391
+ };
@@ -2,12 +2,12 @@ import type { ExtensionType } from '../../../store/index.js';
2
2
  import type { CitationEvents } from './citation.js';
3
3
  import type { CodeBlockEvents } from './code-block.js';
4
4
  import type { OutDatabaseAllEvents } from './database.js';
5
- import type { AuditEvents, BlockLifecycleEvents, DocumentHealthEvents, FrameworkDiagramEvents, ValidationEvents } from './lifecycle.js';
5
+ import type { AuditEvents, BlockLifecycleEvents, CanvasPaneEvents, DocumentHealthEvents, FrameworkDiagramEvents, ValidationEvents } from './lifecycle.js';
6
6
  import type { LinkToolbarEvents } from './link.js';
7
7
  import type { NoteEvents } from './note.js';
8
8
  import type { SlashMenuEvents } from './slash-menu.js';
9
9
  import type { AttachmentReloadedEvent, AttachmentReloadedEventInToolbar, AttachmentUpgradedEvent, AttachmentUploadedEvent, BlockCreationEvent, DocCreatedEvent, EdgelessToolPickedEvent, ElementCreationEvent, ElementLockEvent, ElementUpdatedEvent, LatexEvent, LinkedDocCreatedEvent, LinkEvent, MindMapCollapseEvent, TelemetryEvent } from './types.js';
10
- export type TelemetryEventMap = OutDatabaseAllEvents & LinkToolbarEvents & SlashMenuEvents & CodeBlockEvents & NoteEvents & CitationEvents & BlockLifecycleEvents & FrameworkDiagramEvents & ValidationEvents & AuditEvents & DocumentHealthEvents & {
10
+ export type TelemetryEventMap = OutDatabaseAllEvents & LinkToolbarEvents & SlashMenuEvents & CodeBlockEvents & NoteEvents & CitationEvents & BlockLifecycleEvents & FrameworkDiagramEvents & ValidationEvents & AuditEvents & CanvasPaneEvents & DocumentHealthEvents & {
11
11
  DocCreated: DocCreatedEvent;
12
12
  Link: TelemetryEvent;
13
13
  LinkedDocCreated: LinkedDocCreatedEvent;
@@ -188,6 +188,11 @@ export declare const STYLE_MENU_LABEL: ChromeWording;
188
188
  export declare const TEXT_FORMAT_BOLD: ChromeWording;
189
189
  export declare const TEXT_FORMAT_ITALIC: ChromeWording;
190
190
  export declare const TEXT_FORMAT_UNDERLINE: ChromeWording;
191
+ /**
192
+ * Said by the canvas text toolbar's decoration toggles (`gfx/text`, beside
193
+ * {@link TEXT_FORMAT_UNDERLINE}) and by the inline format bar (ADR 0030).
194
+ */
195
+ export declare const TEXT_FORMAT_OVERLINE: ChromeWording;
191
196
  export declare const TEXT_FORMAT_STRIKETHROUGH: ChromeWording;
192
197
  /**
193
198
  * The font weights and the one non-default font style a text toolbar offers —
@@ -335,6 +335,14 @@ export const TEXT_FORMAT_UNDERLINE = [
335
335
  'com.labre.text-format.underline',
336
336
  'Underline',
337
337
  ];
338
+ /**
339
+ * Said by the canvas text toolbar's decoration toggles (`gfx/text`, beside
340
+ * {@link TEXT_FORMAT_UNDERLINE}) and by the inline format bar (ADR 0030).
341
+ */
342
+ export const TEXT_FORMAT_OVERLINE = [
343
+ 'com.labre.text-format.overline',
344
+ 'Overline',
345
+ ];
338
346
  export const TEXT_FORMAT_STRIKETHROUGH = [
339
347
  'com.labre.text-format.strikethrough',
340
348
  'Strikethrough',
@@ -1203,6 +1211,7 @@ export const CHROME_WORDINGS = [
1203
1211
  TEXT_FORMAT_BOLD,
1204
1212
  TEXT_FORMAT_ITALIC,
1205
1213
  TEXT_FORMAT_UNDERLINE,
1214
+ TEXT_FORMAT_OVERLINE,
1206
1215
  TEXT_FORMAT_STRIKETHROUGH,
1207
1216
  FONT_WEIGHT_LIGHT,
1208
1217
  FONT_WEIGHT_REGULAR,
@@ -1,5 +1,6 @@
1
1
  export { fontBaseStyle, fontSMStyle, fontXSStyle } from './font.js';
2
2
  export { reducedMotionStyle, SPRING_DURATION_MS, SPRING_EASING, springDuration, springEasing, } from './motion.js';
3
3
  export { panelBaseColorsStyle, panelBaseStyle } from './panel.js';
4
+ export { PANEL_DRAG_THRESHOLD_PX, panelDragStarted, panelHeaderStyles, } from './panel-header.js';
4
5
  export { scrollbarStyle } from './scrollbar-style.js';
5
6
  export { affineTextStyles } from './text.js';
@@ -1,5 +1,6 @@
1
1
  export { fontBaseStyle, fontSMStyle, fontXSStyle } from './font.js';
2
2
  export { reducedMotionStyle, SPRING_DURATION_MS, SPRING_EASING, springDuration, springEasing, } from './motion.js';
3
3
  export { panelBaseColorsStyle, panelBaseStyle } from './panel.js';
4
+ export { PANEL_DRAG_THRESHOLD_PX, panelDragStarted, panelHeaderStyles, } from './panel-header.js';
4
5
  export { scrollbarStyle } from './scrollbar-style.js';
5
6
  export { affineTextStyles } from './text.js';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The header of a side panel, as the frame panel draws it
3
+ * (`fragments/frame-panel`, `header/frame-panel-header.ts`): one 36px row,
4
+ * 8px side padding, no divider under it, a 14px / 500 secondary-text title
5
+ * and icon buttons whose glyph is secondary until hovered or active.
6
+ *
7
+ * Every side panel's header takes it from here — the frame panel, the
8
+ * selection pane and the artefact catalogue — so the three cannot drift
9
+ * apart (held by `panel-header-parity.unit.spec.ts` in `affine/all`). It lives
10
+ * this low because a widget may not import the frame panel: the frame panel
11
+ * depends on the frame block, which depends on the edgeless toolbar.
12
+ *
13
+ * A component opts in by adding the three classes to its own markup:
14
+ * `affine-panel-header` on the row, `affine-panel-header-title` on the title,
15
+ * `affine-panel-header-button` on each icon button.
16
+ */
17
+ export declare const panelHeaderStyles: import("lit").CSSResult;
18
+ /**
19
+ * Pointer travel, on either axis, before a press on a card or a row of a side
20
+ * panel becomes a drag rather than a click — the frame panel's threshold,
21
+ * shared with the selection pane so the two panels start a drag alike.
22
+ */
23
+ export declare const PANEL_DRAG_THRESHOLD_PX = 5;
24
+ /** Whether a press at `from` moved to `to` has travelled far enough to drag. */
25
+ export declare function panelDragStarted(from: {
26
+ x: number;
27
+ y: number;
28
+ }, to: {
29
+ x: number;
30
+ y: number;
31
+ }): boolean;
@@ -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
  });