Skip to content

Commit 8e18f5c

Browse files
committed
Deploying to gh-pages from @ 3b019c6 🚀
1 parent 52c3939 commit 8e18f5c

File tree

4,522 files changed

+1260607
-201257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,522 files changed

+1260607
-201257
lines changed

assets/icons/p2p.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/icons/share.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/CommandHandling.js

Lines changed: 68 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { WebRtcMultiplayerServer } from '@node-projects/web-component-designer-webrtc-multiplayer';
2-
//import { UndoRedoGraph } from './UndoRedoGraph.js';
3-
let multiplayer = null;
4-
;
1+
import { ContextMenu } from '@node-projects/web-component-designer';
2+
//Command Handling..
3+
// Setup commands
54
export class CommandHandling {
65
dockManager;
76
appShell;
@@ -15,40 +14,11 @@ export class CommandHandling {
1514
let commandName = button.dataset['command'];
1615
let commandParameter = button.dataset['commandParameter'];
1716
if (commandName === 'new')
18-
this.appShell.newDocument(null, null, false);
19-
else if (commandName === 'newIframe')
20-
this.appShell.newDocument(null, null, true);
17+
this.appShell.newDocument(false);
18+
else if (commandName === 'newFixedWidth')
19+
this.appShell.newDocument(true);
2120
else if (commandName === 'github')
2221
window.location.href = 'https://github.com/node-projects/web-component-designer';
23-
else if (commandName === 'startServer') {
24-
if (!multiplayer) {
25-
multiplayer = new WebRtcMultiplayerServer();
26-
multiplayer.useBroadcast();
27-
multiplayer.startServer();
28-
}
29-
}
30-
else if (commandName === 'connectClient') {
31-
if (!multiplayer) {
32-
multiplayer = new WebRtcMultiplayerServer();
33-
multiplayer.useBroadcast();
34-
//multiplayer.startClient();
35-
}
36-
}
37-
else if (commandName === 'redo' && e.shiftKey) {
38-
const target = this.dockManager.activeDocument.resolvedElementContent;
39-
if (target) {
40-
/*const redos = Array.from(target.instanceServiceContainer.undoService.getRedoEntries());
41-
let undoRedoGraph = new UndoRedoGraph(target.instanceServiceContainer.undoService);
42-
undoRedoGraph.render(redos);
43-
undoRedoGraph.style.left = e.x + 'px';
44-
undoRedoGraph.style.top = e.y + 'px';
45-
undoRedoGraph.style.width = 'auto';
46-
undoRedoGraph.style.height = 'auto';
47-
undoRedoGraph.style.zIndex = '9';
48-
undoRedoGraph.style.position = 'absolute';
49-
document.body.appendChild(undoRedoGraph);*/
50-
}
51-
}
5222
else if (this.dockManager.activeDocument) {
5323
let target = this.dockManager.activeDocument.resolvedElementContent;
5424
if (target.executeCommand) {
@@ -59,7 +29,7 @@ export class CommandHandling {
5929
handleCommandButtonMouseHold(button, e) {
6030
let commandName = button.dataset['command'];
6131
let commandParameter = button.dataset['commandParameter'];
62-
let target = this.dockManager.activeDocument?.resolvedElementContent;
32+
let target = this.dockManager.activeDocument.resolvedElementContent;
6333
target.executeCommand({ type: ('hold' + commandName[0].toUpperCase() + commandName.substring(1)), parameter: commandParameter, event: e });
6434
}
6535
handleInputValueChanged(e) {
@@ -76,24 +46,63 @@ export class CommandHandling {
7646
init(serviceContainer) {
7747
let buttons = Array.from(document.querySelectorAll('[data-command]'));
7848
buttons.forEach(b => {
79-
let mouseDownTimer = null;
80-
b.addEventListener('mousedown', (e) => {
81-
mouseDownTimer = setTimeout(() => {
82-
this.handleCommandButtonMouseHold(b, e);
83-
mouseDownTimer = false;
84-
}, 300);
85-
});
86-
b.addEventListener('click', (e) => {
87-
if (mouseDownTimer !== false)
88-
this.handleCommandButtonClick(e);
89-
});
90-
b.addEventListener('mouseup', (e) => {
91-
if (mouseDownTimer) {
92-
clearTimeout(mouseDownTimer);
93-
mouseDownTimer = null;
94-
}
95-
});
49+
if (b instanceof HTMLButtonElement) {
50+
b.onclick = (e) => this.handleCommandButtonClick(e);
51+
let mouseDownTimer = null;
52+
b.onmousedown = (e) => {
53+
mouseDownTimer = setTimeout(() => {
54+
this.handleCommandButtonMouseHold(b, e);
55+
}, 300);
56+
};
57+
b.onmouseup = (e) => {
58+
if (mouseDownTimer) {
59+
clearTimeout(mouseDownTimer);
60+
mouseDownTimer = null;
61+
}
62+
};
63+
}
64+
else {
65+
b.onchange = (e) => this.handleInputValueChanged(e);
66+
let commandName = b.dataset['command'];
67+
if (commandName == 'setStrokeColor')
68+
serviceContainer.globalContext.onStrokeColorChanged.on(e => b.value = e.newValue);
69+
if (commandName == 'setFillBrush')
70+
serviceContainer.globalContext.onFillBrushChanged.on(e => b.value = e.newValue);
71+
}
9672
});
73+
let undoButton = document.querySelector('[data-command="undo"]');
74+
let mouseDownTimer = null;
75+
undoButton.onmousedown = (e) => {
76+
mouseDownTimer = setTimeout(() => {
77+
let target = this.dockManager.activeDocument.resolvedElementContent;
78+
let entries = target.instanceServiceContainer.undoService.getUndoEntries(20);
79+
let mnu = Array.from(entries).map((x, idx) => ({ title: 'undo: ' + x, action: () => { for (let i = 0; i <= idx; i++)
80+
target.instanceServiceContainer.undoService.undo(); } }));
81+
ContextMenu.show(mnu, e, { mode: 'undo' });
82+
}, 300);
83+
};
84+
undoButton.onmouseup = (e) => {
85+
if (mouseDownTimer) {
86+
clearTimeout(mouseDownTimer);
87+
mouseDownTimer = null;
88+
}
89+
};
90+
let redoButton = document.querySelector('[data-command="redo"]');
91+
redoButton.onmousedown = (e) => {
92+
mouseDownTimer = setTimeout(() => {
93+
let target = this.dockManager.activeDocument.resolvedElementContent;
94+
let entries = target.instanceServiceContainer.undoService.getRedoEntries(20);
95+
let mnu = Array.from(entries).map((x, idx) => ({ title: 'redo: ' + x, action: () => { for (let i = 0; i <= idx; i++)
96+
target.instanceServiceContainer.undoService.redo(); } }));
97+
ContextMenu.show(mnu, e, { mode: 'undo' });
98+
}, 300);
99+
};
100+
redoButton.onmouseup = (e) => {
101+
if (mouseDownTimer) {
102+
clearTimeout(mouseDownTimer);
103+
mouseDownTimer = null;
104+
}
105+
};
97106
setInterval(() => {
98107
if (this.dockManager.activeDocument) {
99108
let target = this.dockManager.activeDocument.resolvedElementContent;
@@ -107,39 +116,20 @@ export class CommandHandling {
107116
else {
108117
this.handleCommand(buttons, null);
109118
}
110-
const target = this.dockManager.activeDocument?.resolvedElementContent;
111-
if (target) {
112-
const undoCount = target.instanceServiceContainer.undoService.undoCount;
113-
const redoCount = target.instanceServiceContainer.undoService.redoCount;
114-
document.getElementById('undoCount').innerText = '(' + undoCount + '/' + (undoCount + redoCount) + ')';
115-
document.getElementById('redoCount').innerText = '(' + redoCount + '/' + (undoCount + redoCount) + ')';
116-
}
117119
}, 100);
118120
}
119121
handleCommand(buttons, target) {
120122
buttons.forEach(b => {
121123
let command = b.dataset['command'];
122124
let commandParameter = b.dataset['commandParameter'];
123125
if (command === 'new')
124-
b.removeAttribute('disabled');
125-
else if (command === 'newIframe')
126-
b.removeAttribute('disabled');
126+
b.disabled = false;
127+
else if (command === 'newFixedWidth')
128+
b.disabled = false;
127129
else if (command === 'github')
128-
b.removeAttribute('disabled');
129-
else if (command === 'startServer')
130-
if (!multiplayer)
131-
b.removeAttribute('disabled');
132-
else
133-
b.setAttribute('disabled', '');
134-
else if (command === 'connectClient')
135-
if (!multiplayer)
136-
b.removeAttribute('disabled');
137-
else
138-
b.setAttribute('disabled', '');
139-
else if (!target ? true : !target.canExecuteCommand({ type: command, parameter: commandParameter }))
140-
b.setAttribute('disabled', '');
130+
b.disabled = false;
141131
else
142-
b.removeAttribute('disabled');
132+
b.disabled = !target ? true : !target.canExecuteCommand({ type: command, parameter: commandParameter });
143133
});
144134
}
145135
}

dist/UndoRedoGraph.js

Lines changed: 0 additions & 132 deletions
This file was deleted.

dist/appShell.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NpmPackageLoader, BaseCustomWebcomponentBindingsService, JsonFileElementsService, DocumentContainer, CopyPasteAsJsonService, UnkownElementsPropertiesService, sleep, BindingsRefactorService, TextRefactorService, SeperatorContextMenu, DomConverter, ValueType, UndoService } from '@node-projects/web-component-designer';
1+
import { NpmPackageLoader, BaseCustomWebcomponentBindingsService, JsonFileElementsService, DocumentContainer, CopyPasteAsJsonService, UnkownElementsPropertiesService, sleep, BindingsRefactorService, TextRefactorService, SeperatorContextMenu, DomConverter, ValueType } from '@node-projects/web-component-designer';
22
import createDefaultServiceContainer from '@node-projects/web-component-designer/dist/elements/services/DefaultServiceBootstrap.js';
33
import { NodeHtmlParserService } from '@node-projects/web-component-designer-htmlparserservice-nodehtmlparser';
44
import { CodeViewMonaco } from '@node-projects/web-component-designer-codeview-monaco';
@@ -16,7 +16,6 @@ serviceContainer.register("bindableObjectsService", new CustomBindableObjectsSer
1616
serviceContainer.registerLast("propertyService", new UnkownElementsPropertiesService());
1717
serviceContainer.register("refactorService", new BindingsRefactorService());
1818
serviceContainer.register("refactorService", new TextRefactorService());
19-
serviceContainer.register("undoService", (designerCanvas) => new UndoService(designerCanvas, true));
2019
serviceContainer.config.codeViewWidget = CodeViewMonaco;
2120
serviceContainer.designerContextMenuExtensions.push(new ExpandCollapseContextMenu());
2221
serviceContainer.designerContextMenuExtensions.push(new SeperatorContextMenu(), new EditTemplateContextMenu());
@@ -249,7 +248,7 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
249248
}
250249
});
251250
await this._setupServiceContainer();
252-
this._bindableObjectsBrowser.initialize(serviceContainer);
251+
this._bindableObjectsBrowser.initialize(serviceContainer, null, 'itemsView');
253252
//@ts-ignore
254253
this._propertyGrid.propertyGrid.propertyGroupHover = (group) => group.properties?.[0]?.styleDeclaration;
255254
this._propertyGrid.propertyGrid.propertyContextMenuProvider = (designItems, property) => {
@@ -280,7 +279,7 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
280279
this.jumpToCss(group.properties?.[0]?.styleDeclaration?.ast?.parent, group.properties?.[0]?.styleDeclaration?.stylesheet);
281280
//}
282281
};
283-
this.newDocument(code, style, false);
282+
this.newDocument(false, code, style);
284283
await sleep(200);
285284
this.activateDockById('treeUpper');
286285
}
@@ -332,9 +331,9 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
332331
this._paletteTree.loadControls(serviceContainer, serviceContainer.elementsServices);
333332
this._propertyGrid.serviceContainer = serviceContainer;
334333
}
335-
newDocument(code, style, useIframe) {
334+
newDocument(fixedWidth, code, style) {
336335
this._documentNumber++;
337-
let sampleDocument = new DocumentContainer(serviceContainer, null, useIframe);
336+
let sampleDocument = new DocumentContainer(serviceContainer);
338337
sampleDocument.setAttribute('dock-spawn-panel-type', 'document');
339338
sampleDocument.title = "document-" + this._documentNumber;
340339
sampleDocument.additionalStylesheets = [
@@ -377,6 +376,10 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
377376
}
378377
}, true);
379378
this._dock.appendChild(sampleDocument);
379+
if (fixedWidth) {
380+
sampleDocument.designerView.designerWidth = '400px';
381+
sampleDocument.designerView.designerHeight = '400px';
382+
}
380383
if (code) {
381384
sampleDocument.content = code;
382385
}

dist/services/CustomBindableObjectsService.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { BindableObjectType } from "@node-projects/web-component-designer";
22
export class CustomBindableObjectsService {
3+
hasObjectsForInstanceServiceContainer(instanceServiceContainer, source) {
4+
return true;
5+
}
36
name = 'custom';
47
async getBindableObject(fullName) {
58
let objs = await this.getBindableObjects();

0 commit comments

Comments
 (0)