@eclipse-glsp/client 2.2.0-next.335 → 2.2.0-next.337

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 (173) hide show
  1. package/css/ghost-element.css +7 -0
  2. package/lib/base/default.module.d.ts.map +1 -1
  3. package/lib/base/default.module.js +1 -2
  4. package/lib/base/default.module.js.map +1 -1
  5. package/lib/base/drag-aware-mouse-listener.d.ts +4 -1
  6. package/lib/base/drag-aware-mouse-listener.d.ts.map +1 -1
  7. package/lib/base/drag-aware-mouse-listener.js +12 -2
  8. package/lib/base/drag-aware-mouse-listener.js.map +1 -1
  9. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts +34 -0
  10. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts.map +1 -0
  11. package/lib/base/feedback/feedback-action-dispatcher-default.js +120 -0
  12. package/lib/base/feedback/feedback-action-dispatcher-default.js.map +1 -0
  13. package/lib/base/feedback/feedback-action-dispatcher.d.ts +2 -17
  14. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  15. package/lib/base/feedback/feedback-action-dispatcher.js +1 -100
  16. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  17. package/lib/base/feedback/{feeback-emitter.d.ts → feedback-emitter.d.ts} +8 -1
  18. package/lib/base/feedback/feedback-emitter.d.ts.map +1 -0
  19. package/lib/base/feedback/{feeback-emitter.js → feedback-emitter.js} +21 -6
  20. package/lib/base/feedback/feedback-emitter.js.map +1 -0
  21. package/lib/base/feedback/index.d.ts +2 -1
  22. package/lib/base/feedback/index.d.ts.map +1 -1
  23. package/lib/base/feedback/index.js +2 -1
  24. package/lib/base/feedback/index.js.map +1 -1
  25. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  26. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +1 -1
  27. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  28. package/lib/features/change-bounds/model.d.ts +5 -1
  29. package/lib/features/change-bounds/model.d.ts.map +1 -1
  30. package/lib/features/change-bounds/model.js +36 -10
  31. package/lib/features/change-bounds/model.js.map +1 -1
  32. package/lib/features/change-bounds/movement-restrictor.d.ts +1 -0
  33. package/lib/features/change-bounds/movement-restrictor.d.ts.map +1 -1
  34. package/lib/features/change-bounds/movement-restrictor.js +8 -9
  35. package/lib/features/change-bounds/movement-restrictor.js.map +1 -1
  36. package/lib/features/copy-paste/copy-paste-standalone.d.ts.map +1 -1
  37. package/lib/features/copy-paste/copy-paste-standalone.js +0 -3
  38. package/lib/features/copy-paste/copy-paste-standalone.js.map +1 -1
  39. package/lib/features/debug/debug-bounds-decorator.d.ts.map +1 -1
  40. package/lib/features/debug/debug-bounds-decorator.js +6 -6
  41. package/lib/features/debug/debug-bounds-decorator.js.map +1 -1
  42. package/lib/features/debug/debug-module.js +1 -1
  43. package/lib/features/debug/debug-module.js.map +1 -1
  44. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts +6 -4
  45. package/lib/features/element-template/mouse-tracking-element-position-listener.d.ts.map +1 -1
  46. package/lib/features/element-template/mouse-tracking-element-position-listener.js +11 -12
  47. package/lib/features/element-template/mouse-tracking-element-position-listener.js.map +1 -1
  48. package/lib/features/grid/grid-module.d.ts.map +1 -1
  49. package/lib/features/grid/grid-module.js +1 -1
  50. package/lib/features/grid/grid-module.js.map +1 -1
  51. package/lib/features/helper-lines/helper-line-manager-default.d.ts +14 -2
  52. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +1 -1
  53. package/lib/features/helper-lines/helper-line-manager-default.js +56 -15
  54. package/lib/features/helper-lines/helper-line-manager-default.js.map +1 -1
  55. package/lib/features/hints/model.d.ts +5 -1
  56. package/lib/features/hints/model.d.ts.map +1 -1
  57. package/lib/features/hints/model.js.map +1 -1
  58. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  59. package/lib/features/select/select-mouse-listener.js +1 -1
  60. package/lib/features/select/select-mouse-listener.js.map +1 -1
  61. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  62. package/lib/features/tool-palette/tool-palette.js +2 -2
  63. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  64. package/lib/features/tools/base-tools.d.ts +1 -1
  65. package/lib/features/tools/base-tools.d.ts.map +1 -1
  66. package/lib/features/tools/change-bounds/change-bounds-manager.d.ts +11 -4
  67. package/lib/features/tools/change-bounds/change-bounds-manager.d.ts.map +1 -1
  68. package/lib/features/tools/change-bounds/change-bounds-manager.js +46 -13
  69. package/lib/features/tools/change-bounds/change-bounds-manager.js.map +1 -1
  70. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.d.ts.map +1 -1
  71. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js +3 -3
  72. package/lib/features/tools/change-bounds/change-bounds-tool-feedback.js.map +1 -1
  73. package/lib/features/tools/change-bounds/change-bounds-tool-module.js +1 -1
  74. package/lib/features/tools/change-bounds/change-bounds-tool-module.js.map +1 -1
  75. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts +2 -2
  76. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.d.ts.map +1 -1
  77. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js +3 -6
  78. package/lib/features/tools/change-bounds/change-bounds-tool-move-feedback.js.map +1 -1
  79. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +3 -2
  80. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  81. package/lib/features/tools/change-bounds/change-bounds-tool.js +7 -27
  82. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  83. package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts +8 -2
  84. package/lib/features/tools/change-bounds/change-bounds-tracker.d.ts.map +1 -1
  85. package/lib/features/tools/change-bounds/change-bounds-tracker.js +22 -5
  86. package/lib/features/tools/change-bounds/change-bounds-tracker.js.map +1 -1
  87. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +4 -1
  88. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
  89. package/lib/features/tools/edge-creation/edge-creation-tool.js +12 -10
  90. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  91. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts +1 -1
  92. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.d.ts.map +1 -1
  93. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js +3 -3
  94. package/lib/features/tools/edge-edit/edge-edit-tool-feedback.js.map +1 -1
  95. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +1 -1
  96. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
  97. package/lib/features/tools/edge-edit/edge-edit-tool.js +3 -3
  98. package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
  99. package/lib/features/tools/node-creation/container-manager.d.ts +41 -0
  100. package/lib/features/tools/node-creation/container-manager.d.ts.map +1 -0
  101. package/lib/features/tools/node-creation/container-manager.js +73 -0
  102. package/lib/features/tools/node-creation/container-manager.js.map +1 -0
  103. package/lib/features/tools/node-creation/index.d.ts +3 -0
  104. package/lib/features/tools/node-creation/index.d.ts.map +1 -1
  105. package/lib/features/tools/node-creation/index.js +3 -0
  106. package/lib/features/tools/node-creation/index.js.map +1 -1
  107. package/lib/features/tools/node-creation/insert-indicator.d.ts +30 -0
  108. package/lib/features/tools/node-creation/insert-indicator.d.ts.map +1 -0
  109. package/lib/features/tools/node-creation/insert-indicator.js +40 -0
  110. package/lib/features/tools/node-creation/insert-indicator.js.map +1 -0
  111. package/lib/features/tools/node-creation/node-creation-module.d.ts.map +1 -1
  112. package/lib/features/tools/node-creation/node-creation-module.js +5 -0
  113. package/lib/features/tools/node-creation/node-creation-module.js.map +1 -1
  114. package/lib/features/tools/node-creation/node-creation-tool.d.ts +23 -14
  115. package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
  116. package/lib/features/tools/node-creation/node-creation-tool.js +79 -75
  117. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  118. package/lib/features/tools/node-creation/node-creation-views.d.ts +25 -0
  119. package/lib/features/tools/node-creation/node-creation-views.d.ts.map +1 -0
  120. package/lib/features/tools/node-creation/node-creation-views.js +60 -0
  121. package/lib/features/tools/node-creation/node-creation-views.js.map +1 -0
  122. package/lib/utils/gmodel-util.d.ts +2 -0
  123. package/lib/utils/gmodel-util.d.ts.map +1 -1
  124. package/lib/utils/gmodel-util.js.map +1 -1
  125. package/lib/views/ggraph-view.d.ts.map +1 -1
  126. package/lib/views/ggraph-view.js +2 -2
  127. package/lib/views/ggraph-view.js.map +1 -1
  128. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  129. package/lib/views/glsp-projection-view.js +2 -2
  130. package/lib/views/glsp-projection-view.js.map +1 -1
  131. package/package.json +3 -3
  132. package/src/base/default.module.ts +1 -2
  133. package/src/base/drag-aware-mouse-listener.ts +17 -1
  134. package/src/base/feedback/feedback-action-dispatcher-default.ts +119 -0
  135. package/src/base/feedback/feedback-action-dispatcher.ts +2 -106
  136. package/src/base/feedback/feedback-emitter.spec.ts +176 -0
  137. package/src/base/feedback/{feeback-emitter.ts → feedback-emitter.ts} +24 -5
  138. package/src/base/feedback/index.ts +2 -1
  139. package/src/base/selection-service.spec.ts +1 -1
  140. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +1 -1
  141. package/src/features/change-bounds/model.ts +38 -13
  142. package/src/features/change-bounds/movement-restrictor.ts +11 -11
  143. package/src/features/copy-paste/copy-paste-standalone.ts +0 -3
  144. package/src/features/debug/debug-bounds-decorator.tsx +7 -7
  145. package/src/features/debug/debug-module.ts +1 -1
  146. package/src/features/element-template/mouse-tracking-element-position-listener.ts +14 -22
  147. package/src/features/grid/grid-module.ts +2 -2
  148. package/src/features/helper-lines/helper-line-manager-default.ts +66 -10
  149. package/src/features/hints/model.ts +6 -1
  150. package/src/features/hints/type-hint-provider.spec.ts +1 -1
  151. package/src/features/select/select-mouse-listener.ts +2 -2
  152. package/src/features/tool-palette/tool-palette.ts +2 -3
  153. package/src/features/tools/base-tools.ts +1 -1
  154. package/src/features/tools/change-bounds/change-bounds-manager.ts +71 -13
  155. package/src/features/tools/change-bounds/change-bounds-tool-feedback.ts +5 -2
  156. package/src/features/tools/change-bounds/change-bounds-tool-module.ts +1 -1
  157. package/src/features/tools/change-bounds/change-bounds-tool-move-feedback.ts +4 -8
  158. package/src/features/tools/change-bounds/change-bounds-tool.ts +9 -55
  159. package/src/features/tools/change-bounds/change-bounds-tracker.ts +26 -5
  160. package/src/features/tools/edge-creation/edge-creation-tool.ts +13 -6
  161. package/src/features/tools/edge-edit/edge-edit-tool-feedback.ts +1 -1
  162. package/src/features/tools/edge-edit/edge-edit-tool.ts +2 -3
  163. package/src/features/tools/node-creation/container-manager.ts +76 -0
  164. package/src/features/tools/node-creation/index.ts +3 -0
  165. package/src/features/tools/node-creation/insert-indicator.ts +41 -0
  166. package/src/features/tools/node-creation/node-creation-module.ts +13 -1
  167. package/src/features/tools/node-creation/node-creation-tool.ts +98 -90
  168. package/src/features/tools/node-creation/node-creation-views.tsx +49 -0
  169. package/src/utils/gmodel-util.ts +4 -1
  170. package/src/views/ggraph-view.tsx +3 -3
  171. package/src/views/glsp-projection-view.tsx +2 -3
  172. package/lib/base/feedback/feeback-emitter.d.ts.map +0 -1
  173. package/lib/base/feedback/feeback-emitter.js.map +0 -1
@@ -16,13 +16,14 @@
16
16
  import {
17
17
  Action,
18
18
  CreateNodeOperation,
19
+ Disposable,
20
+ DisposableCollection,
19
21
  GModelElement,
20
- GNode,
21
22
  GhostElement,
23
+ IModelFactory,
22
24
  Point,
23
25
  TYPES,
24
26
  TriggerNodeCreationAction,
25
- findParentByFeature,
26
27
  isCtrlOrCmd,
27
28
  isMoveable
28
29
  } from '@eclipse-glsp/sprotty';
@@ -32,14 +33,14 @@ import { FeedbackEmitter } from '../../../base';
32
33
  import { DragAwareMouseListener } from '../../../base/drag-aware-mouse-listener';
33
34
  import { CSS_GHOST_ELEMENT, CSS_HIDDEN, CursorCSS, cursorFeedbackAction } from '../../../base/feedback/css-feedback';
34
35
  import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
35
- import { MoveableElement, isValidMove } from '../../../utils';
36
- import { getAbsolutePosition } from '../../../utils/viewpoint-util';
37
- import { RemoveTemplateElementsAction } from '../../element-template';
36
+ import { MoveableElement } from '../../../utils/gmodel-util';
38
37
  import { AddTemplateElementsAction, getTemplateElementId } from '../../element-template/add-template-element';
39
38
  import { MouseTrackingElementPositionListener, PositioningTool } from '../../element-template/mouse-tracking-element-position-listener';
40
- import { Containable, isContainable } from '../../hints/model';
39
+ import { RemoveTemplateElementsAction } from '../../element-template/remove-template-element';
41
40
  import { BaseCreationTool } from '../base-tools';
42
- import { ChangeBoundsManager } from '../change-bounds';
41
+ import { ChangeBoundsManager, TrackedMove } from '../change-bounds';
42
+ import { ContainerManager, TrackedInsert } from './container-manager';
43
+ import { InsertIndicator } from './insert-indicator';
43
44
 
44
45
  @injectable()
45
46
  export class NodeCreationTool extends BaseCreationTool<TriggerNodeCreationAction> implements PositioningTool {
@@ -47,52 +48,80 @@ export class NodeCreationTool extends BaseCreationTool<TriggerNodeCreationAction
47
48
 
48
49
  protected isTriggerAction = TriggerNodeCreationAction.is;
49
50
 
50
- @inject(TYPES.IChangeBoundsManager) readonly changeBoundsManager: ChangeBoundsManager;
51
+ @inject(ChangeBoundsManager) readonly changeBoundsManager: ChangeBoundsManager;
52
+ @inject(ContainerManager) readonly containerManager: ContainerManager;
53
+ @inject(TYPES.IModelFactory) modelFactory: IModelFactory;
51
54
 
52
55
  get id(): string {
53
56
  return NodeCreationTool.ID;
54
57
  }
55
58
 
56
59
  doEnable(): void {
57
- let trackingListener: MouseTrackingElementPositionListener | undefined;
58
- const ghostElement = this.triggerAction.ghostElement;
59
- const ghostElementId = ghostElement ? getTemplateElementId(ghostElement.template) : undefined;
60
- if (ghostElement && ghostElementId) {
61
- trackingListener = new MouseTrackingElementPositionListener(ghostElementId, this, 'middle');
62
- this.toDisposeOnDisable.push(trackingListener, this.mouseTool.registerListener(trackingListener));
63
- }
60
+ const ghostElement = this.triggerAction.ghostElement ?? { template: this.modelFactory.createSchema(this.createInsertIndicator()) };
61
+ this.toDisposeOnDisable.push(this.createGhostElementTracker(ghostElement, 'middle'));
62
+ this.toDisposeOnDisable.push(this.createNodeCreationListener(ghostElement));
63
+ this.toDisposeOnDisable.push(this.createNodeCreationCursorFeedback().submit());
64
+ }
64
65
 
65
- const toolListener = new NodeCreationToolMouseListener(this.triggerAction, this, ghostElement);
66
- this.toDisposeOnDisable.push(
67
- toolListener,
68
- this.mouseTool.registerListener(toolListener),
69
- this.createFeedbackEmitter().add(cursorFeedbackAction(CursorCSS.NODE_CREATION), cursorFeedbackAction()).submit()
66
+ protected createInsertIndicator(): GModelElement {
67
+ return new InsertIndicator();
68
+ }
69
+
70
+ protected createGhostElementTracker(ghostElement: GhostElement, position: 'top-left' | 'middle'): Disposable {
71
+ const trackingListener = new NodeInsertTrackingListener(
72
+ getTemplateElementId(ghostElement.template),
73
+ this.triggerAction.elementTypeId,
74
+ this,
75
+ position
70
76
  );
77
+ return new DisposableCollection(trackingListener, this.mouseTool.registerListener(trackingListener));
78
+ }
79
+
80
+ protected createNodeCreationListener(ghostElement: GhostElement): Disposable {
81
+ const toolListener = new NodeCreationToolMouseListener(this.triggerAction, this, ghostElement);
82
+ return new DisposableCollection(toolListener, this.mouseTool.registerListener(toolListener));
83
+ }
84
+
85
+ protected createNodeCreationCursorFeedback(): FeedbackEmitter {
86
+ return this.createFeedbackEmitter().add(cursorFeedbackAction(CursorCSS.NODE_CREATION), cursorFeedbackAction());
87
+ }
88
+ }
89
+
90
+ export class NodeInsertTrackingListener extends MouseTrackingElementPositionListener {
91
+ constructor(
92
+ elementId: string,
93
+ protected elementTypeId: string,
94
+ protected override tool: NodeCreationTool,
95
+ cursorPosition: 'top-left' | 'middle' = 'top-left'
96
+ ) {
97
+ super(elementId, tool, cursorPosition);
98
+ }
99
+
100
+ protected override addMoveFeedback(move: TrackedMove, ctx: GModelElement, event: MouseEvent): void {
101
+ super.addMoveFeedback(move, ctx, event);
102
+
103
+ const element = move.elementMoves[0].element;
104
+ const location = move.elementMoves[0].toPosition;
105
+ const insert = this.tool.containerManager.insert(element, location, this.elementTypeId, { evt: event });
106
+ this.tool.containerManager.addInsertFeedback(this.moveGhostFeedback, insert, ctx, event);
71
107
  }
72
108
  }
73
109
 
74
110
  export class NodeCreationToolMouseListener extends DragAwareMouseListener {
75
- protected container?: GModelElement & Containable;
76
111
  protected cursorFeedback: FeedbackEmitter;
77
112
  protected ghostElementFeedback: FeedbackEmitter;
78
- protected ghostElementId?: string;
113
+ protected ghostElementId: string;
79
114
 
80
115
  constructor(
81
116
  protected triggerAction: TriggerNodeCreationAction,
82
117
  protected tool: NodeCreationTool,
83
- protected ghostElement?: GhostElement
118
+ protected ghostElement: GhostElement
84
119
  ) {
85
120
  super();
86
121
  this.cursorFeedback = tool.createFeedbackEmitter();
87
122
  this.ghostElementFeedback = tool.createFeedbackEmitter();
88
- if (ghostElement) {
89
- this.ghostElementId = getTemplateElementId(ghostElement.template);
90
- }
91
- this.createGhostElement();
92
- }
93
-
94
- protected creationAllowed(elementTypeId: string): boolean | undefined {
95
- return this.container && this.container.isContainableElement(elementTypeId);
123
+ this.ghostElementId = getTemplateElementId(ghostElement.template);
124
+ this.createGhostElement(ghostElement);
96
125
  }
97
126
 
98
127
  get elementTypeId(): string {
@@ -101,78 +130,57 @@ export class NodeCreationToolMouseListener extends DragAwareMouseListener {
101
130
 
102
131
  override nonDraggingMouseUp(target: GModelElement, event: MouseEvent): Action[] {
103
132
  const result: Action[] = [];
104
- if (this.container === undefined) {
105
- this.mouseOver(target, event);
133
+
134
+ const insert = this.getTrackedInsert(target, event);
135
+ if (insert.valid) {
136
+ result.push(
137
+ CreateNodeOperation.create(this.elementTypeId, {
138
+ location: insert.location,
139
+ containerId: insert.container?.id,
140
+ args: this.triggerAction.args
141
+ })
142
+ );
143
+ }
144
+ if (isCtrlOrCmd(event)) {
145
+ // we continue in stamp mode so we keep the ghost but dispose everything else
146
+ this.disposeAllButGhostElement();
147
+ return result;
106
148
  }
107
149
 
108
- if (this.creationAllowed(this.elementTypeId)) {
109
- const location = this.getValidInsertPosition(target, event);
110
- if (location) {
111
- const containerId = this.container?.id;
112
- result.push(CreateNodeOperation.create(this.elementTypeId, { location, containerId, args: this.triggerAction.args }));
113
- }
114
- if (!isCtrlOrCmd(event)) {
115
- // we no longer want to show the ghost element AFTER the next update
116
- this.ghostElementFeedback.discard();
117
- result.push(EnableDefaultToolsAction.create());
118
- } else {
119
- // we continue in stamp mode so we keep the ghost but dispose everything else
120
- this.disposeAllButGhostElement();
121
- }
150
+ if (insert.valid) {
151
+ // we keep the ghost element until the next update to avoid flickering during insert
152
+ this.ghostElementFeedback.discard();
153
+ } else {
154
+ this.dispose();
122
155
  }
156
+ result.push(EnableDefaultToolsAction.create());
123
157
  return result;
124
158
  }
125
159
 
126
- protected createGhostElement(): void {
127
- if (!this.ghostElement) {
128
- return;
129
- }
130
- const templates = [this.ghostElement.template];
131
- this.ghostElementFeedback
132
- .add(
133
- AddTemplateElementsAction.create({ templates, addClasses: [CSS_HIDDEN, CSS_GHOST_ELEMENT] }),
134
- RemoveTemplateElementsAction.create({ templates })
135
- )
136
- .submit();
137
- }
138
-
139
- protected getGhostElement(): MoveableElement | undefined {
140
- if (!this.ghostElementId) {
141
- return undefined;
142
- }
143
- const ghostElement = this.container?.index.getById(this.ghostElementId);
160
+ protected createGhostElement(ghostElement: GhostElement): string {
161
+ const templates = [ghostElement.template];
162
+ this.ghostElementFeedback.add(
163
+ AddTemplateElementsAction.create({ templates, addClasses: [CSS_HIDDEN, CSS_GHOST_ELEMENT] }),
164
+ RemoveTemplateElementsAction.create({ templates })
165
+ );
166
+ this.ghostElementFeedback.submit();
167
+ return getTemplateElementId(ghostElement.template);
168
+ }
169
+
170
+ protected getGhostElement(ctx: GModelElement, event: MouseEvent): MoveableElement | undefined {
171
+ const ghostElement = ctx.index.getById(this.ghostElementId);
144
172
  return ghostElement && isMoveable(ghostElement) ? ghostElement : undefined;
145
173
  }
146
174
 
147
- protected getValidInsertPosition(target: GModelElement, event: MouseEvent): Point | undefined {
148
- const ghostElement = this.getGhostElement();
149
- if (ghostElement) {
150
- return isValidMove(ghostElement, ghostElement.position, this.tool.changeBoundsManager.movementRestrictor)
151
- ? ghostElement.position
152
- : undefined;
153
- }
154
- const location = getAbsolutePosition(target, event);
155
-
156
- // Create a 0-bounds proxy element for snapping
157
- const elementProxy = new GNode();
158
- elementProxy.size = { width: 0, height: 0 };
159
- return this.tool.changeBoundsManager.snapPosition(elementProxy, location);
160
- }
161
-
162
- override mouseOver(target: GModelElement, event: MouseEvent): Action[] {
163
- const currentContainer = findParentByFeature(target, isContainable);
164
- if (!this.container || currentContainer !== this.container) {
165
- this.container = currentContainer;
166
- const feedback = this.creationAllowed(this.elementTypeId)
167
- ? cursorFeedbackAction(CursorCSS.NODE_CREATION)
168
- : cursorFeedbackAction(CursorCSS.OPERATION_NOT_ALLOWED);
169
- this.cursorFeedback.add(feedback).submit();
175
+ protected getTrackedInsert(ctx: GModelElement, event: MouseEvent): TrackedInsert {
176
+ const ghostElement = this.getGhostElement(ctx, event);
177
+ if (!ghostElement) {
178
+ return { elementTypeId: this.elementTypeId, location: Point.ORIGIN, valid: false };
170
179
  }
171
- return [];
180
+ return this.tool.containerManager.insert(ghostElement, ghostElement.position, this.elementTypeId, { evt: event });
172
181
  }
173
182
 
174
183
  protected disposeAllButGhostElement(): void {
175
- this.cursorFeedback.dispose();
176
184
  super.dispose();
177
185
  }
178
186
 
@@ -0,0 +1,49 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2024 Axon Ivy AG 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 { IView, RenderingContext, TYPES, setClass, svg } from '@eclipse-glsp/sprotty';
18
+ import { inject, injectable, optional } from 'inversify';
19
+ import { VNode } from 'snabbdom';
20
+ import { GArgument } from '../../../utils';
21
+ import { Grid } from '../../grid';
22
+ import { ARG_LENGTH, InsertIndicator } from './insert-indicator';
23
+
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ const JSX = { createElement: svg };
26
+
27
+ @injectable()
28
+ export class InsertIndicatorView implements IView {
29
+ @optional() @inject(TYPES.Grid) protected grid?: Grid;
30
+
31
+ render(model: Readonly<InsertIndicator>, context: RenderingContext): VNode | undefined {
32
+ if (context.targetKind === 'hidden') {
33
+ return undefined;
34
+ }
35
+ const size = this.getSize(model);
36
+ const node = (
37
+ <g>
38
+ <polyline class-sprotty-node={true} class-insert-indicator={true} points={`0,${-size / 2} 0,${size / 2}`}></polyline>
39
+ <polyline class-sprotty-node={true} class-insert-indicator={true} points={`${-size / 2},0 ${size / 2},0`}></polyline>
40
+ </g>
41
+ );
42
+ model.cssClasses.forEach(cl => setClass(node, cl, true));
43
+ return node;
44
+ }
45
+
46
+ protected getSize(model: Readonly<InsertIndicator>): number {
47
+ return GArgument.getNumber(model, ARG_LENGTH) ?? this.grid?.x ?? 10;
48
+ }
49
+ }
@@ -40,6 +40,7 @@ import {
40
40
  isSelected,
41
41
  remove
42
42
  } from '@eclipse-glsp/sprotty';
43
+ import { ResizeHandleLocation } from '../features';
43
44
 
44
45
  /**
45
46
  * Helper type to represent a filter predicate for {@link GModelElement}s. This is used to retrieve
@@ -253,7 +254,9 @@ export type MoveableElement = GModelElement & Locateable;
253
254
 
254
255
  export interface Resizable extends BoundsAware, Selectable {}
255
256
 
256
- export interface ResizableModelElement extends GParentElement, Resizable {}
257
+ export interface ResizableModelElement extends GParentElement, Resizable {
258
+ resizeLocations?: ResizeHandleLocation[];
259
+ }
257
260
 
258
261
  /**
259
262
  * Helper function to translate a given {@link GModelElement} into its corresponding {@link ElementAndBounds} representation.
@@ -13,14 +13,14 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Bounds, Dimension, Point, RenderingContext, SGraphImpl, SGraphView, TYPES, Writable } from '@eclipse-glsp/sprotty';
16
+ import { Bounds, Dimension, Point, RenderingContext, SGraphImpl, SGraphView, Writable } from '@eclipse-glsp/sprotty';
17
17
  import { inject, injectable, optional } from 'inversify';
18
18
  import { VNode } from 'snabbdom';
19
19
  import { GridManager, GridStyle } from '../features';
20
20
 
21
21
  @injectable()
22
22
  export class GGraphView extends SGraphView {
23
- @inject(TYPES.IGridManager) @optional() protected gridManager?: GridManager;
23
+ @inject(GridManager) @optional() protected gridManager?: GridManager;
24
24
 
25
25
  override render(model: Readonly<SGraphImpl>, context: RenderingContext): VNode {
26
26
  const graph = super.render(model, context);
@@ -31,7 +31,7 @@ export class GGraphView extends SGraphView {
31
31
  }
32
32
 
33
33
  protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
34
- if (!this.gridManager?.isGridVisible) {
34
+ if (context.targetKind === 'hidden' || !this.gridManager?.isGridVisible) {
35
35
  return {};
36
36
  }
37
37
  const bounds = this.getBackgroundBounds(model, context, this.gridManager);
@@ -25,7 +25,6 @@ import {
25
25
  ProjectionParams,
26
26
  RenderingContext,
27
27
  SGraphImpl,
28
- TYPES,
29
28
  ViewProjection,
30
29
  Writable,
31
30
  html,
@@ -45,7 +44,7 @@ const JSX = { createElement: html };
45
44
  @injectable()
46
45
  export class GLSPProjectionView extends ProjectedViewportView {
47
46
  @inject(EdgeRouterRegistry) edgeRouterRegistry: EdgeRouterRegistry;
48
- @inject(TYPES.IGridManager) @optional() protected gridManager?: GridManager;
47
+ @inject(GridManager) @optional() protected gridManager?: GridManager;
49
48
 
50
49
  override render(model: Readonly<GViewportRootElement>, context: RenderingContext, args?: IViewArgs): VNode {
51
50
  const rootNode: VNode = (
@@ -73,7 +72,7 @@ export class GLSPProjectionView extends ProjectedViewportView {
73
72
  }
74
73
 
75
74
  protected getGridStyle(model: Readonly<SGraphImpl>, context: RenderingContext): GridStyle {
76
- if (!this.gridManager?.isGridVisible) {
75
+ if (context.targetKind === 'hidden' || !this.gridManager?.isGridVisible) {
77
76
  return {};
78
77
  }
79
78
  const bounds = this.getBackgroundBounds(model, context, this.gridManager);
@@ -1 +0,0 @@
1
- {"version":3,"file":"feeback-emitter.d.ts","sourceRoot":"","sources":["../../../src/base/feedback/feeback-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAW,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEzG;;GAEG;AACH,qBAAa,eAAgB,YAAW,gBAAgB,EAAE,UAAU;IAKpD,SAAS,CAAC,kBAAkB,EAAE,yBAAyB;IAJnE,SAAS,CAAC,eAAe,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAM;IACvD,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,CAAM;IAC9C,SAAS,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;gBAEhB,kBAAkB,EAAE,yBAAyB;IAEnE;;;;;;OAMG;IACH,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,YAAY,GAAG,IAAI;IAYxD;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAS5B;;OAEG;IAC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