@node-projects/web-component-designer 0.0.124 → 0.0.126
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.
- package/ACKNOWLEDGMENTS +3 -1
- package/dist/elements/helper/contextMenu/ContextMenuHelper.d.ts +0 -27
- package/dist/elements/helper/contextMenu/ContextMenuHelper.js +182 -153
- package/dist/elements/helper/contextMenu/IContextmenuItem.d.ts +3 -2
- package/dist/elements/helper/contextMenu/IContextmenuItem.js +1 -0
- package/dist/elements/helper/contextMenu/IContextmenuItemTmp.d.ts +8 -0
- package/dist/elements/helper/contextMenu/IContextmenuItemTmp.js +2 -0
- package/dist/elements/helper/contextMenu/NewContextmenu.d.ts +30 -0
- package/dist/elements/helper/contextMenu/NewContextmenu.js +274 -0
- package/dist/elements/helper/contextMenu/contextmenu.d.ts +29 -0
- package/dist/elements/helper/contextMenu/contextmenu.js +304 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -2
- package/dist/elements/widgets/designerView/designerCanvas.js +4 -3
- package/dist/elements/widgets/designerView/extensions/contextMenu/CopyPasteContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/IContextMenuExtension.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/ItemsBelowContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/ItemsBelowContextMenu.js +1 -2
- package/dist/elements/widgets/designerView/extensions/contextMenu/MultipleItemsSelectedContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/RotateLeftAndRightContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/SelectAllChildrenContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/SeperatorContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/ZMoveContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/ZoomToElementContextMenu.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/svg/PathExtension.js +2 -2
- package/dist/elements/widgets/designerView/tools/PointerTool.js +1 -1
- package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +2 -2
- package/dist/elements/widgets/treeView/treeViewExtended.d.ts +2 -2
- package/dist/elements/widgets/treeView/treeViewExtended.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/ACKNOWLEDGMENTS
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
https://github.com/PolymerLabs/wizzywid
|
|
5
5
|
This was a start for this whole project (even if mostly nothing of the original code is left)
|
|
6
6
|
- Thanks to @chdh for plain-scrollbar component
|
|
7
|
-
https://github.com/chdh/plain-scrollbar
|
|
7
|
+
https://github.com/chdh/plain-scrollbar
|
|
8
|
+
- Thanks to @m-thalmann for contextmenujs
|
|
9
|
+
https://github.com/m-thalmann/contextmenujs (also we have heavily modified it)
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IContextMenuItem } from "./IContextmenuItem";
|
|
2
|
-
export declare class ContextMenuHelper {
|
|
3
|
-
private static _contextMenuCss;
|
|
4
|
-
private _shadowRoot;
|
|
5
|
-
private _element;
|
|
6
|
-
private _closeBound;
|
|
7
|
-
private _keyUpBound;
|
|
8
|
-
private _closeOnDownBound;
|
|
9
|
-
private _closeOnUpBound;
|
|
10
|
-
static addContextMenu(element: HTMLElement, items: IContextMenuItem[]): void;
|
|
11
|
-
static showContextMenu(shadowRoot: ShadowRoot | Document | null, e: MouseEvent, element: HTMLElement, items: IContextMenuItem[]): ContextMenuHelper;
|
|
12
|
-
private constructor();
|
|
13
|
-
private init;
|
|
14
|
-
close(): void;
|
|
15
|
-
show(): void;
|
|
16
|
-
hide(): void;
|
|
17
|
-
private _keyUp;
|
|
18
|
-
private _closeOnDown;
|
|
19
|
-
private _closeOnUp;
|
|
20
|
-
static createMenu(helper: ContextMenuHelper, items: IContextMenuItem[]): HTMLElement;
|
|
21
|
-
static clickInsideElement(e: any, className: any): any;
|
|
22
|
-
static getPosition(e: MouseEvent): {
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
};
|
|
26
|
-
positionMenu(e: MouseEvent): void;
|
|
27
|
-
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/*import { IContextMenuItem } from "./IContextmenuItem";
|
|
3
|
+
import { css } from "@node-projects/base-custom-webcomponent"
|
|
4
|
+
|
|
2
5
|
export class ContextMenuHelper {
|
|
3
|
-
|
|
6
|
+
|
|
7
|
+
private static _contextMenuCss = css`
|
|
4
8
|
.context-menu {
|
|
5
9
|
display: none;
|
|
6
10
|
position: absolute;
|
|
@@ -52,165 +56,190 @@ export class ContextMenuHelper {
|
|
|
52
56
|
color: #fff;
|
|
53
57
|
background-color: #0066aa;
|
|
54
58
|
}`;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
static showContextMenu(shadowRoot, e, element, items) {
|
|
68
|
-
if (shadowRoot == null)
|
|
69
|
-
shadowRoot = document;
|
|
70
|
-
//@ts-ignore
|
|
71
|
-
if (shadowRoot.adoptedStyleSheets.indexOf(ContextMenuHelper._contextMenuCss) < 0) {
|
|
72
|
-
//@ts-ignore
|
|
73
|
-
shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, ContextMenuHelper._contextMenuCss];
|
|
74
|
-
}
|
|
75
|
-
let ctxMenu = new ContextMenuHelper();
|
|
76
|
-
let menu = ContextMenuHelper.createMenu(ctxMenu, items);
|
|
77
|
-
ctxMenu.init(shadowRoot, menu);
|
|
78
|
-
ctxMenu.positionMenu(e);
|
|
79
|
-
return ctxMenu;
|
|
80
|
-
}
|
|
81
|
-
constructor() {
|
|
82
|
-
}
|
|
83
|
-
init(shadowRoot, element) {
|
|
84
|
-
this._shadowRoot = shadowRoot;
|
|
85
|
-
this._element = element;
|
|
86
|
-
if (this._shadowRoot === document)
|
|
87
|
-
document.body.appendChild(this._element);
|
|
88
|
-
else
|
|
89
|
-
this._shadowRoot.appendChild(this._element);
|
|
90
|
-
this._closeBound = this.close.bind(this);
|
|
91
|
-
this._closeOnUpBound = this._closeOnUp.bind(this);
|
|
92
|
-
this._closeOnDownBound = this._closeOnDown.bind(this);
|
|
93
|
-
this._keyUpBound = this._keyUp.bind(this);
|
|
94
|
-
window.addEventListener('keyup', this._keyUpBound);
|
|
95
|
-
window.addEventListener('resize', this._closeBound);
|
|
96
|
-
window.addEventListener('mousedown', this._closeOnDownBound);
|
|
97
|
-
window.addEventListener('mouseup', this._closeOnUpBound);
|
|
98
|
-
this._element.classList.add('context-menu--active');
|
|
99
|
-
}
|
|
100
|
-
close() {
|
|
101
|
-
requestAnimationFrame(() => {
|
|
102
|
-
window.removeEventListener('keyup', this._keyUpBound);
|
|
103
|
-
window.removeEventListener('resize', this._closeBound);
|
|
104
|
-
window.removeEventListener('mousedown', this._closeOnDownBound);
|
|
105
|
-
window.removeEventListener('mouseup', this._closeOnUpBound);
|
|
106
|
-
if (this._element.parentElement)
|
|
107
|
-
this._element.parentElement.removeChild(this._element);
|
|
108
|
-
});
|
|
59
|
+
|
|
60
|
+
private _shadowRoot: ShadowRoot | Document;
|
|
61
|
+
private _element: HTMLElement;
|
|
62
|
+
private _closeBound: () => void;
|
|
63
|
+
private _keyUpBound: () => void;
|
|
64
|
+
private _closeOnDownBound: () => void;
|
|
65
|
+
private _closeOnUpBound: () => void;
|
|
66
|
+
|
|
67
|
+
static addContextMenu(element: HTMLElement, items: IContextMenuItem[]) {
|
|
68
|
+
element.oncontextmenu = (event) => {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
ContextMenuHelper.showContextMenu(null, event, null, items);
|
|
109
71
|
}
|
|
110
|
-
|
|
111
|
-
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static showContextMenu(shadowRoot: ShadowRoot | Document | null, e: MouseEvent, element: HTMLElement, items: IContextMenuItem[]) {
|
|
75
|
+
if (shadowRoot == null)
|
|
76
|
+
shadowRoot = document;
|
|
77
|
+
|
|
78
|
+
//@ts-ignore
|
|
79
|
+
if (shadowRoot.adoptedStyleSheets.indexOf(ContextMenuHelper._contextMenuCss) < 0) {
|
|
80
|
+
//@ts-ignore
|
|
81
|
+
shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, ContextMenuHelper._contextMenuCss];
|
|
112
82
|
}
|
|
113
|
-
|
|
114
|
-
|
|
83
|
+
let ctxMenu = new ContextMenuHelper();
|
|
84
|
+
let menu = ContextMenuHelper.createMenu(ctxMenu, items);
|
|
85
|
+
ctxMenu.init(shadowRoot, menu);
|
|
86
|
+
ctxMenu.positionMenu(e)
|
|
87
|
+
return ctxMenu;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private constructor() {
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private init(shadowRoot: ShadowRoot | Document, element: HTMLElement) {
|
|
94
|
+
this._shadowRoot = shadowRoot;
|
|
95
|
+
this._element = element;
|
|
96
|
+
if (this._shadowRoot === document)
|
|
97
|
+
document.body.appendChild(this._element);
|
|
98
|
+
else
|
|
99
|
+
this._shadowRoot.appendChild(this._element);
|
|
100
|
+
|
|
101
|
+
this._closeBound = this.close.bind(this);
|
|
102
|
+
this._closeOnUpBound = this._closeOnUp.bind(this);
|
|
103
|
+
this._closeOnDownBound = this._closeOnDown.bind(this);
|
|
104
|
+
this._keyUpBound = this._keyUp.bind(this);
|
|
105
|
+
|
|
106
|
+
window.addEventListener('keyup', this._keyUpBound);
|
|
107
|
+
window.addEventListener('resize', this._closeBound);
|
|
108
|
+
window.addEventListener('mousedown', this._closeOnDownBound);
|
|
109
|
+
window.addEventListener('mouseup', this._closeOnUpBound);
|
|
110
|
+
|
|
111
|
+
this._element.classList.add('context-menu--active');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public close() {
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
window.removeEventListener('keyup', this._keyUpBound);
|
|
117
|
+
window.removeEventListener('resize', this._closeBound);
|
|
118
|
+
window.removeEventListener('mousedown', this._closeOnDownBound);
|
|
119
|
+
window.removeEventListener('mouseup', this._closeOnUpBound);
|
|
120
|
+
|
|
121
|
+
if (this._element.parentElement)
|
|
122
|
+
this._element.parentElement.removeChild(this._element);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public show() {
|
|
127
|
+
this._element.classList.add('context-menu--active');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public hide() {
|
|
131
|
+
this._element.classList.remove('context-menu--active');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private _keyUp(e: KeyboardEvent) {
|
|
135
|
+
if (e.keyCode === 27) {
|
|
136
|
+
this.close();
|
|
115
137
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private _closeOnDown(e: MouseEvent) {
|
|
141
|
+
const p = e.composedPath();
|
|
142
|
+
if (p.indexOf(this._element) < 0)
|
|
143
|
+
this.close();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private _closeOnUp(e: MouseEvent) {
|
|
147
|
+
if (e.button == 1)
|
|
148
|
+
this.close();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static createMenu(helper: ContextMenuHelper, items: IContextMenuItem[]) {
|
|
152
|
+
let nav = document.createElement('nav');
|
|
153
|
+
nav.className = 'context-menu';
|
|
154
|
+
let ul = document.createElement('ul');
|
|
155
|
+
ul.className = 'context-menu__items';
|
|
156
|
+
nav.appendChild(ul);
|
|
157
|
+
|
|
158
|
+
let lastWasSeperator = false;
|
|
159
|
+
for (let i of items) {
|
|
160
|
+
if (i.title == '-') {
|
|
161
|
+
if (!lastWasSeperator) {
|
|
162
|
+
let hr = document.createElement('hr');
|
|
163
|
+
ul.appendChild(hr);
|
|
164
|
+
lastWasSeperator = true
|
|
119
165
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
nav.className = 'context-menu';
|
|
133
|
-
let ul = document.createElement('ul');
|
|
134
|
-
ul.className = 'context-menu__items';
|
|
135
|
-
nav.appendChild(ul);
|
|
136
|
-
let lastWasSeperator = false;
|
|
137
|
-
for (let i of items) {
|
|
138
|
-
if (i.title == '-') {
|
|
139
|
-
if (!lastWasSeperator) {
|
|
140
|
-
let hr = document.createElement('hr');
|
|
141
|
-
ul.appendChild(hr);
|
|
142
|
-
lastWasSeperator = true;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
lastWasSeperator = false;
|
|
147
|
-
let li = document.createElement('li');
|
|
148
|
-
li.className = 'context-menu__item';
|
|
149
|
-
let div = document.createElement('div');
|
|
150
|
-
div.className = 'context-menu__link';
|
|
151
|
-
div.textContent = i.title;
|
|
152
|
-
li.appendChild(div);
|
|
153
|
-
ul.appendChild(li);
|
|
154
|
-
li.onclick = (e) => {
|
|
155
|
-
helper.close();
|
|
156
|
-
i.action(null, e);
|
|
157
|
-
};
|
|
158
|
-
}
|
|
166
|
+
} else {
|
|
167
|
+
lastWasSeperator = false;
|
|
168
|
+
let li = document.createElement('li');
|
|
169
|
+
li.className = 'context-menu__item';
|
|
170
|
+
let div = document.createElement('div');
|
|
171
|
+
div.className = 'context-menu__link';
|
|
172
|
+
div.textContent = i.title;
|
|
173
|
+
li.appendChild(div);
|
|
174
|
+
ul.appendChild(li);
|
|
175
|
+
li.onclick = (e) => {
|
|
176
|
+
helper.close();
|
|
177
|
+
i.action(null, e);
|
|
159
178
|
}
|
|
160
|
-
|
|
179
|
+
}
|
|
161
180
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
return nav;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static clickInsideElement(e, className) {
|
|
185
|
+
let el = e.srcElement || e.target;
|
|
186
|
+
|
|
187
|
+
if (el.classList.contains(className)) {
|
|
188
|
+
return el;
|
|
189
|
+
} else {
|
|
190
|
+
while (el = el.parentNode) {
|
|
191
|
+
if (el.classList && el.classList.contains(className)) {
|
|
192
|
+
return el;
|
|
173
193
|
}
|
|
174
|
-
|
|
194
|
+
}
|
|
175
195
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
};
|
|
196
|
+
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static getPosition(e: MouseEvent) {
|
|
201
|
+
let posx = 0;
|
|
202
|
+
let posy = 0;
|
|
203
|
+
|
|
204
|
+
//@ts-ignore
|
|
205
|
+
if (!e) e = window.event;
|
|
206
|
+
|
|
207
|
+
if (e.pageX || e.pageY) {
|
|
208
|
+
posx = e.pageX + 5;
|
|
209
|
+
posy = e.pageY - 5;
|
|
210
|
+
} else if (e.clientX || e.clientY) {
|
|
211
|
+
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft + 5;
|
|
212
|
+
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop - 5;
|
|
194
213
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
let menuWidth = this._element.offsetWidth + 4;
|
|
200
|
-
let menuHeight = this._element.offsetHeight + 4;
|
|
201
|
-
let windowWidth = window.innerWidth;
|
|
202
|
-
let windowHeight = window.innerHeight;
|
|
203
|
-
if ((windowWidth - clickCoordsX) < menuWidth) {
|
|
204
|
-
this._element.style.left = windowWidth - menuWidth + "px";
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
this._element.style.left = clickCoordsX + "px";
|
|
208
|
-
}
|
|
209
|
-
if ((windowHeight - clickCoordsY) < menuHeight) {
|
|
210
|
-
this._element.style.top = windowHeight - menuHeight + "px";
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
this._element.style.top = clickCoordsY + "px";
|
|
214
|
-
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
x: posx,
|
|
217
|
+
y: posy
|
|
215
218
|
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public positionMenu(e: MouseEvent) {
|
|
222
|
+
let clickCoords = ContextMenuHelper.getPosition(e);
|
|
223
|
+
let clickCoordsX = clickCoords.x;
|
|
224
|
+
let clickCoordsY = clickCoords.y;
|
|
225
|
+
|
|
226
|
+
let menuWidth = this._element.offsetWidth + 4;
|
|
227
|
+
let menuHeight = this._element.offsetHeight + 4;
|
|
228
|
+
|
|
229
|
+
let windowWidth = window.innerWidth;
|
|
230
|
+
let windowHeight = window.innerHeight;
|
|
231
|
+
|
|
232
|
+
if ((windowWidth - clickCoordsX) < menuWidth) {
|
|
233
|
+
this._element.style.left = windowWidth - menuWidth + "px";
|
|
234
|
+
} else {
|
|
235
|
+
this._element.style.left = clickCoordsX + "px";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if ((windowHeight - clickCoordsY) < menuHeight) {
|
|
239
|
+
this._element.style.top = windowHeight - menuHeight + "px";
|
|
240
|
+
} else {
|
|
241
|
+
this._element.style.top = clickCoordsY + "px";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
216
244
|
}
|
|
245
|
+
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export interface IContextMenuItem {
|
|
2
|
-
readonly title
|
|
2
|
+
readonly title?: string;
|
|
3
3
|
readonly icon?: string;
|
|
4
|
-
readonly action?: (e: HTMLElement, args?: Event) => void;
|
|
5
4
|
readonly children?: IContextMenuItem[];
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
6
|
readonly shortCut?: string;
|
|
7
|
+
action?: (event: MouseEvent, item: IContextMenuItem) => void;
|
|
7
8
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface IContextMenuItem {
|
|
2
|
+
readonly title?: string;
|
|
3
|
+
readonly icon?: string;
|
|
4
|
+
readonly children?: IContextMenuItem[];
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly shortCut?: string;
|
|
7
|
+
action?: (event: MouseEvent, item: IContextMenuItem) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface IContextMenuOptions {
|
|
10
|
+
closeOnResize?: boolean;
|
|
11
|
+
closeOnClick?: boolean;
|
|
12
|
+
defaultIcon?: string;
|
|
13
|
+
subIcon?: string;
|
|
14
|
+
mouseOffset?: number;
|
|
15
|
+
shadowRoot?: ShadowRoot | Document;
|
|
16
|
+
}
|
|
17
|
+
export declare class ContextMenu {
|
|
18
|
+
private static _contextMenuCss;
|
|
19
|
+
static count: number;
|
|
20
|
+
menu: IContextMenuItem[];
|
|
21
|
+
options: IContextMenuOptions;
|
|
22
|
+
private num;
|
|
23
|
+
private _documentClickBound;
|
|
24
|
+
constructor(menu: IContextMenuItem[], options: any);
|
|
25
|
+
reload(): void;
|
|
26
|
+
renderLevel(level: IContextMenuItem[]): HTMLUListElement;
|
|
27
|
+
display(event: MouseEvent): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
_documentClick(): void;
|
|
30
|
+
}
|