@eclipse-glsp/client 0.10.0-next.ca17587.154 → 1.1.0-RC01

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 (578) hide show
  1. package/css/decoration.css +5 -1
  2. package/css/glsp-sprotty.css +149 -8
  3. package/css/tool-palette.css +2 -2
  4. package/lib/base/action-dispatcher.d.ts +4 -3
  5. package/lib/base/action-dispatcher.d.ts.map +1 -1
  6. package/lib/base/action-dispatcher.js +22 -12
  7. package/lib/base/action-dispatcher.js.map +1 -1
  8. package/lib/base/actions/focus-change-action.d.ts +16 -7
  9. package/lib/base/actions/focus-change-action.d.ts.map +1 -1
  10. package/lib/base/actions/focus-change-action.js +31 -12
  11. package/lib/base/actions/focus-change-action.js.map +1 -1
  12. package/lib/base/actions/sprotty-actions.d.ts +7 -0
  13. package/lib/base/actions/sprotty-actions.d.ts.map +1 -0
  14. package/lib/{features/tool-palette/palette-item.js → base/actions/sprotty-actions.js} +4 -20
  15. package/lib/base/actions/sprotty-actions.js.map +1 -0
  16. package/lib/base/auto-complete/auto-complete-actions.d.ts +5 -3
  17. package/lib/base/auto-complete/auto-complete-actions.d.ts.map +1 -1
  18. package/lib/base/auto-complete/auto-complete-actions.js +24 -5
  19. package/lib/base/auto-complete/auto-complete-actions.js.map +1 -1
  20. package/lib/base/auto-complete/auto-complete-widget.d.ts +9 -2
  21. package/lib/base/auto-complete/auto-complete-widget.d.ts.map +1 -1
  22. package/lib/base/auto-complete/auto-complete-widget.js +16 -9
  23. package/lib/base/auto-complete/auto-complete-widget.js.map +1 -1
  24. package/lib/base/auto-complete/validation-decorator.js +2 -2
  25. package/lib/base/auto-complete/validation-decorator.js.map +1 -1
  26. package/lib/base/command-stack.d.ts.map +1 -1
  27. package/lib/base/command-stack.js +6 -5
  28. package/lib/base/command-stack.js.map +1 -1
  29. package/lib/base/container-modules.d.ts.map +1 -1
  30. package/lib/base/container-modules.js +10 -9
  31. package/lib/base/container-modules.js.map +1 -1
  32. package/lib/base/di.config.d.ts +1 -1
  33. package/lib/base/di.config.d.ts.map +1 -1
  34. package/lib/base/di.config.js +13 -14
  35. package/lib/base/di.config.js.map +1 -1
  36. package/lib/base/drag-aware-mouse-listener.d.ts +1 -1
  37. package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
  38. package/lib/base/drag-aware-mouse-listener.js.map +1 -1
  39. package/lib/base/editor-context-service.d.ts +15 -4
  40. package/lib/base/editor-context-service.d.ts.map +1 -1
  41. package/lib/base/editor-context-service.js +31 -19
  42. package/lib/base/editor-context-service.js.map +1 -1
  43. package/lib/base/focus-tracker.d.ts +1 -1
  44. package/lib/base/focus-tracker.d.ts.map +1 -1
  45. package/lib/base/focus-tracker.js +4 -4
  46. package/lib/base/focus-tracker.js.map +1 -1
  47. package/lib/base/model/model-registry.d.ts.map +1 -1
  48. package/lib/base/model/model-registry.js +2 -2
  49. package/lib/base/model/model-registry.js.map +1 -1
  50. package/lib/base/model/update-model-command.d.ts +15 -8
  51. package/lib/base/model/update-model-command.d.ts.map +1 -1
  52. package/lib/base/model/update-model-command.js +43 -53
  53. package/lib/base/model/update-model-command.js.map +1 -1
  54. package/lib/base/model-initialization-constraint.d.ts +4 -5
  55. package/lib/base/model-initialization-constraint.d.ts.map +1 -1
  56. package/lib/base/model-initialization-constraint.js +11 -13
  57. package/lib/base/model-initialization-constraint.js.map +1 -1
  58. package/lib/base/selection-clearing-mouse-listener.d.ts.map +1 -1
  59. package/lib/base/selection-clearing-mouse-listener.js +1 -1
  60. package/lib/base/selection-clearing-mouse-listener.js.map +1 -1
  61. package/lib/base/source-uri-aware.d.ts +2 -17
  62. package/lib/base/source-uri-aware.d.ts.map +1 -1
  63. package/lib/base/source-uri-aware.js +4 -6
  64. package/lib/base/source-uri-aware.js.map +1 -1
  65. package/lib/base/tool-manager/glsp-tool-manager.d.ts +1 -1
  66. package/lib/base/tool-manager/glsp-tool-manager.d.ts.map +1 -1
  67. package/lib/base/tool-manager/glsp-tool-manager.js +10 -10
  68. package/lib/base/tool-manager/glsp-tool-manager.js.map +1 -1
  69. package/lib/base/tool-manager/tool-actions.d.ts +14 -0
  70. package/lib/base/tool-manager/tool-actions.d.ts.map +1 -0
  71. package/lib/base/tool-manager/tool-actions.js +25 -0
  72. package/lib/base/tool-manager/tool-actions.js.map +1 -0
  73. package/lib/base/types.d.ts +146 -20
  74. package/lib/base/types.d.ts.map +1 -1
  75. package/lib/base/types.js +14 -26
  76. package/lib/base/types.js.map +1 -1
  77. package/lib/base/view/view-registry.d.ts.map +1 -1
  78. package/lib/base/view/view-registry.js +2 -2
  79. package/lib/base/view/view-registry.js.map +1 -1
  80. package/lib/features/change-bounds/model.d.ts +1 -1
  81. package/lib/features/change-bounds/model.d.ts.map +1 -1
  82. package/lib/features/change-bounds/model.js +3 -3
  83. package/lib/features/change-bounds/model.js.map +1 -1
  84. package/lib/features/change-bounds/movement-restrictor.d.ts +37 -7
  85. package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
  86. package/lib/features/change-bounds/movement-restrictor.js +55 -40
  87. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  88. package/lib/features/change-bounds/snap.d.ts +60 -4
  89. package/lib/features/change-bounds/snap.d.ts.map +1 -1
  90. package/lib/features/change-bounds/snap.js +96 -9
  91. package/lib/features/change-bounds/snap.js.map +1 -1
  92. package/lib/features/change-bounds/snap.spec.d.ts +17 -0
  93. package/lib/features/change-bounds/snap.spec.d.ts.map +1 -0
  94. package/lib/features/change-bounds/snap.spec.js +82 -0
  95. package/lib/features/change-bounds/snap.spec.js.map +1 -0
  96. package/lib/features/command-palette/command-palette-tool.js +3 -3
  97. package/lib/features/command-palette/command-palette-tool.js.map +1 -1
  98. package/lib/features/command-palette/di.config.d.ts +2 -2
  99. package/lib/features/command-palette/di.config.d.ts.map +1 -1
  100. package/lib/features/command-palette/di.config.js +6 -6
  101. package/lib/features/command-palette/di.config.js.map +1 -1
  102. package/lib/features/command-palette/server-command-palette-provider.d.ts +1 -1
  103. package/lib/features/command-palette/server-command-palette-provider.d.ts.map +1 -1
  104. package/lib/features/command-palette/server-command-palette-provider.js +13 -10
  105. package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
  106. package/lib/features/context-menu/delete-element-context-menu.d.ts +17 -1
  107. package/lib/features/context-menu/delete-element-context-menu.d.ts.map +1 -1
  108. package/lib/features/context-menu/delete-element-context-menu.js +4 -4
  109. package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
  110. package/lib/features/context-menu/di.config.d.ts +1 -1
  111. package/lib/features/context-menu/di.config.d.ts.map +1 -1
  112. package/lib/features/context-menu/di.config.js +8 -7
  113. package/lib/features/context-menu/di.config.js.map +1 -1
  114. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts +34 -4
  115. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts.map +1 -1
  116. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js +37 -31
  117. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +1 -1
  118. package/lib/features/context-menu/server-context-menu-provider.d.ts +1 -1
  119. package/lib/features/context-menu/server-context-menu-provider.d.ts.map +1 -1
  120. package/lib/features/context-menu/server-context-menu-provider.js +8 -7
  121. package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
  122. package/lib/features/copy-paste/copy-paste-context-menu.d.ts +12 -15
  123. package/lib/features/copy-paste/copy-paste-context-menu.d.ts.map +1 -1
  124. package/lib/features/copy-paste/copy-paste-context-menu.js +26 -33
  125. package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
  126. package/lib/features/copy-paste/copy-paste-handler.d.ts +1 -1
  127. package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
  128. package/lib/features/copy-paste/copy-paste-handler.js +10 -11
  129. package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
  130. package/lib/features/copy-paste/di.config.d.ts +1 -1
  131. package/lib/features/copy-paste/di.config.d.ts.map +1 -1
  132. package/lib/features/copy-paste/di.config.js +5 -7
  133. package/lib/features/copy-paste/di.config.js.map +1 -1
  134. package/lib/features/decoration/decoration-placer.d.ts +1 -1
  135. package/lib/features/decoration/decoration-placer.d.ts.map +1 -1
  136. package/lib/features/decoration/decoration-placer.js +19 -3
  137. package/lib/features/decoration/decoration-placer.js.map +1 -1
  138. package/lib/features/decoration/di.config.d.ts +2 -2
  139. package/lib/features/decoration/di.config.d.ts.map +1 -1
  140. package/lib/features/decoration/di.config.js +4 -4
  141. package/lib/features/decoration/di.config.js.map +1 -1
  142. package/lib/features/edit-label/di.config.d.ts +1 -1
  143. package/lib/features/edit-label/di.config.d.ts.map +1 -1
  144. package/lib/features/edit-label/di.config.js +5 -5
  145. package/lib/features/edit-label/di.config.js.map +1 -1
  146. package/lib/features/edit-label/edit-label-tool.d.ts.map +1 -1
  147. package/lib/features/edit-label/edit-label-tool.js +2 -2
  148. package/lib/features/edit-label/edit-label-tool.js.map +1 -1
  149. package/lib/features/edit-label/edit-label-validator.d.ts +4 -6
  150. package/lib/features/edit-label/edit-label-validator.d.ts.map +1 -1
  151. package/lib/features/edit-label/edit-label-validator.js +11 -13
  152. package/lib/features/edit-label/edit-label-validator.js.map +1 -1
  153. package/lib/features/hints/di.config.js +4 -4
  154. package/lib/features/hints/di.config.js.map +1 -1
  155. package/lib/features/hints/type-hints.d.ts +15 -5
  156. package/lib/features/hints/type-hints.d.ts.map +1 -1
  157. package/lib/features/hints/type-hints.js +29 -26
  158. package/lib/features/hints/type-hints.js.map +1 -1
  159. package/lib/features/hover/di.config.d.ts +1 -1
  160. package/lib/features/hover/di.config.d.ts.map +1 -1
  161. package/lib/features/hover/di.config.js +14 -10
  162. package/lib/features/hover/di.config.js.map +1 -1
  163. package/lib/features/hover/hover.d.ts +16 -5
  164. package/lib/features/hover/hover.d.ts.map +1 -1
  165. package/lib/features/hover/hover.js +44 -19
  166. package/lib/features/hover/hover.js.map +1 -1
  167. package/lib/features/layout/di.config.d.ts +3 -3
  168. package/lib/features/layout/di.config.d.ts.map +1 -1
  169. package/lib/features/layout/di.config.js +12 -7
  170. package/lib/features/layout/di.config.js.map +1 -1
  171. package/lib/features/layout/freeform-layout.d.ts +17 -1
  172. package/lib/features/layout/freeform-layout.d.ts.map +1 -1
  173. package/lib/features/layout/freeform-layout.js +4 -4
  174. package/lib/features/layout/freeform-layout.js.map +1 -1
  175. package/lib/features/layout/hbox-layout.d.ts +41 -0
  176. package/lib/features/layout/hbox-layout.d.ts.map +1 -0
  177. package/lib/features/layout/hbox-layout.js +201 -0
  178. package/lib/features/layout/hbox-layout.js.map +1 -0
  179. package/lib/features/layout/layout-elements-action.d.ts +198 -0
  180. package/lib/features/layout/layout-elements-action.d.ts.map +1 -0
  181. package/lib/features/layout/layout-elements-action.js +391 -0
  182. package/lib/features/layout/layout-elements-action.js.map +1 -0
  183. package/lib/features/layout/layout-elements-action.spec.d.ts +3 -0
  184. package/lib/features/layout/layout-elements-action.spec.d.ts.map +1 -0
  185. package/lib/features/layout/{layout-commands.spec.js → layout-elements-action.spec.js} +81 -62
  186. package/lib/features/layout/layout-elements-action.spec.js.map +1 -0
  187. package/lib/features/layout/layouter.d.ts +37 -0
  188. package/lib/features/layout/layouter.d.ts.map +1 -0
  189. package/lib/features/layout/layouter.js +131 -0
  190. package/lib/features/layout/layouter.js.map +1 -0
  191. package/lib/features/layout/tests/freeform-layout.spec.d.ts +3 -0
  192. package/lib/features/layout/tests/freeform-layout.spec.d.ts.map +1 -0
  193. package/lib/features/layout/tests/freeform-layout.spec.js +201 -0
  194. package/lib/features/layout/tests/freeform-layout.spec.js.map +1 -0
  195. package/lib/features/layout/tests/hbox-layout.spec.d.ts +3 -0
  196. package/lib/features/layout/tests/hbox-layout.spec.d.ts.map +1 -0
  197. package/lib/features/layout/tests/hbox-layout.spec.js +161 -0
  198. package/lib/features/layout/tests/hbox-layout.spec.js.map +1 -0
  199. package/lib/features/layout/tests/layouter-test-util.d.ts +34 -0
  200. package/lib/features/layout/tests/layouter-test-util.d.ts.map +1 -0
  201. package/lib/features/layout/tests/layouter-test-util.js +96 -0
  202. package/lib/features/layout/tests/layouter-test-util.js.map +1 -0
  203. package/lib/features/layout/tests/vbox-layout.spec.d.ts +3 -0
  204. package/lib/features/layout/tests/vbox-layout.spec.d.ts.map +1 -0
  205. package/lib/features/layout/tests/vbox-layout.spec.js +161 -0
  206. package/lib/features/layout/tests/vbox-layout.spec.js.map +1 -0
  207. package/lib/features/layout/vbox-layout.d.ts +18 -2
  208. package/lib/features/layout/vbox-layout.d.ts.map +1 -1
  209. package/lib/features/layout/vbox-layout.js +26 -13
  210. package/lib/features/layout/vbox-layout.js.map +1 -1
  211. package/lib/features/mouse-tool/di.config.d.ts +1 -1
  212. package/lib/features/mouse-tool/di.config.d.ts.map +1 -1
  213. package/lib/features/mouse-tool/di.config.js +2 -2
  214. package/lib/features/mouse-tool/di.config.js.map +1 -1
  215. package/lib/features/mouse-tool/mouse-tool.d.ts +9 -6
  216. package/lib/features/mouse-tool/mouse-tool.d.ts.map +1 -1
  217. package/lib/features/mouse-tool/mouse-tool.js +10 -48
  218. package/lib/features/mouse-tool/mouse-tool.js.map +1 -1
  219. package/lib/features/navigation/di.config.js +4 -4
  220. package/lib/features/navigation/di.config.js.map +1 -1
  221. package/lib/features/navigation/navigation-action-handler.d.ts +31 -16
  222. package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
  223. package/lib/features/navigation/navigation-action-handler.js +52 -68
  224. package/lib/features/navigation/navigation-action-handler.js.map +1 -1
  225. package/lib/features/navigation/navigation-target-resolver.d.ts +3 -3
  226. package/lib/features/navigation/navigation-target-resolver.d.ts.map +1 -1
  227. package/lib/features/navigation/navigation-target-resolver.js +8 -9
  228. package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
  229. package/lib/features/navigation/navigation-target-resolver.spec.js +12 -12
  230. package/lib/features/navigation/navigation-target-resolver.spec.js.map +1 -1
  231. package/lib/features/reconnect/model.d.ts +1 -1
  232. package/lib/features/reconnect/model.d.ts.map +1 -1
  233. package/lib/features/reconnect/model.js +1 -1
  234. package/lib/features/reconnect/model.js.map +1 -1
  235. package/lib/features/save/di.config.d.ts +1 -1
  236. package/lib/features/save/di.config.d.ts.map +1 -1
  237. package/lib/features/save/di.config.js +3 -3
  238. package/lib/features/save/di.config.js.map +1 -1
  239. package/lib/features/save/save-keylistener.d.ts +1 -1
  240. package/lib/features/save/save-keylistener.d.ts.map +1 -1
  241. package/lib/features/save/save-keylistener.js +3 -3
  242. package/lib/features/save/save-keylistener.js.map +1 -1
  243. package/lib/features/select/di.config.d.ts +1 -1
  244. package/lib/features/select/di.config.d.ts.map +1 -1
  245. package/lib/features/select/di.config.js +7 -8
  246. package/lib/features/select/di.config.js.map +1 -1
  247. package/lib/features/select/select-feedback-action.d.ts +26 -22
  248. package/lib/features/select/select-feedback-action.d.ts.map +1 -1
  249. package/lib/features/select/select-feedback-action.js +19 -46
  250. package/lib/features/select/select-feedback-action.js.map +1 -1
  251. package/lib/features/select/select-mouse-listener.d.ts +4 -2
  252. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  253. package/lib/features/select/select-mouse-listener.js +63 -1
  254. package/lib/features/select/select-mouse-listener.js.map +1 -1
  255. package/lib/features/select/selection-service.d.ts +14 -5
  256. package/lib/features/select/selection-service.d.ts.map +1 -1
  257. package/lib/features/select/selection-service.js +55 -64
  258. package/lib/features/select/selection-service.js.map +1 -1
  259. package/lib/features/select/selection-service.spec.js +28 -25
  260. package/lib/features/select/selection-service.spec.js.map +1 -1
  261. package/lib/features/source-model-watcher/di.config.d.ts +4 -0
  262. package/lib/features/{model-source-watcher → source-model-watcher}/di.config.d.ts.map +1 -1
  263. package/lib/features/{model-source-watcher → source-model-watcher}/di.config.js +4 -4
  264. package/lib/features/source-model-watcher/di.config.js.map +1 -0
  265. package/lib/features/{model-source-watcher/model-source-changed-action-handler.d.ts → source-model-watcher/source-model-changed-action-handler.d.ts} +10 -10
  266. package/lib/features/source-model-watcher/source-model-changed-action-handler.d.ts.map +1 -0
  267. package/lib/features/{model-source-watcher/model-source-changed-action-handler.js → source-model-watcher/source-model-changed-action-handler.js} +28 -28
  268. package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -0
  269. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts +17 -9
  270. package/lib/features/tool-feedback/change-bounds-tool-feedback.d.ts.map +1 -1
  271. package/lib/features/tool-feedback/change-bounds-tool-feedback.js +68 -38
  272. package/lib/features/tool-feedback/change-bounds-tool-feedback.js.map +1 -1
  273. package/lib/features/tool-feedback/creation-tool-feedback.d.ts +24 -12
  274. package/lib/features/tool-feedback/creation-tool-feedback.d.ts.map +1 -1
  275. package/lib/features/tool-feedback/creation-tool-feedback.js +88 -35
  276. package/lib/features/tool-feedback/creation-tool-feedback.js.map +1 -1
  277. package/lib/features/tool-feedback/css-feedback.d.ts +17 -10
  278. package/lib/features/tool-feedback/css-feedback.d.ts.map +1 -1
  279. package/lib/features/tool-feedback/css-feedback.js +42 -38
  280. package/lib/features/tool-feedback/css-feedback.js.map +1 -1
  281. package/lib/features/tool-feedback/di.config.d.ts +1 -1
  282. package/lib/features/tool-feedback/di.config.d.ts.map +1 -1
  283. package/lib/features/tool-feedback/di.config.js +18 -18
  284. package/lib/features/tool-feedback/di.config.js.map +1 -1
  285. package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts +45 -22
  286. package/lib/features/tool-feedback/edge-edit-tool-feedback.d.ts.map +1 -1
  287. package/lib/features/tool-feedback/edge-edit-tool-feedback.js +147 -114
  288. package/lib/features/tool-feedback/edge-edit-tool-feedback.js.map +1 -1
  289. package/lib/features/tool-feedback/feedback-action-dispatcher.d.ts +2 -2
  290. package/lib/features/tool-feedback/feedback-action-dispatcher.d.ts.map +1 -1
  291. package/lib/features/tool-feedback/feedback-action-dispatcher.js +4 -4
  292. package/lib/features/tool-feedback/feedback-action-dispatcher.js.map +1 -1
  293. package/lib/features/tool-feedback/marquee-tool-feedback.d.ts +21 -10
  294. package/lib/features/tool-feedback/marquee-tool-feedback.d.ts.map +1 -1
  295. package/lib/features/tool-feedback/marquee-tool-feedback.js +44 -18
  296. package/lib/features/tool-feedback/marquee-tool-feedback.js.map +1 -1
  297. package/lib/features/tool-feedback/model.d.ts +1 -2
  298. package/lib/features/tool-feedback/model.d.ts.map +1 -1
  299. package/lib/features/tool-feedback/model.js +1 -1
  300. package/lib/features/tool-feedback/model.js.map +1 -1
  301. package/lib/features/tool-feedback/view.d.ts +1 -1
  302. package/lib/features/tool-feedback/view.d.ts.map +1 -1
  303. package/lib/features/tool-feedback/view.js +22 -5
  304. package/lib/features/tool-feedback/view.js.map +1 -1
  305. package/lib/features/tool-palette/di.config.d.ts +1 -1
  306. package/lib/features/tool-palette/di.config.d.ts.map +1 -1
  307. package/lib/features/tool-palette/di.config.js +5 -4
  308. package/lib/features/tool-palette/di.config.js.map +1 -1
  309. package/lib/features/tool-palette/tool-palette.d.ts +10 -7
  310. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  311. package/lib/features/tool-palette/tool-palette.js +39 -32
  312. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  313. package/lib/features/tools/base-glsp-tool.d.ts +3 -3
  314. package/lib/features/tools/base-glsp-tool.d.ts.map +1 -1
  315. package/lib/features/tools/base-glsp-tool.js +11 -11
  316. package/lib/features/tools/base-glsp-tool.js.map +1 -1
  317. package/lib/features/tools/change-bounds-tool.d.ts +7 -9
  318. package/lib/features/tools/change-bounds-tool.d.ts.map +1 -1
  319. package/lib/features/tools/change-bounds-tool.js +48 -71
  320. package/lib/features/tools/change-bounds-tool.js.map +1 -1
  321. package/lib/features/tools/delete-tool.d.ts +1 -1
  322. package/lib/features/tools/delete-tool.d.ts.map +1 -1
  323. package/lib/features/tools/delete-tool.js +17 -17
  324. package/lib/features/tools/delete-tool.js.map +1 -1
  325. package/lib/features/tools/di.config.d.ts +9 -2
  326. package/lib/features/tools/di.config.d.ts.map +1 -1
  327. package/lib/features/tools/di.config.js +26 -15
  328. package/lib/features/tools/di.config.js.map +1 -1
  329. package/lib/features/tools/edge-creation-tool.d.ts +1 -1
  330. package/lib/features/tools/edge-creation-tool.d.ts.map +1 -1
  331. package/lib/features/tools/edge-creation-tool.js +28 -21
  332. package/lib/features/tools/edge-creation-tool.js.map +1 -1
  333. package/lib/features/tools/edge-edit-tool.d.ts +3 -2
  334. package/lib/features/tools/edge-edit-tool.d.ts.map +1 -1
  335. package/lib/features/tools/edge-edit-tool.js +41 -36
  336. package/lib/features/tools/edge-edit-tool.js.map +1 -1
  337. package/lib/features/{tool-palette/palette-item.d.ts → tools/enable-default-tools-on-focus-loss.d.ts} +11 -11
  338. package/lib/features/tools/enable-default-tools-on-focus-loss.d.ts.map +1 -0
  339. package/lib/features/tools/enable-default-tools-on-focus-loss.js +29 -0
  340. package/lib/features/tools/enable-default-tools-on-focus-loss.js.map +1 -0
  341. package/lib/features/tools/marquee-behavior.d.ts +1 -1
  342. package/lib/features/tools/marquee-behavior.js +2 -2
  343. package/lib/features/tools/marquee-behavior.js.map +1 -1
  344. package/lib/features/tools/marquee-behavior.spec.js +63 -63
  345. package/lib/features/tools/marquee-behavior.spec.js.map +1 -1
  346. package/lib/features/tools/marquee-mouse-tool.d.ts +1 -1
  347. package/lib/features/tools/marquee-mouse-tool.d.ts.map +1 -1
  348. package/lib/features/tools/marquee-mouse-tool.js +20 -20
  349. package/lib/features/tools/marquee-mouse-tool.js.map +1 -1
  350. package/lib/features/tools/marquee-tool.d.ts +1 -1
  351. package/lib/features/tools/marquee-tool.d.ts.map +1 -1
  352. package/lib/features/tools/marquee-tool.js +4 -4
  353. package/lib/features/tools/marquee-tool.js.map +1 -1
  354. package/lib/features/tools/model.d.ts +3 -2
  355. package/lib/features/tools/model.d.ts.map +1 -1
  356. package/lib/features/tools/model.js +0 -15
  357. package/lib/features/tools/model.js.map +1 -1
  358. package/lib/features/tools/node-creation-tool.d.ts +1 -1
  359. package/lib/features/tools/node-creation-tool.d.ts.map +1 -1
  360. package/lib/features/tools/node-creation-tool.js +17 -17
  361. package/lib/features/tools/node-creation-tool.js.map +1 -1
  362. package/lib/features/tools/view.d.ts.map +1 -1
  363. package/lib/features/tools/view.js +2 -2
  364. package/lib/features/tools/view.js.map +1 -1
  365. package/lib/features/validation/di.config.d.ts +0 -15
  366. package/lib/features/validation/di.config.d.ts.map +1 -1
  367. package/lib/features/validation/di.config.js +9 -7
  368. package/lib/features/validation/di.config.js.map +1 -1
  369. package/lib/features/validation/issue-marker.d.ts +11 -5
  370. package/lib/features/validation/issue-marker.d.ts.map +1 -1
  371. package/lib/features/validation/issue-marker.js +25 -5
  372. package/lib/features/validation/issue-marker.js.map +1 -1
  373. package/lib/features/validation/marker-navigator.d.ts +27 -25
  374. package/lib/features/validation/marker-navigator.d.ts.map +1 -1
  375. package/lib/features/validation/marker-navigator.js +64 -91
  376. package/lib/features/validation/marker-navigator.js.map +1 -1
  377. package/lib/features/validation/marker-navigator.spec.d.ts.map +1 -1
  378. package/lib/features/validation/marker-navigator.spec.js +23 -37
  379. package/lib/features/validation/marker-navigator.spec.js.map +1 -1
  380. package/lib/features/validation/validate.d.ts +17 -30
  381. package/lib/features/validation/validate.d.ts.map +1 -1
  382. package/lib/features/validation/validate.js +66 -91
  383. package/lib/features/validation/validate.js.map +1 -1
  384. package/lib/features/viewport/di.config.d.ts +1 -1
  385. package/lib/features/viewport/di.config.d.ts.map +1 -1
  386. package/lib/features/viewport/di.config.js +7 -7
  387. package/lib/features/viewport/di.config.js.map +1 -1
  388. package/lib/features/viewport/glsp-scroll-mouse-listener.d.ts +1 -1
  389. package/lib/features/viewport/glsp-scroll-mouse-listener.d.ts.map +1 -1
  390. package/lib/features/viewport/glsp-scroll-mouse-listener.js +3 -3
  391. package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
  392. package/lib/index.d.ts +10 -11
  393. package/lib/index.d.ts.map +1 -1
  394. package/lib/index.js +26 -22
  395. package/lib/index.js.map +1 -1
  396. package/lib/lib/model.d.ts +3 -2
  397. package/lib/lib/model.d.ts.map +1 -1
  398. package/lib/lib/model.js +3 -18
  399. package/lib/lib/model.js.map +1 -1
  400. package/lib/model-source/glsp-diagram-server.d.ts +6 -6
  401. package/lib/model-source/glsp-diagram-server.d.ts.map +1 -1
  402. package/lib/model-source/glsp-diagram-server.js +8 -7
  403. package/lib/model-source/glsp-diagram-server.js.map +1 -1
  404. package/lib/sprotty-reexport.d.ts +174 -0
  405. package/lib/sprotty-reexport.d.ts.map +1 -0
  406. package/lib/sprotty-reexport.js +301 -0
  407. package/lib/sprotty-reexport.js.map +1 -0
  408. package/lib/utils/argument-utils.js +5 -5
  409. package/lib/utils/argument-utils.js.map +1 -1
  410. package/lib/utils/layout-utils.d.ts +6 -22
  411. package/lib/utils/layout-utils.d.ts.map +1 -1
  412. package/lib/utils/layout-utils.js +1 -1
  413. package/lib/utils/layout-utils.js.map +1 -1
  414. package/lib/utils/smodel-util.d.ts +117 -11
  415. package/lib/utils/smodel-util.d.ts.map +1 -1
  416. package/lib/utils/smodel-util.js +142 -37
  417. package/lib/utils/smodel-util.js.map +1 -1
  418. package/lib/utils/viewpoint-util.d.ts +3 -3
  419. package/lib/utils/viewpoint-util.d.ts.map +1 -1
  420. package/lib/utils/viewpoint-util.js +19 -3
  421. package/lib/utils/viewpoint-util.js.map +1 -1
  422. package/lib/views/base-view-module.d.ts.map +1 -1
  423. package/lib/views/base-view-module.js +21 -19
  424. package/lib/views/base-view-module.js.map +1 -1
  425. package/lib/views/compartments.js +2 -2
  426. package/lib/views/compartments.js.map +1 -1
  427. package/lib/views/glsp-edge-view.d.ts +1 -1
  428. package/lib/views/glsp-edge-view.d.ts.map +1 -1
  429. package/lib/views/glsp-edge-view.js +1 -1
  430. package/lib/views/glsp-edge-view.js.map +1 -1
  431. package/lib/views/glsp-projection-view.d.ts +30 -0
  432. package/lib/views/glsp-projection-view.d.ts.map +1 -0
  433. package/lib/views/glsp-projection-view.js +148 -0
  434. package/lib/views/glsp-projection-view.js.map +1 -0
  435. package/lib/views/index.d.ts +1 -0
  436. package/lib/views/index.d.ts.map +1 -1
  437. package/lib/views/index.js +7 -2
  438. package/lib/views/index.js.map +1 -1
  439. package/lib/views/issue-marker-view.d.ts.map +1 -1
  440. package/lib/views/issue-marker-view.js +3 -3
  441. package/lib/views/issue-marker-view.js.map +1 -1
  442. package/lib/views/rounded-corner-view.d.ts.map +1 -1
  443. package/lib/views/rounded-corner-view.js +2 -2
  444. package/lib/views/rounded-corner-view.js.map +1 -1
  445. package/package.json +10 -19
  446. package/src/base/action-dispatcher.ts +26 -16
  447. package/src/base/actions/focus-change-action.ts +25 -8
  448. package/src/base/actions/sprotty-actions.ts +26 -0
  449. package/src/base/auto-complete/auto-complete-actions.ts +7 -5
  450. package/src/base/auto-complete/auto-complete-widget.ts +15 -13
  451. package/src/base/command-stack.ts +7 -6
  452. package/src/base/container-modules.ts +6 -5
  453. package/src/base/di.config.ts +4 -5
  454. package/src/base/drag-aware-mouse-listener.ts +4 -4
  455. package/src/base/editor-context-service.ts +32 -12
  456. package/src/base/focus-tracker.ts +5 -4
  457. package/src/base/model/model-registry.ts +2 -2
  458. package/src/base/model/update-model-command.ts +54 -41
  459. package/src/base/model-initialization-constraint.ts +9 -11
  460. package/src/base/selection-clearing-mouse-listener.ts +1 -1
  461. package/src/base/source-uri-aware.ts +5 -4
  462. package/src/base/tool-manager/glsp-tool-manager.ts +9 -9
  463. package/src/base/tool-manager/tool-actions.ts +37 -0
  464. package/src/base/types.ts +31 -24
  465. package/src/base/view/view-registry.ts +2 -2
  466. package/src/features/change-bounds/model.ts +5 -5
  467. package/src/features/change-bounds/movement-restrictor.ts +74 -44
  468. package/src/features/change-bounds/snap.spec.ts +89 -0
  469. package/src/features/change-bounds/snap.ts +99 -12
  470. package/src/features/command-palette/di.config.ts +5 -7
  471. package/src/features/command-palette/server-command-palette-provider.ts +9 -8
  472. package/src/features/context-menu/delete-element-context-menu.ts +6 -6
  473. package/src/features/context-menu/di.config.ts +3 -2
  474. package/src/features/context-menu/selection-service-aware-context-menu-mouse-listener.ts +51 -29
  475. package/src/features/context-menu/server-context-menu-provider.ts +7 -6
  476. package/src/features/copy-paste/copy-paste-context-menu.ts +30 -23
  477. package/src/features/copy-paste/copy-paste-handler.ts +6 -6
  478. package/src/features/copy-paste/di.config.ts +7 -15
  479. package/src/features/decoration/decoration-placer.ts +4 -4
  480. package/src/features/decoration/di.config.ts +3 -5
  481. package/src/features/edit-label/di.config.ts +4 -5
  482. package/src/features/edit-label/edit-label-tool.ts +1 -2
  483. package/src/features/edit-label/edit-label-validator.ts +6 -10
  484. package/src/features/hints/di.config.ts +3 -3
  485. package/src/features/hints/type-hints.ts +33 -18
  486. package/src/features/hover/di.config.ts +8 -2
  487. package/src/features/hover/hover.ts +48 -28
  488. package/src/features/layout/di.config.ts +17 -7
  489. package/src/features/layout/freeform-layout.ts +6 -15
  490. package/src/features/layout/hbox-layout.ts +273 -0
  491. package/src/features/layout/{layout-commands.spec.ts → layout-elements-action.spec.ts} +89 -65
  492. package/src/features/layout/layout-elements-action.ts +486 -0
  493. package/src/features/layout/layouter.ts +137 -0
  494. package/src/features/layout/tests/freeform-layout.spec.ts +216 -0
  495. package/src/features/layout/tests/hbox-layout.spec.ts +171 -0
  496. package/src/features/layout/tests/layouter-test-util.ts +122 -0
  497. package/src/features/layout/tests/vbox-layout.spec.ts +171 -0
  498. package/src/features/layout/vbox-layout.ts +41 -24
  499. package/src/features/mouse-tool/di.config.ts +3 -4
  500. package/src/features/mouse-tool/mouse-tool.ts +18 -57
  501. package/src/features/navigation/navigation-action-handler.ts +76 -42
  502. package/src/features/navigation/navigation-target-resolver.spec.ts +3 -3
  503. package/src/features/navigation/navigation-target-resolver.ts +8 -13
  504. package/src/features/reconnect/model.ts +2 -2
  505. package/src/features/save/di.config.ts +2 -3
  506. package/src/features/save/save-keylistener.ts +3 -3
  507. package/src/features/select/di.config.ts +6 -8
  508. package/src/features/select/select-feedback-action.ts +18 -46
  509. package/src/features/select/select-mouse-listener.ts +82 -3
  510. package/src/features/select/selection-service.spec.ts +12 -9
  511. package/src/features/select/selection-service.ts +52 -60
  512. package/src/features/{model-source-watcher → source-model-watcher}/di.config.ts +5 -5
  513. package/src/features/{model-source-watcher/model-source-changed-action-handler.ts → source-model-watcher/source-model-changed-action-handler.ts} +17 -22
  514. package/src/features/tool-feedback/change-bounds-tool-feedback.ts +52 -22
  515. package/src/features/tool-feedback/creation-tool-feedback.ts +79 -30
  516. package/src/features/tool-feedback/css-feedback.ts +40 -37
  517. package/src/features/tool-feedback/di.config.ts +4 -5
  518. package/src/features/tool-feedback/edge-edit-tool-feedback.ts +140 -88
  519. package/src/features/tool-feedback/feedback-action-dispatcher.ts +4 -3
  520. package/src/features/tool-feedback/marquee-tool-feedback.ts +38 -13
  521. package/src/features/tool-feedback/model.ts +1 -3
  522. package/src/features/tool-feedback/view.tsx +3 -3
  523. package/src/features/tool-palette/di.config.ts +3 -2
  524. package/src/features/tool-palette/tool-palette.ts +35 -19
  525. package/src/features/tools/base-glsp-tool.ts +11 -11
  526. package/src/features/tools/change-bounds-tool.ts +37 -67
  527. package/src/features/tools/delete-tool.ts +9 -9
  528. package/src/features/tools/di.config.ts +23 -12
  529. package/src/features/tools/edge-creation-tool.ts +21 -12
  530. package/src/features/tools/edge-edit-tool.ts +25 -21
  531. package/src/features/tools/enable-default-tools-on-focus-loss.ts +33 -0
  532. package/src/features/tools/marquee-behavior.ts +2 -2
  533. package/src/features/tools/marquee-mouse-tool.ts +13 -14
  534. package/src/features/tools/marquee-tool.ts +3 -3
  535. package/src/features/tools/model.ts +4 -3
  536. package/src/features/tools/node-creation-tool.ts +8 -8
  537. package/src/features/tools/view.tsx +2 -3
  538. package/src/features/validation/di.config.ts +13 -11
  539. package/src/features/validation/issue-marker.ts +34 -12
  540. package/src/features/validation/marker-navigator.spec.ts +4 -2
  541. package/src/features/validation/marker-navigator.ts +67 -82
  542. package/src/features/validation/validate.ts +62 -90
  543. package/src/features/viewport/di.config.ts +1 -2
  544. package/src/features/viewport/glsp-scroll-mouse-listener.ts +5 -5
  545. package/src/index.ts +12 -12
  546. package/src/lib/model.ts +4 -4
  547. package/src/model-source/glsp-diagram-server.ts +15 -15
  548. package/src/sprotty-reexport.ts +288 -0
  549. package/src/utils/layout-utils.ts +9 -29
  550. package/src/utils/smodel-util.ts +139 -43
  551. package/src/utils/viewpoint-util.ts +5 -14
  552. package/src/views/base-view-module.ts +5 -1
  553. package/src/views/compartments.tsx +1 -1
  554. package/src/views/glsp-edge-view.tsx +4 -4
  555. package/src/views/glsp-projection-view.tsx +173 -0
  556. package/src/views/index.ts +2 -0
  557. package/src/views/issue-marker-view.tsx +2 -2
  558. package/src/views/rounded-corner-view.tsx +2 -3
  559. package/lib/features/layout/layout-commands.d.ts +0 -153
  560. package/lib/features/layout/layout-commands.d.ts.map +0 -1
  561. package/lib/features/layout/layout-commands.js +0 -412
  562. package/lib/features/layout/layout-commands.js.map +0 -1
  563. package/lib/features/layout/layout-commands.spec.d.ts +0 -3
  564. package/lib/features/layout/layout-commands.spec.d.ts.map +0 -1
  565. package/lib/features/layout/layout-commands.spec.js.map +0 -1
  566. package/lib/features/model-source-watcher/di.config.d.ts +0 -4
  567. package/lib/features/model-source-watcher/di.config.js.map +0 -1
  568. package/lib/features/model-source-watcher/model-source-changed-action-handler.d.ts.map +0 -1
  569. package/lib/features/model-source-watcher/model-source-changed-action-handler.js.map +0 -1
  570. package/lib/features/tool-palette/palette-item.d.ts.map +0 -1
  571. package/lib/features/tool-palette/palette-item.js.map +0 -1
  572. package/lib/protocol-reexport.d.ts +0 -45
  573. package/lib/protocol-reexport.d.ts.map +0 -1
  574. package/lib/protocol-reexport.js +0 -75
  575. package/lib/protocol-reexport.js.map +0 -1
  576. package/src/features/layout/layout-commands.ts +0 -424
  577. package/src/features/tool-palette/palette-item.ts +0 -38
  578. package/src/protocol-reexport.ts +0 -64
@@ -0,0 +1,486 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2019-2022 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import {
17
+ Action,
18
+ ChangeBoundsOperation,
19
+ ElementAndBounds,
20
+ hasArrayProp,
21
+ hasNumberProp,
22
+ hasStringProp,
23
+ SetBoundsAction,
24
+ Writable
25
+ } from '@eclipse-glsp/protocol';
26
+ import { inject, injectable, optional } from 'inversify';
27
+ import { ElementMove, IActionDispatcher, IActionHandler, ICommand, MoveAction, SModelElement } from 'sprotty';
28
+ import { TYPES } from '../../base/types';
29
+ import { toValidElementAndBounds, toValidElementMove } from '../../utils/layout-utils';
30
+ import { BoundsAwareModelElement, getElements } from '../../utils/smodel-util';
31
+ import { isBoundsAwareMoveable, isResizable } from '../change-bounds/model';
32
+ import { IMovementRestrictor } from '../change-bounds/movement-restrictor';
33
+ import { SelectionService } from '../select/selection-service';
34
+
35
+ /**
36
+ * Used to specify the desired resize dimension for a {@link ResizeElementsCommand}.
37
+ */
38
+ // eslint-disable-next-line no-shadow
39
+ export enum ResizeDimension {
40
+ Width,
41
+ Height,
42
+ Width_And_Height
43
+ }
44
+
45
+ /**
46
+ * A function that computes a single number from a set of given numbers
47
+ * i.e. it reduces the given numbers to one single number.
48
+ * Mainly used by the {@link ResizeElementsCommand} to reduce the given dimensions to a target dimension value.
49
+ */
50
+ export type ReduceFunction = (...values: number[]) => number;
51
+
52
+ export namespace ReduceFunction {
53
+ /**
54
+ * Returns the minimal value of the given numbers.
55
+ * @param values Numbers to be evaluated.
56
+ * @returns The reduced number.
57
+ */
58
+ export function min(...values: number[]): number {
59
+ return Math.min(...values);
60
+ }
61
+
62
+ /**
63
+ * Returns the maximal value of the given numbers.
64
+ * @param values Numbers to be evaluated.
65
+ * @returns The reduced number.
66
+ */
67
+ export function max(...values: number[]): number {
68
+ return Math.max(...values);
69
+ }
70
+
71
+ /**
72
+ * Computes the average of the given numbers.
73
+ * @param values Numbers to be evaluated.
74
+ */
75
+ export function avg(...values: number[]): number {
76
+ return values.reduce((a, b) => a + b, 0) / values.length;
77
+ }
78
+
79
+ /**
80
+ * Returns the last value of the given numbers.
81
+ * @param values Numbers to be evaluated.
82
+ * @returns The reduced number.
83
+ */
84
+ export function first(...values: number[]): number {
85
+ return values[0];
86
+ }
87
+
88
+ /**
89
+ * Returns the minimal value of the given numbers.
90
+ * @param values Numbers to be evaluated.
91
+ * @returns The reduced number.
92
+ */
93
+ export function last(...values: number[]): number {
94
+ return values[values.length - 1];
95
+ }
96
+
97
+ /**
98
+ * Returns the reduce function that corresponds to the given {@link ReduceFunctionType}.
99
+ * @param type The reduce function kind.
100
+ * @returns The corresponding reduce function.
101
+ */
102
+ export function get(type: ReduceFunctionType): ReduceFunction {
103
+ return ReduceFunction[type];
104
+ }
105
+ }
106
+
107
+ /** Union type of all {@link ReduceFunction} keys. */
108
+ export type ReduceFunctionType = Exclude<keyof typeof ReduceFunction, 'get'>;
109
+
110
+ export interface ResizeElementsAction extends Action {
111
+ kind: typeof ResizeElementsAction.KIND;
112
+
113
+ /**
114
+ * IDs of the elements that should be resized. If no IDs are given, the selected elements will be resized.
115
+ */
116
+ elementIds: string[];
117
+
118
+ /**
119
+ * Resize dimension. The default is {@link ResizeDimension.Width}.
120
+ */
121
+ dimension: ResizeDimension;
122
+
123
+ /**
124
+ * Type of the {@link ReduceFunction} that should be used to reduce the dimension to a target dimension value
125
+ */
126
+ reduceFunction: ReduceFunctionType;
127
+ }
128
+
129
+ export namespace ResizeElementsAction {
130
+ export const KIND = 'resizeElementAction';
131
+
132
+ export function is(object: any): object is ResizeElementsAction {
133
+ return (
134
+ Action.hasKind(object, KIND) &&
135
+ hasArrayProp(object, 'elementIds') &&
136
+ hasNumberProp(object, 'dimension') &&
137
+ hasStringProp(object, 'reduceFunction')
138
+ );
139
+ }
140
+
141
+ export function create(options: {
142
+ elementIds?: string[];
143
+ dimension?: ResizeDimension;
144
+ reduceFunction: ReduceFunctionType;
145
+ }): ResizeElementsAction {
146
+ return {
147
+ kind: KIND,
148
+ dimension: ResizeDimension.Width,
149
+ elementIds: [],
150
+ ...options
151
+ };
152
+ }
153
+ }
154
+
155
+ @injectable()
156
+ export abstract class LayoutElementsActionHandler implements IActionHandler {
157
+ @inject(TYPES.IActionDispatcher)
158
+ protected actionDispatcher: IActionDispatcher;
159
+
160
+ @inject(TYPES.SelectionService)
161
+ protected selectionService: SelectionService;
162
+
163
+ @inject(TYPES.IMovementRestrictor)
164
+ @optional()
165
+ protected movementRestrictor?: IMovementRestrictor;
166
+
167
+ abstract handle(action: Action): void | Action | ICommand;
168
+
169
+ getSelectedElements(selection: { elementIds: string[] }): BoundsAwareModelElement[] {
170
+ const index = this.selectionService.getModelRoot().index;
171
+ const selectedElements = selection.elementIds.length > 0 ? selection.elementIds : this.selectionService.getSelectedElementIDs();
172
+ return getElements(index, selectedElements, this.isActionElement);
173
+ }
174
+
175
+ protected abstract isActionElement(element: SModelElement): element is BoundsAwareModelElement;
176
+
177
+ dispatchAction(action: Action): void {
178
+ this.actionDispatcher.dispatch(action);
179
+ }
180
+
181
+ dispatchActions(actions: Action[]): void {
182
+ this.actionDispatcher.dispatchAll(actions);
183
+ }
184
+ }
185
+
186
+ @injectable()
187
+ export class ResizeElementsActionHandler extends LayoutElementsActionHandler {
188
+ handle(action: ResizeElementsAction): void {
189
+ const elements = this.getSelectedElements(action);
190
+ if (elements.length > 1) {
191
+ const reduceFn = ReduceFunction.get(action.reduceFunction);
192
+ switch (action.dimension) {
193
+ case ResizeDimension.Width:
194
+ return this.resizeWidth(elements, reduceFn);
195
+ case ResizeDimension.Height:
196
+ return this.resizeHeight(elements, reduceFn);
197
+ case ResizeDimension.Width_And_Height:
198
+ return this.resizeWidthAndHeight(elements, reduceFn);
199
+ }
200
+ }
201
+ }
202
+
203
+ resizeWidth(elements: BoundsAwareModelElement[], reduceFn: ReduceFunction): void {
204
+ const targetWidth = reduceFn(...elements.map(element => element.bounds.width));
205
+ this.dispatchResizeActions(elements, (element, bounds) => {
206
+ // resize around center (horizontal)
207
+ const halfDiffWidth = 0.5 * (targetWidth - element.bounds.width);
208
+ bounds.newPosition!.x = element.bounds.x - halfDiffWidth;
209
+ bounds.newSize.width = targetWidth;
210
+ });
211
+ }
212
+
213
+ resizeHeight(elements: BoundsAwareModelElement[], reduceFn: ReduceFunction): void {
214
+ const targetHeight = reduceFn(...elements.map(element => element.bounds.height));
215
+ this.dispatchResizeActions(elements, (element, bounds) => {
216
+ // resize around middle (vertical)
217
+ const halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
218
+ bounds.newPosition!.y = element.bounds.y - halfDiffHeight;
219
+ bounds.newSize.height = targetHeight;
220
+ });
221
+ }
222
+
223
+ resizeWidthAndHeight(elements: BoundsAwareModelElement[], reduceFn: ReduceFunction): void {
224
+ const targetWidth = reduceFn(...elements.map(element => element.bounds.width));
225
+ const targetHeight = reduceFn(...elements.map(element => element.bounds.height));
226
+ this.dispatchResizeActions(elements, (element, bounds) => {
227
+ // resize around center and middle (horizontal & vertical)
228
+ const halfDiffWidth = 0.5 * (targetWidth - element.bounds.width);
229
+ const halfDiffHeight = 0.5 * (targetHeight - element.bounds.height);
230
+ bounds.newPosition = { x: element.bounds.x - halfDiffWidth, y: element.bounds.y - halfDiffHeight };
231
+ bounds.newSize = { width: targetWidth, height: targetHeight };
232
+ });
233
+ }
234
+
235
+ dispatchResizeActions(
236
+ elements: BoundsAwareModelElement[],
237
+ change: (element: BoundsAwareModelElement, bounds: Writable<ElementAndBounds>) => void
238
+ ): void {
239
+ const elementAndBounds: ElementAndBounds[] = []; // client- and server-side resize
240
+
241
+ elements.forEach(element => {
242
+ const elementChange = this.createElementAndBounds(element, change);
243
+ if (elementChange) {
244
+ // simply skip invalid changes
245
+ elementAndBounds.push(elementChange);
246
+ }
247
+ });
248
+ this.dispatchActions([SetBoundsAction.create(elementAndBounds), ChangeBoundsOperation.create(elementAndBounds)]);
249
+ }
250
+
251
+ createElementAndBounds(
252
+ element: BoundsAwareModelElement,
253
+ change: (_element: BoundsAwareModelElement, _bounds: Writable<ElementAndBounds>) => void
254
+ ): Writable<ElementAndBounds> | undefined {
255
+ const bounds: ElementAndBounds = {
256
+ elementId: element.id,
257
+ newPosition: {
258
+ x: element.bounds.x,
259
+ y: element.bounds.y
260
+ },
261
+ newSize: {
262
+ width: element.bounds.width,
263
+ height: element.bounds.height
264
+ }
265
+ };
266
+ change(element, bounds);
267
+ return toValidElementAndBounds(element, bounds, this.movementRestrictor);
268
+ }
269
+ protected isActionElement(element: SModelElement): element is BoundsAwareModelElement {
270
+ return isResizable(element);
271
+ }
272
+ }
273
+
274
+ // eslint-disable-next-line no-shadow
275
+ export enum Alignment {
276
+ Left,
277
+ Center,
278
+ Right,
279
+ Top,
280
+ Middle,
281
+ Bottom
282
+ }
283
+
284
+ /**
285
+ * A function that retrieves a specific (sub)-selection of elements from a given set of elements.
286
+ * Mainly used by the {@link AlignElementsActionHandler}.
287
+ */
288
+ export type SelectFunction = (elements: BoundsAwareModelElement[]) => BoundsAwareModelElement[];
289
+ export namespace SelectFunction {
290
+ /**
291
+ * Select all elements from the given set of elements.
292
+ * @param elements The set of elements.
293
+ * @returns All elements.
294
+ */
295
+ export function all(elements: BoundsAwareModelElement[]): BoundsAwareModelElement[] {
296
+ return elements;
297
+ }
298
+
299
+ /**
300
+ * Select the first element from a given set of elements.
301
+ * @param elements The elements.
302
+ * @returns An array containing the first element of the given elements.
303
+ */
304
+ export function first(elements: BoundsAwareModelElement[]): BoundsAwareModelElement[] {
305
+ return [elements[0]];
306
+ }
307
+
308
+ /**
309
+ * Select the last element from a given set of elements.
310
+ * @param elements The elements.
311
+ * @returns An array containing the last element of the given elements.
312
+ */
313
+ export function last(elements: BoundsAwareModelElement[]): BoundsAwareModelElement[] {
314
+ return [elements[elements.length - 1]];
315
+ }
316
+
317
+ /**
318
+ * Returns the select function that corresponds to the given {@link SelectFunctionType}.
319
+ * @param type The select function type.
320
+ * @returns The corresponding select function.
321
+ */
322
+ export function get(kind: SelectFunctionType): SelectFunction {
323
+ return SelectFunction[kind];
324
+ }
325
+ }
326
+
327
+ /** Union type of all {@link SelectFunction} keys. */
328
+ export type SelectFunctionType = Exclude<keyof typeof SelectFunction, 'get'>;
329
+
330
+ export interface AlignElementsAction extends Action {
331
+ kind: typeof AlignElementsAction.KIND;
332
+
333
+ /**
334
+ * IDs of the elements that should be aligned. If no IDs are given, the selected elements will be aligned.
335
+ */
336
+ elementIds: string[];
337
+ /**
338
+ * Alignment direction. The default is {@link Alignment.Left}
339
+ */
340
+ alignment: Alignment;
341
+ /**
342
+ * Function to selected elements that are considered during alignment calculation.
343
+ * The default value is {@link Select.all}.
344
+ */
345
+ selectFunction: SelectFunctionType;
346
+ }
347
+
348
+ export namespace AlignElementsAction {
349
+ export const KIND = 'alignElements';
350
+
351
+ export function is(object: any): object is AlignElementsAction {
352
+ return (
353
+ Action.hasKind(object, KIND) &&
354
+ hasArrayProp(object, 'elementIds') &&
355
+ hasNumberProp(object, 'alignment') &&
356
+ hasStringProp(object, 'selectFunction')
357
+ );
358
+ }
359
+
360
+ export function create(
361
+ options: { elementIds?: string[]; alignment?: Alignment; selectionFunction?: SelectFunctionType } = {}
362
+ ): AlignElementsAction {
363
+ return {
364
+ kind: KIND,
365
+ elementIds: [],
366
+ alignment: Alignment.Left,
367
+ selectFunction: 'all',
368
+ ...options
369
+ };
370
+ }
371
+ }
372
+
373
+ @injectable()
374
+ export class AlignElementsActionHandler extends LayoutElementsActionHandler {
375
+ handle(action: AlignElementsAction): void {
376
+ const elements = this.getSelectedElements(action);
377
+ const selectFn = SelectFunction.get(action.selectFunction);
378
+ const calculatedElements = selectFn(elements);
379
+ if (elements.length > 1) {
380
+ switch (action.alignment) {
381
+ case Alignment.Left:
382
+ return this.alignLeft(calculatedElements);
383
+ case Alignment.Center:
384
+ return this.alignCenter(calculatedElements);
385
+ case Alignment.Right:
386
+ return this.alignRight(calculatedElements);
387
+ case Alignment.Top:
388
+ return this.alignTop(calculatedElements);
389
+ case Alignment.Middle:
390
+ return this.alignMiddle(calculatedElements);
391
+ case Alignment.Bottom:
392
+ return this.alignBottom(calculatedElements);
393
+ }
394
+ }
395
+ }
396
+
397
+ alignLeft(elements: BoundsAwareModelElement[]): void {
398
+ const minX = elements.map(element => element.bounds.x).reduce((a, b) => Math.min(a, b));
399
+ this.dispatchAlignActions(elements, (_, move) => (move.toPosition.x = minX));
400
+ }
401
+
402
+ alignCenter(elements: BoundsAwareModelElement[]): void {
403
+ const minX = elements.map(element => element.bounds.x).reduce((a, b) => Math.min(a, b));
404
+ const maxX = elements.map(element => element.bounds.x + element.bounds.width).reduce((a, b) => Math.max(a, b));
405
+ const diffX = maxX - minX;
406
+ const centerX = minX + 0.5 * diffX;
407
+ this.dispatchAlignActions(elements, (element, move) => (move.toPosition.x = centerX - 0.5 * element.bounds.width));
408
+ }
409
+
410
+ alignRight(elements: BoundsAwareModelElement[]): void {
411
+ const maxX = elements.map(element => element.bounds.x + element.bounds.width).reduce((a, b) => Math.max(a, b));
412
+ this.dispatchAlignActions(elements, (element, move) => (move.toPosition.x = maxX - element.bounds.width));
413
+ }
414
+
415
+ alignTop(elements: BoundsAwareModelElement[]): void {
416
+ const minY = elements.map(element => element.bounds.y).reduce((a, b) => Math.min(a, b));
417
+ this.dispatchAlignActions(elements, (_, move) => (move.toPosition.y = minY));
418
+ }
419
+
420
+ alignMiddle(elements: BoundsAwareModelElement[]): void {
421
+ const minY = elements.map(element => element.bounds.y).reduce((a, b) => Math.min(a, b));
422
+ const maxY = elements.map(element => element.bounds.y + element.bounds.height).reduce((a, b) => Math.max(a, b));
423
+ const diffY = maxY - minY;
424
+ const middleY = minY + 0.5 * diffY;
425
+ this.dispatchAlignActions(elements, (element, move) => (move.toPosition.y = middleY - 0.5 * element.bounds.height));
426
+ }
427
+
428
+ alignBottom(elements: BoundsAwareModelElement[]): void {
429
+ const maxY = elements.map(element => element.bounds.y + element.bounds.height).reduce((a, b) => Math.max(a, b));
430
+ this.dispatchAlignActions(elements, (element, move) => (move.toPosition.y = maxY - element.bounds.height));
431
+ }
432
+
433
+ dispatchAlignActions(
434
+ elements: BoundsAwareModelElement[],
435
+ change: (element: BoundsAwareModelElement, move: Writable<ElementMove>) => void
436
+ ): void {
437
+ const moves: ElementMove[] = []; // client-side move
438
+ const elementAndBounds: ElementAndBounds[] = []; // server-side move
439
+ elements.forEach(element => {
440
+ const move = this.createElementMove(element, change);
441
+ if (move) {
442
+ // simply skip invalid changes
443
+ moves.push(move);
444
+ const elementAndBound = this.createElementAndBounds(element, move);
445
+ elementAndBounds.push(elementAndBound);
446
+ }
447
+ });
448
+ this.dispatchActions([MoveAction.create(moves), ChangeBoundsOperation.create(elementAndBounds)]);
449
+ }
450
+
451
+ createElementMove(
452
+ element: BoundsAwareModelElement,
453
+ change: (_element: BoundsAwareModelElement, _move: Writable<ElementMove>) => void
454
+ ): Writable<ElementMove> | undefined {
455
+ const move: ElementMove = {
456
+ elementId: element.id,
457
+ fromPosition: {
458
+ x: element.bounds.x,
459
+ y: element.bounds.y
460
+ },
461
+ toPosition: {
462
+ x: element.bounds.x,
463
+ y: element.bounds.y
464
+ }
465
+ };
466
+ change(element, move);
467
+ return toValidElementMove(element, move, this.movementRestrictor);
468
+ }
469
+
470
+ createElementAndBounds(element: BoundsAwareModelElement, move: ElementMove): ElementAndBounds {
471
+ return {
472
+ elementId: element.id,
473
+ newPosition: {
474
+ x: move.toPosition.x,
475
+ y: move.toPosition.y
476
+ },
477
+ newSize: {
478
+ width: element.bounds.width,
479
+ height: element.bounds.height
480
+ }
481
+ };
482
+ }
483
+ protected isActionElement(element: SModelElement): element is BoundsAwareModelElement {
484
+ return isBoundsAwareMoveable(element);
485
+ }
486
+ }
@@ -0,0 +1,137 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import {
17
+ BoundsData,
18
+ ILogger,
19
+ LayoutRegistry,
20
+ StatefulLayouter,
21
+ SModelElement,
22
+ Layouter,
23
+ SParentElement,
24
+ LayoutContainer,
25
+ isLayoutContainer
26
+ } from 'sprotty';
27
+ import { injectable } from 'inversify';
28
+ import { Bounds } from 'sprotty-protocol/lib/utils/geometry';
29
+
30
+ @injectable()
31
+ export class LayouterExt extends Layouter {
32
+ override layout(element2boundsData: Map<SModelElement, BoundsData>): void {
33
+ new StatefulLayouterExt(element2boundsData, this.layoutRegistry, this.logger).layout();
34
+ }
35
+ }
36
+
37
+ // 2-pass layout:
38
+ // Step 1: Find "rendered size" of each element (may take resizeContainer into account)
39
+ // Child-to-parent layout
40
+ // Step 2: Extend parents as necessary, then use the adjusted parent size to properly
41
+ // align children (center/end alignments, hGrab/vGrab)
42
+ // Parent-to-children layout
43
+
44
+ export class StatefulLayouterExt extends StatefulLayouter {
45
+ protected toBeLayouted2: (SParentElement & LayoutContainer)[];
46
+
47
+ /**
48
+ *
49
+ * @param elementToBoundsData The map of element to bounds data. Bounds Data are computed from the hidden
50
+ * SVG rendering pass.
51
+ * @param layoutRegistry2 The registry of available layouts.
52
+ * @param log The log.
53
+ */
54
+ constructor(
55
+ protected readonly elementToBoundsData: Map<SModelElement, BoundsData>,
56
+ protected readonly layoutRegistry2: LayoutRegistry,
57
+ log: ILogger
58
+ ) {
59
+ super(elementToBoundsData, layoutRegistry2, log);
60
+ this.toBeLayouted2 = [];
61
+ elementToBoundsData.forEach((data, element) => {
62
+ if (isLayoutContainer(element)) {
63
+ this.toBeLayouted2.push(element);
64
+ }
65
+ });
66
+ for (const element of this.toBeLayouted2) {
67
+ // Clear previous layout information for dynamic-layout objects
68
+ elementToBoundsData.delete(element);
69
+ }
70
+ }
71
+
72
+ override getBoundsData(element: SModelElement): BoundsData {
73
+ let boundsData = this.elementToBoundsData.get(element);
74
+ let bounds = (element as any).bounds;
75
+ if (isLayoutContainer(element) && this.toBeLayouted2.indexOf(element) >= 0) {
76
+ bounds = this.doLayout(element);
77
+ } else if (isLayoutContainer(element)) {
78
+ bounds = {
79
+ x: 0,
80
+ y: 0,
81
+ width: -1,
82
+ height: -1
83
+ };
84
+ }
85
+ if (!boundsData) {
86
+ boundsData = {
87
+ bounds: bounds,
88
+ boundsChanged: false,
89
+ alignmentChanged: false
90
+ };
91
+ this.elementToBoundsData.set(element, boundsData);
92
+ }
93
+ return boundsData;
94
+ }
95
+
96
+ override layout(): void {
97
+ // First pass: apply layout with cleared container data. Will get
98
+ // preferred size for all elements (Children first, then parents)
99
+ while (this.toBeLayouted2.length > 0) {
100
+ const element = this.toBeLayouted2[0];
101
+ this.doLayout(element);
102
+ }
103
+
104
+ this.toBeLayouted2 = [];
105
+ this.elementToBoundsData.forEach((data, element) => {
106
+ if (isLayoutContainer(element)) {
107
+ this.toBeLayouted2.push(element);
108
+ }
109
+ });
110
+
111
+ // Second pass: apply layout with initial size data for all
112
+ // nodes. Update the position/size of all elements, taking
113
+ // vGrab/hGrab into account (parent -> children).
114
+ while (this.toBeLayouted2.length > 0) {
115
+ const element = this.toBeLayouted2[0];
116
+ this.doLayout(element);
117
+ }
118
+ }
119
+
120
+ protected override doLayout(element: SParentElement & LayoutContainer): Bounds {
121
+ const index = this.toBeLayouted2.indexOf(element);
122
+ if (index >= 0) {
123
+ this.toBeLayouted2.splice(index, 1);
124
+ }
125
+ const layout = this.layoutRegistry2.get(element.layout);
126
+ if (layout) {
127
+ layout.layout(element, this);
128
+ }
129
+ const boundsData = this.elementToBoundsData.get(element);
130
+ if (boundsData !== undefined && boundsData.bounds !== undefined) {
131
+ return boundsData.bounds;
132
+ } else {
133
+ this.log.error(element, 'Layout failed');
134
+ return Bounds.EMPTY;
135
+ }
136
+ }
137
+ }