@node-projects/web-component-designer 0.0.207 → 0.0.208
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/dist/elements/helper/contextMenu/ContextMenu.d.ts +2 -1
- package/dist/elements/helper/contextMenu/ContextMenu.js +39 -1
- package/dist/elements/services/undoService/IUndoService.d.ts +2 -2
- package/dist/elements/services/undoService/UndoService.d.ts +2 -2
- package/dist/elements/services/undoService/UndoService.js +4 -4
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ export interface IContextMenuOptions {
|
|
|
4
4
|
subIcon?: string;
|
|
5
5
|
mouseOffset?: number;
|
|
6
6
|
shadowRoot?: ShadowRoot | Document;
|
|
7
|
+
mode?: 'normal' | 'undo';
|
|
7
8
|
}
|
|
8
9
|
export declare class ContextMenu {
|
|
9
10
|
private static _contextMenuCss;
|
|
@@ -17,7 +18,7 @@ export declare class ContextMenu {
|
|
|
17
18
|
renderLevel(level: IContextMenuItem[]): HTMLUListElement;
|
|
18
19
|
display(event: MouseEvent): void;
|
|
19
20
|
_windowResize(): void;
|
|
20
|
-
_windowDown(e: MouseEvent):
|
|
21
|
+
_windowDown(e: MouseEvent): boolean;
|
|
21
22
|
_windowKeyUp(e: KeyboardEvent): void;
|
|
22
23
|
static show(menu: IContextMenuItem[], event: MouseEvent, options?: IContextMenuOptions): ContextMenu;
|
|
23
24
|
close(): void;
|
|
@@ -108,6 +108,10 @@ export class ContextMenu {
|
|
|
108
108
|
|
|
109
109
|
.context_menu li[disabled=""]:hover {
|
|
110
110
|
background-color: inherit;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.context_menu li.context_menu_marked {
|
|
114
|
+
background-color: #5ebdec;
|
|
111
115
|
}`;
|
|
112
116
|
static count = 0;
|
|
113
117
|
menu;
|
|
@@ -180,6 +184,12 @@ export class ContextMenu {
|
|
|
180
184
|
item.action(e, item);
|
|
181
185
|
this.close();
|
|
182
186
|
});
|
|
187
|
+
if (this.options?.mode == 'undo') {
|
|
188
|
+
li.addEventListener('mouseup', (e) => {
|
|
189
|
+
item.action(e, item);
|
|
190
|
+
this.close();
|
|
191
|
+
});
|
|
192
|
+
}
|
|
183
193
|
if (item.children != null) {
|
|
184
194
|
let childmenu = this.renderLevel(item.children);
|
|
185
195
|
li.appendChild(childmenu);
|
|
@@ -189,8 +199,34 @@ export class ContextMenu {
|
|
|
189
199
|
childmenu.style.top = 'unset';
|
|
190
200
|
childmenu.style.bottom = '0';
|
|
191
201
|
}
|
|
202
|
+
if (this.options?.mode == 'undo') {
|
|
203
|
+
let select = true;
|
|
204
|
+
for (let node of li.parentElement.children) {
|
|
205
|
+
if (select)
|
|
206
|
+
node.classList.add('context_menu_marked');
|
|
207
|
+
else
|
|
208
|
+
node.classList.remove('context_menu_marked');
|
|
209
|
+
if (node == li)
|
|
210
|
+
select = false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
192
213
|
});
|
|
193
214
|
}
|
|
215
|
+
else {
|
|
216
|
+
if (this.options?.mode == 'undo') {
|
|
217
|
+
li.addEventListener('mouseenter', () => {
|
|
218
|
+
let select = true;
|
|
219
|
+
for (let node of li.parentElement.children) {
|
|
220
|
+
if (select)
|
|
221
|
+
node.classList.add('context_menu_marked');
|
|
222
|
+
else
|
|
223
|
+
node.classList.remove('context_menu_marked');
|
|
224
|
+
if (node == li)
|
|
225
|
+
select = false;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
194
230
|
}
|
|
195
231
|
ul_outer.appendChild(li);
|
|
196
232
|
}
|
|
@@ -246,9 +282,11 @@ export class ContextMenu {
|
|
|
246
282
|
this.close();
|
|
247
283
|
}
|
|
248
284
|
_windowDown(e) {
|
|
285
|
+
e.preventDefault();
|
|
249
286
|
const p = e.composedPath();
|
|
250
287
|
if (p.indexOf(this._menuElement) < 0)
|
|
251
288
|
this.close();
|
|
289
|
+
return false;
|
|
252
290
|
}
|
|
253
291
|
_windowKeyUp(e) {
|
|
254
292
|
if (e.key === 'Escape') {
|
|
@@ -264,8 +302,8 @@ export class ContextMenu {
|
|
|
264
302
|
this._menuElement.remove();
|
|
265
303
|
window.removeEventListener("keyup", this._windowKeyUp);
|
|
266
304
|
window.removeEventListener("mousedown", this._windowDown);
|
|
267
|
-
window.removeEventListener("contextmenu", this._windowDown);
|
|
268
305
|
window.removeEventListener("resize", this._windowResize);
|
|
306
|
+
setTimeout(() => window.removeEventListener("contextmenu", this._windowDown), 10);
|
|
269
307
|
}
|
|
270
308
|
}
|
|
271
309
|
class ContextUtil {
|
|
@@ -9,6 +9,6 @@ export interface IUndoService extends IService {
|
|
|
9
9
|
clear(): any;
|
|
10
10
|
undo(): any;
|
|
11
11
|
redo(): any;
|
|
12
|
-
getUndoEntries(): Generator<string, void, unknown>;
|
|
13
|
-
getRedoEntries(): Generator<string, void, unknown>;
|
|
12
|
+
getUndoEntries(count?: number): Generator<string, void, unknown>;
|
|
13
|
+
getRedoEntries(count?: number): Generator<string, void, unknown>;
|
|
14
14
|
}
|
|
@@ -17,6 +17,6 @@ export declare class UndoService implements IUndoService {
|
|
|
17
17
|
redo(): void;
|
|
18
18
|
canUndo(): boolean;
|
|
19
19
|
canRedo(): boolean;
|
|
20
|
-
getUndoEntries(): Generator<string, void, unknown>;
|
|
21
|
-
getRedoEntries(): Generator<string, void, unknown>;
|
|
20
|
+
getUndoEntries(count?: number): Generator<string, void, unknown>;
|
|
21
|
+
getRedoEntries(count?: number): Generator<string, void, unknown>;
|
|
22
22
|
}
|
|
@@ -96,12 +96,12 @@ export class UndoService {
|
|
|
96
96
|
canRedo() {
|
|
97
97
|
return this._redoStack.length > 0;
|
|
98
98
|
}
|
|
99
|
-
*getUndoEntries() {
|
|
100
|
-
for (let i = this._undoStack.length - 1; i >= 0; i--)
|
|
99
|
+
*getUndoEntries(count = 999) {
|
|
100
|
+
for (let i = Math.min(this._undoStack.length, count) - 1; i >= 0; i--)
|
|
101
101
|
yield this._undoStack[i].title;
|
|
102
102
|
}
|
|
103
|
-
*getRedoEntries() {
|
|
104
|
-
for (let i = this._redoStack.length - 1; i >= 0; i--)
|
|
103
|
+
*getRedoEntries(count = 999) {
|
|
104
|
+
for (let i = Math.min(this._redoStack.length, count) - 1; i >= 0; i--)
|
|
105
105
|
yield this._redoStack[i].title;
|
|
106
106
|
}
|
|
107
107
|
}
|