@eclipse-glsp/client 2.8.0-next.8 → 2.8.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 (279) hide show
  1. package/README.md +1 -1
  2. package/css/grid.css +2 -1
  3. package/lib/base/action-dispatcher.js +1 -4
  4. package/lib/base/action-dispatcher.js.map +1 -1
  5. package/lib/base/auto-complete/auto-complete-widget.js +4 -8
  6. package/lib/base/auto-complete/auto-complete-widget.js.map +1 -1
  7. package/lib/base/auto-complete/base-autocomplete-palette.js +1 -2
  8. package/lib/base/auto-complete/base-autocomplete-palette.js.map +1 -1
  9. package/lib/base/editor-context-service.js +4 -7
  10. package/lib/base/editor-context-service.js.map +1 -1
  11. package/lib/base/feedback/css-feedback.js +1 -1
  12. package/lib/base/feedback/css-feedback.js.map +1 -1
  13. package/lib/base/feedback/feedback-action-dispatcher.js +4 -6
  14. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  15. package/lib/base/feedback/feedback-command.js +1 -2
  16. package/lib/base/feedback/feedback-command.js.map +1 -1
  17. package/lib/base/feedback/feedback-emitter.js +1 -2
  18. package/lib/base/feedback/feedback-emitter.js.map +1 -1
  19. package/lib/base/feedback/set-model-command.js +1 -2
  20. package/lib/base/feedback/set-model-command.js.map +1 -1
  21. package/lib/base/feedback/update-model-command.js +1 -2
  22. package/lib/base/feedback/update-model-command.js.map +1 -1
  23. package/lib/base/model/diagram-loader.js +4 -6
  24. package/lib/base/model/diagram-loader.js.map +1 -1
  25. package/lib/base/model/glsp-model-source.d.ts +1 -1
  26. package/lib/base/model/glsp-model-source.d.ts.map +1 -1
  27. package/lib/base/model/glsp-model-source.js +3 -5
  28. package/lib/base/model/glsp-model-source.js.map +1 -1
  29. package/lib/base/model/model-registry.js +1 -2
  30. package/lib/base/model/model-registry.js.map +1 -1
  31. package/lib/base/selection-service.js +3 -3
  32. package/lib/base/selection-service.js.map +1 -1
  33. package/lib/base/shortcuts/available-shortcuts-extension.js +3 -2
  34. package/lib/base/shortcuts/available-shortcuts-extension.js.map +1 -1
  35. package/lib/base/shortcuts/available-shortcuts-tool.js +3 -2
  36. package/lib/base/shortcuts/available-shortcuts-tool.js.map +1 -1
  37. package/lib/base/tool-manager/tool-manager.js +1 -1
  38. package/lib/base/tool-manager/tool-manager.js.map +1 -1
  39. package/lib/base/ui-extension/ui-extension.js +4 -6
  40. package/lib/base/ui-extension/ui-extension.js.map +1 -1
  41. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js +12 -17
  42. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-palette.js.map +1 -1
  43. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js +3 -2
  44. package/lib/features/accessibility/edge-autocomplete/edge-autocomplete-tool.js.map +1 -1
  45. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +11 -15
  46. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -1
  47. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js +2 -3
  48. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js.map +1 -1
  49. package/lib/features/accessibility/element-navigation/local-element-navigator.js +2 -3
  50. package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -1
  51. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js +5 -4
  52. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js.map +1 -1
  53. package/lib/features/accessibility/global-keylistener-tool.js +4 -3
  54. package/lib/features/accessibility/global-keylistener-tool.js.map +1 -1
  55. package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js +3 -2
  56. package/lib/features/accessibility/keyboard-grid/keyboard-grid-search-palette.js.map +1 -1
  57. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js +5 -7
  58. package/lib/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.js.map +1 -1
  59. package/lib/features/accessibility/toast/toast-handler.js +2 -4
  60. package/lib/features/accessibility/toast/toast-handler.js.map +1 -1
  61. package/lib/features/accessibility/toast/toast-tool.js +3 -2
  62. package/lib/features/accessibility/toast/toast-tool.js.map +1 -1
  63. package/lib/features/accessibility/view-key-tools/deselect-key-tool.js +3 -2
  64. package/lib/features/accessibility/view-key-tools/deselect-key-tool.js.map +1 -1
  65. package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js +4 -3
  66. package/lib/features/accessibility/view-key-tools/grid-cell-zoom-key-tool.js.map +1 -1
  67. package/lib/features/bounds/freeform-layout.js +1 -1
  68. package/lib/features/bounds/freeform-layout.js.map +1 -1
  69. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts +31 -1
  70. package/lib/features/bounds/glsp-hidden-bounds-updater.d.ts.map +1 -1
  71. package/lib/features/bounds/glsp-hidden-bounds-updater.js +119 -58
  72. package/lib/features/bounds/glsp-hidden-bounds-updater.js.map +1 -1
  73. package/lib/features/bounds/hbox-layout.js +7 -10
  74. package/lib/features/bounds/hbox-layout.js.map +1 -1
  75. package/lib/features/bounds/layout-data.js +2 -4
  76. package/lib/features/bounds/layout-data.js.map +1 -1
  77. package/lib/features/bounds/local-bounds.js +3 -4
  78. package/lib/features/bounds/local-bounds.js.map +1 -1
  79. package/lib/features/bounds/set-bounds-feedback-command.js +2 -3
  80. package/lib/features/bounds/set-bounds-feedback-command.js.map +1 -1
  81. package/lib/features/bounds/vbox-layout.js +7 -10
  82. package/lib/features/bounds/vbox-layout.js.map +1 -1
  83. package/lib/features/change-bounds/model.js +1 -1
  84. package/lib/features/change-bounds/model.js.map +1 -1
  85. package/lib/features/change-bounds/move-element-handler.js +1 -2
  86. package/lib/features/change-bounds/move-element-handler.js.map +1 -1
  87. package/lib/features/change-bounds/movement-restrictor.js +1 -2
  88. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  89. package/lib/features/change-bounds/point-position-updater.js +1 -1
  90. package/lib/features/change-bounds/point-position-updater.js.map +1 -1
  91. package/lib/features/change-bounds/resize/resize-default-tool.js +4 -3
  92. package/lib/features/change-bounds/resize/resize-default-tool.js.map +1 -1
  93. package/lib/features/change-bounds/resize/resize-handler.js +1 -2
  94. package/lib/features/change-bounds/resize/resize-handler.js.map +1 -1
  95. package/lib/features/change-bounds/resize/resize-tool.js +4 -3
  96. package/lib/features/change-bounds/resize/resize-tool.js.map +1 -1
  97. package/lib/features/change-bounds/tracker.js +1 -2
  98. package/lib/features/change-bounds/tracker.js.map +1 -1
  99. package/lib/features/command-palette/command-palette-tool.js +3 -2
  100. package/lib/features/command-palette/command-palette-tool.js.map +1 -1
  101. package/lib/features/command-palette/command-palette.js +2 -3
  102. package/lib/features/command-palette/command-palette.js.map +1 -1
  103. package/lib/features/context-menu/glsp-context-menu-mouse-listener.js +2 -3
  104. package/lib/features/context-menu/glsp-context-menu-mouse-listener.js.map +1 -1
  105. package/lib/features/copy-paste/copy-paste-handler.d.ts +1 -1
  106. package/lib/features/copy-paste/copy-paste-handler.d.ts.map +1 -1
  107. package/lib/features/copy-paste/copy-paste-handler.js +3 -5
  108. package/lib/features/copy-paste/copy-paste-handler.js.map +1 -1
  109. package/lib/features/copy-paste/copy-paste-standalone.js +6 -9
  110. package/lib/features/copy-paste/copy-paste-standalone.js.map +1 -1
  111. package/lib/features/debug/debug-bounds-decorator.js +9 -12
  112. package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
  113. package/lib/features/debug/debug-model.js +1 -1
  114. package/lib/features/debug/debug-model.js.map +1 -1
  115. package/lib/features/decoration/decoration-placer.js +3 -2
  116. package/lib/features/decoration/decoration-placer.js.map +1 -1
  117. package/lib/features/element-template/add-template-element.d.ts +6 -1
  118. package/lib/features/element-template/add-template-element.d.ts.map +1 -1
  119. package/lib/features/element-template/add-template-element.js +17 -5
  120. package/lib/features/element-template/add-template-element.js.map +1 -1
  121. package/lib/features/element-template/mouse-tracking-element-position-listener.js +1 -1
  122. package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
  123. package/lib/features/element-template/remove-template-element.js +1 -1
  124. package/lib/features/element-template/remove-template-element.js.map +1 -1
  125. package/lib/features/export/default-png-diagram-exporter.js +4 -7
  126. package/lib/features/export/default-png-diagram-exporter.js.map +1 -1
  127. package/lib/features/export/diagram-export-postprocessor.js +1 -2
  128. package/lib/features/export/diagram-export-postprocessor.js.map +1 -1
  129. package/lib/features/export/glsp-svg-exporter.d.ts.map +1 -1
  130. package/lib/features/export/glsp-svg-exporter.js +5 -6
  131. package/lib/features/export/glsp-svg-exporter.js.map +1 -1
  132. package/lib/features/export/request-export-command.js +1 -1
  133. package/lib/features/export/request-export-command.js.map +1 -1
  134. package/lib/features/grid/grid-model.js +1 -1
  135. package/lib/features/grid/grid-model.js.map +1 -1
  136. package/lib/features/helper-lines/helper-line-feedback.js +7 -8
  137. package/lib/features/helper-lines/helper-line-feedback.js.map +1 -1
  138. package/lib/features/helper-lines/model.d.ts +1 -1
  139. package/lib/features/helper-lines/model.d.ts.map +1 -1
  140. package/lib/features/helper-lines/model.js +3 -4
  141. package/lib/features/helper-lines/model.js.map +1 -1
  142. package/lib/features/hints/type-hint-provider.js +3 -5
  143. package/lib/features/hints/type-hint-provider.js.map +1 -1
  144. package/lib/features/label-edit/edit-label-tool.js +3 -2
  145. package/lib/features/label-edit/edit-label-tool.js.map +1 -1
  146. package/lib/features/label-edit-ui/label-edit-ui.js +2 -3
  147. package/lib/features/label-edit-ui/label-edit-ui.js.map +1 -1
  148. package/lib/features/navigation/navigation-target-resolver.js +1 -1
  149. package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
  150. package/lib/features/routing/sticky-manhattan-anchors.js +9 -6
  151. package/lib/features/routing/sticky-manhattan-anchors.js.map +1 -1
  152. package/lib/features/routing/sticky-manhattan-edge-router.js +10 -12
  153. package/lib/features/routing/sticky-manhattan-edge-router.js.map +1 -1
  154. package/lib/features/search-palette/search-palette.js +3 -2
  155. package/lib/features/search-palette/search-palette.js.map +1 -1
  156. package/lib/features/search-palette/suggestions/edge-element-suggestions.js +2 -3
  157. package/lib/features/search-palette/suggestions/edge-element-suggestions.js.map +1 -1
  158. package/lib/features/search-palette/suggestions/named-element-suggestions.js +8 -11
  159. package/lib/features/search-palette/suggestions/named-element-suggestions.js.map +1 -1
  160. package/lib/features/select/select-feedback-command.js +1 -1
  161. package/lib/features/select/select-feedback-command.js.map +1 -1
  162. package/lib/features/select/select-mouse-listener.js +1 -2
  163. package/lib/features/select/select-mouse-listener.js.map +1 -1
  164. package/lib/features/status/status-overlay.js +4 -4
  165. package/lib/features/status/status-overlay.js.map +1 -1
  166. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  167. package/lib/features/tool-palette/tool-palette.js +16 -23
  168. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  169. package/lib/features/tools/change-bounds/change-bounds-manager.js +4 -6
  170. package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
  171. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -4
  172. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
  173. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +4 -8
  174. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
  175. package/lib/features/tools/change-bounds/change-bounds-tool.js +6 -6
  176. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  177. package/lib/features/tools/change-bounds/change-bounds-tracker.js +7 -10
  178. package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
  179. package/lib/features/tools/deletion/delete-tool.js +6 -4
  180. package/lib/features/tools/deletion/delete-tool.js.map +1 -1
  181. package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts +1 -1
  182. package/lib/features/tools/edge-creation/dangling-edge-feedback.d.ts.map +1 -1
  183. package/lib/features/tools/edge-creation/dangling-edge-feedback.js +7 -5
  184. package/lib/features/tools/edge-creation/dangling-edge-feedback.js.map +1 -1
  185. package/lib/features/tools/edge-creation/edge-creation-tool.js +5 -6
  186. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  187. package/lib/features/tools/edge-creation/view.js +1 -2
  188. package/lib/features/tools/edge-creation/view.js.map +1 -1
  189. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +1 -1
  190. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
  191. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +8 -5
  192. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
  193. package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -2
  194. package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
  195. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +3 -2
  196. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
  197. package/lib/features/tools/marquee-selection/marquee-tool-feedback.js +2 -2
  198. package/lib/features/tools/marquee-selection/marquee-tool-feedback.js.map +1 -1
  199. package/lib/features/tools/marquee-selection/marquee-tool.js +3 -2
  200. package/lib/features/tools/marquee-selection/marquee-tool.js.map +1 -1
  201. package/lib/features/tools/marquee-selection/model.d.ts +1 -1
  202. package/lib/features/tools/marquee-selection/model.d.ts.map +1 -1
  203. package/lib/features/tools/marquee-selection/model.js +3 -2
  204. package/lib/features/tools/marquee-selection/model.js.map +1 -1
  205. package/lib/features/tools/node-creation/container-manager.js +3 -4
  206. package/lib/features/tools/node-creation/container-manager.js.map +1 -1
  207. package/lib/features/tools/node-creation/insert-indicator.d.ts +1 -1
  208. package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -1
  209. package/lib/features/tools/node-creation/insert-indicator.js +5 -5
  210. package/lib/features/tools/node-creation/insert-indicator.js.map +1 -1
  211. package/lib/features/tools/node-creation/node-creation-tool.js +5 -6
  212. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  213. package/lib/features/tools/node-creation/node-creation-views.js +1 -2
  214. package/lib/features/tools/node-creation/node-creation-views.js.map +1 -1
  215. package/lib/features/validation/issue-marker.d.ts +2 -2
  216. package/lib/features/validation/issue-marker.d.ts.map +1 -1
  217. package/lib/features/validation/issue-marker.js +7 -2
  218. package/lib/features/validation/issue-marker.js.map +1 -1
  219. package/lib/features/validation/marker-navigator.js +1 -1
  220. package/lib/features/validation/marker-navigator.js.map +1 -1
  221. package/lib/features/validation/validate.js +4 -6
  222. package/lib/features/validation/validate.js.map +1 -1
  223. package/lib/features/viewport/origin-viewport.js +1 -1
  224. package/lib/features/viewport/origin-viewport.js.map +1 -1
  225. package/lib/features/viewport/reposition.js +2 -3
  226. package/lib/features/viewport/reposition.js.map +1 -1
  227. package/lib/features/viewport/viewport-handler.js +2 -3
  228. package/lib/features/viewport/viewport-handler.js.map +1 -1
  229. package/lib/features/viewport/viewport-tool.js +4 -3
  230. package/lib/features/viewport/viewport-tool.js.map +1 -1
  231. package/lib/features/zorder/bring-to-front-command.js +1 -2
  232. package/lib/features/zorder/bring-to-front-command.js.map +1 -1
  233. package/lib/model.js +2 -2
  234. package/lib/model.js.map +1 -1
  235. package/lib/utils/argument-utils.js +5 -5
  236. package/lib/utils/argument-utils.js.map +1 -1
  237. package/lib/utils/gmodel-util.d.ts +13 -1
  238. package/lib/utils/gmodel-util.d.ts.map +1 -1
  239. package/lib/utils/gmodel-util.js +15 -7
  240. package/lib/utils/gmodel-util.js.map +1 -1
  241. package/lib/utils/layout-utils.js +1 -2
  242. package/lib/utils/layout-utils.js.map +1 -1
  243. package/lib/views/glsp-projection-view.js +1 -2
  244. package/lib/views/glsp-projection-view.js.map +1 -1
  245. package/package.json +18 -17
  246. package/src/base/feedback/feedback-command.ts +1 -1
  247. package/src/base/model/glsp-model-source.ts +1 -1
  248. package/src/features/accessibility/README.md +5 -5
  249. package/src/features/accessibility/keyboard-tool-palette/keyboard-tool-palette.ts +1 -1
  250. package/src/features/bounds/glsp-hidden-bounds-updater.ts +133 -60
  251. package/src/features/copy-paste/copy-paste-handler.ts +3 -3
  252. package/src/features/element-template/add-template-element.ts +17 -2
  253. package/src/features/export/glsp-svg-exporter.ts +2 -2
  254. package/src/features/helper-lines/model.ts +4 -5
  255. package/src/features/tool-palette/tool-palette.ts +2 -4
  256. package/src/features/tools/edge-creation/dangling-edge-feedback.ts +4 -2
  257. package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +5 -3
  258. package/src/features/tools/marquee-selection/model.ts +3 -2
  259. package/src/features/tools/node-creation/insert-indicator.ts +5 -5
  260. package/src/features/validation/issue-marker.ts +7 -2
  261. package/src/utils/gmodel-util.ts +23 -1
  262. package/src/base/action-dispatcher.spec.ts +0 -366
  263. package/src/base/feedback/feedback-emitter.spec.ts +0 -176
  264. package/src/base/model/model-initialization-constraint.spec.ts +0 -95
  265. package/src/base/selection-service.spec.ts +0 -318
  266. package/src/default-modules.spec.ts +0 -56
  267. package/src/features/bounds/freeform-layout.spec.ts +0 -216
  268. package/src/features/bounds/hbox-layout.spec.ts +0 -170
  269. package/src/features/bounds/layouter-test-util.spec.ts +0 -127
  270. package/src/features/bounds/vbox-layout.spec.ts +0 -170
  271. package/src/features/change-bounds/point-position-updater.spec.ts +0 -81
  272. package/src/features/grid/grid-snapper.spec.ts +0 -30
  273. package/src/features/hints/type-hint-provider.spec.ts +0 -360
  274. package/src/features/layout/layout-elements-action.spec.ts +0 -426
  275. package/src/features/navigation/navigation-target-resolver.spec.ts +0 -56
  276. package/src/features/routing/sticky-manhattan-edge-router.spec.ts +0 -212
  277. package/src/features/tools/marquee-selection/marquee-behavior.spec.ts +0 -176
  278. package/src/features/validation/marker-navigator.spec.ts +0 -183
  279. package/src/utils/gmodel-util.spec.ts +0 -221
@@ -1,170 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2026 TypeFox, STMicroelectronics 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
-
17
- import { expect } from 'chai';
18
- import 'mocha';
19
- import 'reflect-metadata';
20
- import { BoundsData, ConsoleLogger, Dimension, GModelElement, GNode } from '@eclipse-glsp/sprotty';
21
- import { createLabel, createNode, layout, setupLayoutRegistry } from './layouter-test-util.spec';
22
-
23
- describe('HBoxLayouter', () => {
24
- const layoutRegistry = setupLayoutRegistry();
25
- const log = new ConsoleLogger();
26
- const map = new Map<GModelElement, BoundsData>();
27
-
28
- function createModel(): GNode {
29
- const model = createNode('node', undefined, Dimension.EMPTY);
30
- model.children = [
31
- createLabel('label1', undefined, undefined, { width: 1, height: 2 }),
32
- createLabel('label2', undefined, undefined, { width: 2, height: 1 }),
33
- createLabel('label3', undefined, undefined, { width: 3, height: 3 })
34
- ];
35
- model.layout = 'hbox';
36
- return model;
37
- }
38
-
39
- it('defaultParams', () => {
40
- const model = createModel();
41
- layout(layoutRegistry, log, map, model);
42
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
43
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
44
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
45
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
46
- });
47
-
48
- it('alignTop', () => {
49
- const model = createModel();
50
- model.layoutOptions = {
51
- vAlign: 'top'
52
- };
53
- layout(layoutRegistry, log, map, model);
54
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
55
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5, width: 1, height: 2 });
56
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 5, width: 2, height: 1 });
57
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
58
- });
59
-
60
- it('alignCenter', () => {
61
- const model = createModel();
62
- model.layoutOptions = {
63
- vAlign: 'center'
64
- };
65
- layout(layoutRegistry, log, map, model);
66
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
67
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
68
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
69
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
70
- });
71
-
72
- it('alignBottom', () => {
73
- const model = createModel();
74
- model.layoutOptions = {
75
- vAlign: 'bottom'
76
- };
77
- layout(layoutRegistry, log, map, model);
78
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
79
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 6, width: 1, height: 2 });
80
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 7, width: 2, height: 1 });
81
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
82
- });
83
-
84
- it('padding', () => {
85
- const model = createModel();
86
- model.layoutOptions = {
87
- paddingTop: 7,
88
- paddingBottom: 8,
89
- paddingLeft: 9,
90
- paddingRight: 10
91
- };
92
- layout(layoutRegistry, log, map, model);
93
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 27, height: 18 });
94
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 7.5, width: 1, height: 2 });
95
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11, y: 8, width: 2, height: 1 });
96
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 14, y: 7, width: 3, height: 3 });
97
- });
98
-
99
- it('hGap', () => {
100
- const model = createModel();
101
- model.layoutOptions = {
102
- hGap: 4
103
- };
104
- layout(layoutRegistry, log, map, model);
105
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 24, height: 13 });
106
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
107
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 10, y: 6, width: 2, height: 1 });
108
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 16, y: 5, width: 3, height: 3 });
109
- });
110
-
111
- it('paddingFactor', () => {
112
- const model = createModel();
113
- model.layoutOptions = {
114
- paddingFactor: 2
115
- };
116
- layout(layoutRegistry, log, map, model);
117
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 13 });
118
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 8.5, width: 1, height: 2 });
119
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11, y: 9, width: 2, height: 1 });
120
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 14, y: 8, width: 3, height: 3 });
121
- });
122
-
123
- it('minWidth', () => {
124
- const model = createModel();
125
- model.layoutOptions = {
126
- minWidth: 25
127
- };
128
- layout(layoutRegistry, log, map, model);
129
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 25, height: 13 });
130
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
131
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
132
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
133
- });
134
-
135
- it('minHeight', () => {
136
- const model = createModel();
137
- model.layoutOptions = {
138
- minHeight: 25
139
- };
140
- layout(layoutRegistry, log, map, model);
141
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 25 });
142
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 11.5, width: 1, height: 2 });
143
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 12, width: 2, height: 1 });
144
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 11, width: 3, height: 3 });
145
- });
146
-
147
- it('prefWidth', () => {
148
- const model = createModel();
149
- model.layoutOptions = {
150
- prefWidth: 20
151
- };
152
- layout(layoutRegistry, log, map, model);
153
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 20, height: 13 });
154
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5.5, width: 1, height: 2 });
155
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 6, width: 2, height: 1 });
156
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 5, width: 3, height: 3 });
157
- });
158
-
159
- it('prefHeight', () => {
160
- const model = createModel();
161
- model.layoutOptions = {
162
- prefHeight: 20
163
- };
164
- layout(layoutRegistry, log, map, model);
165
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 18, height: 20 });
166
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 9, width: 1, height: 2 });
167
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 7, y: 9.5, width: 2, height: 1 });
168
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 10, y: 8.5, width: 3, height: 3 });
169
- });
170
- });
@@ -1,127 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2023 STMicroelectronics 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
-
17
- import { Container } from 'inversify';
18
- import 'mocha';
19
- import {
20
- BoundsData,
21
- ConsoleLogger,
22
- Dimension,
23
- LayoutRegistry,
24
- Point,
25
- GCompartment,
26
- GLabel,
27
- GModelElement,
28
- GNode,
29
- GParentElement,
30
- TYPES,
31
- createFeatureSet,
32
- layoutableChildFeature
33
- } from '@eclipse-glsp/sprotty';
34
- import { initializeDiagramContainer } from '../../default-modules';
35
- import { StatefulLayouterExt } from './layouter';
36
- import { GGraph } from '../../model';
37
-
38
- export function createGraph(): GGraph {
39
- return new GGraph();
40
- }
41
-
42
- export function createNode(
43
- type: string,
44
- nodeLayout?: string,
45
- size?: Dimension,
46
- position?: Point,
47
- layoutOptions?: { [key: string]: string | number | boolean }
48
- ): GNode {
49
- const node = new GNode();
50
- node.features = createFeatureSet(GNode.DEFAULT_FEATURES, { enable: [layoutableChildFeature] });
51
- node.position = position || {
52
- x: 0,
53
- y: 0
54
- };
55
- if (size) {
56
- node.size = size;
57
- }
58
- node.type = type;
59
- if (nodeLayout) {
60
- node.layout = nodeLayout;
61
- }
62
- node.layoutOptions = layoutOptions;
63
- return node;
64
- }
65
-
66
- export function createCompartment(
67
- type: string,
68
- compLayout: string,
69
- layoutOptions?: { [key: string]: string | number | boolean }
70
- ): GCompartment {
71
- const comp = new GCompartment();
72
- comp.features = createFeatureSet(GCompartment.DEFAULT_FEATURES);
73
- comp.type = type;
74
- comp.layout = compLayout;
75
- comp.layoutOptions = layoutOptions;
76
- return comp;
77
- }
78
-
79
- export function createLabel(
80
- labelText: string,
81
- layoutOptions?: { [key: string]: string | number | boolean },
82
- position?: Point,
83
- size?: Dimension
84
- ): GLabel {
85
- const label = new GLabel();
86
- label.features = createFeatureSet(GLabel.DEFAULT_FEATURES);
87
- if (position) {
88
- label.position = position;
89
- }
90
- if (size) {
91
- label.size = size;
92
- }
93
- label.layoutOptions = layoutOptions;
94
- label.text = labelText;
95
- label.type = 'label';
96
- return label;
97
- }
98
-
99
- export function addToMap(map: Map<GModelElement, BoundsData>, element: GModelElement): void {
100
- map.set(element, {
101
- bounds: (element as any).bounds,
102
- boundsChanged: true,
103
- alignmentChanged: true
104
- });
105
- if (element instanceof GParentElement) {
106
- element.children.forEach(c => addToMap(map, c));
107
- }
108
- }
109
-
110
- export function layout(
111
- layoutRegistry: LayoutRegistry,
112
- log: ConsoleLogger,
113
- map: Map<GModelElement, BoundsData>,
114
- model: GNode | GGraph
115
- ): void {
116
- map.clear();
117
- addToMap(map, model);
118
- const layouter = new StatefulLayouterExt(map, layoutRegistry, log);
119
- layouter.layout();
120
- }
121
-
122
- export function setupLayoutRegistry(): LayoutRegistry {
123
- // Generic Test setup
124
- // create client container that registers all default modules including the layoutModule
125
- const layoutContainer = initializeDiagramContainer(new Container());
126
- return layoutContainer.get<LayoutRegistry>(TYPES.LayoutRegistry);
127
- }
@@ -1,170 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2026 TypeFox, STMicroelectronics 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
-
17
- import { expect } from 'chai';
18
- import 'mocha';
19
- import 'reflect-metadata';
20
- import { BoundsData, ConsoleLogger, Dimension, GModelElement, GNode } from '@eclipse-glsp/sprotty';
21
- import { createLabel, createNode, layout, setupLayoutRegistry } from './layouter-test-util.spec';
22
-
23
- describe('VBoxLayouter', () => {
24
- const layoutRegistry = setupLayoutRegistry();
25
- const log = new ConsoleLogger();
26
- const map = new Map<GModelElement, BoundsData>();
27
-
28
- function createModel(): GNode {
29
- const model = createNode('node', undefined, Dimension.EMPTY);
30
- model.children = [
31
- createLabel('label1', undefined, undefined, { width: 1, height: 2 }),
32
- createLabel('label2', undefined, undefined, { width: 2, height: 1 }),
33
- createLabel('label3', undefined, undefined, { width: 3, height: 3 })
34
- ];
35
- model.layout = 'vbox';
36
- return model;
37
- }
38
-
39
- it('defaultParams', () => {
40
- const model = createModel();
41
- layout(layoutRegistry, log, map, model);
42
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
43
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
44
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
45
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
46
- });
47
-
48
- it('alignLeft', () => {
49
- const model = createModel();
50
- model.layoutOptions = {
51
- hAlign: 'left'
52
- };
53
- layout(layoutRegistry, log, map, model);
54
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
55
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 5, y: 5, width: 1, height: 2 });
56
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5, y: 8, width: 2, height: 1 });
57
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
58
- });
59
-
60
- it('alignCenter', () => {
61
- const model = createModel();
62
- model.layoutOptions = {
63
- hAlign: 'center'
64
- };
65
- layout(layoutRegistry, log, map, model);
66
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
67
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
68
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
69
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
70
- });
71
-
72
- it('alignRight', () => {
73
- const model = createModel();
74
- model.layoutOptions = {
75
- hAlign: 'right'
76
- };
77
- layout(layoutRegistry, log, map, model);
78
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
79
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 7, y: 5, width: 1, height: 2 });
80
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 6, y: 8, width: 2, height: 1 });
81
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
82
- });
83
-
84
- it('padding', () => {
85
- const model = createModel();
86
- model.layoutOptions = {
87
- paddingTop: 7,
88
- paddingBottom: 8,
89
- paddingLeft: 9,
90
- paddingRight: 10
91
- };
92
- layout(layoutRegistry, log, map, model);
93
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 22, height: 23 });
94
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 10, y: 7, width: 1, height: 2 });
95
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 9.5, y: 10, width: 2, height: 1 });
96
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 9, y: 12, width: 3, height: 3 });
97
- });
98
-
99
- it('vGap', () => {
100
- const model = createModel();
101
- model.layoutOptions = {
102
- vGap: 4
103
- };
104
- layout(layoutRegistry, log, map, model);
105
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 24 });
106
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
107
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 11, width: 2, height: 1 });
108
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 16, width: 3, height: 3 });
109
- });
110
-
111
- it('paddingFactor', () => {
112
- const model = createModel();
113
- model.layoutOptions = {
114
- paddingFactor: 2
115
- };
116
- layout(layoutRegistry, log, map, model);
117
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 18 });
118
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9, y: 9, width: 1, height: 2 });
119
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 8.5, y: 12, width: 2, height: 1 });
120
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 8, y: 14, width: 3, height: 3 });
121
- });
122
-
123
- it('minWidth', () => {
124
- const model = createModel();
125
- model.layoutOptions = {
126
- minWidth: 25
127
- };
128
- layout(layoutRegistry, log, map, model);
129
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 25, height: 18 });
130
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 12, y: 5, width: 1, height: 2 });
131
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 11.5, y: 8, width: 2, height: 1 });
132
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 11, y: 10, width: 3, height: 3 });
133
- });
134
-
135
- it('minHeight', () => {
136
- const model = createModel();
137
- model.layoutOptions = {
138
- minHeight: 25
139
- };
140
- layout(layoutRegistry, log, map, model);
141
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 25 });
142
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
143
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
144
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
145
- });
146
-
147
- it('prefWidth', () => {
148
- const model = createModel();
149
- model.layoutOptions = {
150
- prefWidth: 20
151
- };
152
- layout(layoutRegistry, log, map, model);
153
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 20, height: 18 });
154
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 9.5, y: 5, width: 1, height: 2 });
155
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 9, y: 8, width: 2, height: 1 });
156
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 8.5, y: 10, width: 3, height: 3 });
157
- });
158
-
159
- it('prefHeight', () => {
160
- const model = createModel();
161
- model.layoutOptions = {
162
- prefHeight: 20
163
- };
164
- layout(layoutRegistry, log, map, model);
165
- expect(map.get(model)!.bounds).to.deep.equal({ x: 0, y: 0, width: 13, height: 20 });
166
- expect(map.get(model.children[0])!.bounds).to.deep.equal({ x: 6, y: 5, width: 1, height: 2 });
167
- expect(map.get(model.children[1])!.bounds).to.deep.equal({ x: 5.5, y: 8, width: 2, height: 1 });
168
- expect(map.get(model.children[2])!.bounds).to.deep.equal({ x: 5, y: 10, width: 3, height: 3 });
169
- });
170
- });
@@ -1,81 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2026 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
- /* eslint-disable import-x/no-deprecated */
17
- /* eslint-disable @typescript-eslint/no-deprecated */
18
-
19
- import { GModelElement } from '@eclipse-glsp/sprotty';
20
- import { expect } from 'chai';
21
- import { GridSnapper } from './../grid/grid-snapper';
22
- import { PointPositionUpdater } from './point-position-updater';
23
-
24
- describe('PointPositionUpdater', () => {
25
- it('updatePosition with no last drag position', () => {
26
- const element = new GModelElement();
27
- const updater = new PointPositionUpdater();
28
- expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
29
- expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
30
- });
31
-
32
- it('update last position and reset', () => {
33
- const updater = new PointPositionUpdater();
34
- expect(updater.isLastDragPositionUndefined()).to.be.true;
35
- updater.updateLastDragPosition({ x: 0, y: 0 });
36
- expect(updater.isLastDragPositionUndefined()).to.be.false;
37
- updater.resetPosition();
38
- expect(updater.isLastDragPositionUndefined()).to.be.true;
39
- });
40
-
41
- it('updatePosition with no snapper', () => {
42
- const element = new GModelElement();
43
- const updater = new PointPositionUpdater();
44
- resetUpdater(updater);
45
- expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
46
- expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
47
-
48
- resetUpdater(updater);
49
- expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
50
- expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
51
- expect(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
52
- expect(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -14, y: -4 });
53
- });
54
-
55
- it('updatePosition with snapper', () => {
56
- const element = new GModelElement();
57
- const snapper = new GridSnapper();
58
- const updater = new PointPositionUpdater(snapper);
59
- resetUpdater(updater);
60
- expect(updater.updatePosition(element, { x: 0, y: 0 }, false)).to.be.undefined;
61
- expect(updater.updatePosition(element, { x: 0, y: 0 }, true)).to.be.undefined;
62
-
63
- resetUpdater(updater);
64
- expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.deep.equals({ x: 10, y: 0 });
65
- expect(updater.updatePosition(element, { x: 5, y: 3 }, true)).to.be.undefined;
66
- expect(updater.updatePosition(element, { x: 11, y: 6 }, true)).to.be.deep.equals({ x: 0, y: 10 });
67
- expect(updater.updatePosition(element, { x: -3, y: 2 }, true)).to.be.deep.equals({ x: -10, y: -10 });
68
-
69
- // disable snapping (alt key)
70
- resetUpdater(updater);
71
- expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.deep.equals({ x: 5, y: 3 });
72
- expect(updater.updatePosition(element, { x: 5, y: 3 }, false)).to.be.undefined;
73
- expect(updater.updatePosition(element, { x: 11, y: 6 }, false)).to.be.deep.equals({ x: 6, y: 3 });
74
- expect(updater.updatePosition(element, { x: -3, y: 2 }, false)).to.be.deep.equals({ x: -14, y: -4 });
75
- });
76
-
77
- function resetUpdater(updater: PointPositionUpdater): void {
78
- updater.resetPosition();
79
- updater.updateLastDragPosition({ x: 0, y: 0 });
80
- }
81
- });
@@ -1,30 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2024 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
-
17
- import { GModelElement } from '@eclipse-glsp/sprotty';
18
- import { expect } from 'chai';
19
- import { GridSnapper } from './grid-snapper';
20
-
21
- describe('GridSnapper', () => {
22
- it('snap', () => {
23
- const element = new GModelElement();
24
- const snapper = new GridSnapper();
25
- expect(snapper.snap({ x: 0, y: 0 }, element)).to.be.deep.equals({ x: 0, y: 0 });
26
- expect(snapper.snap({ x: 4, y: 5 }, element)).to.be.deep.equals({ x: 0, y: 10 });
27
- expect(snapper.snap({ x: 8, y: 11 }, element)).to.be.deep.equals({ x: 10, y: 10 });
28
- expect(snapper.snap({ x: -7, y: -4 }, element)).to.be.deep.equals({ x: -10, y: -0 });
29
- });
30
- });