@node-projects/web-component-designer 0.0.59 → 0.0.63
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/.github/FUNDING.yml +3 -0
- package/dist/commandHandling/CommandType.d.ts +3 -0
- package/dist/commandHandling/CommandType.js +3 -0
- package/dist/elements/documentContainer.d.ts +10 -0
- package/dist/elements/documentContainer.js +88 -11
- package/dist/elements/services/DefaultServiceBootstrap.js +5 -0
- package/dist/elements/services/GlobalContext.d.ts +4 -0
- package/dist/elements/services/GlobalContext.js +12 -0
- package/dist/elements/services/ServiceContainer.d.ts +5 -0
- package/dist/elements/services/ServiceContainer.js +4 -0
- package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +6 -0
- package/dist/elements/services/demoProviderService/DemoProviderService.js +28 -0
- package/dist/elements/services/demoProviderService/IDemoProviderService.d.ts +5 -0
- package/dist/elements/services/demoProviderService/IDemoProviderService.js +1 -0
- package/dist/elements/services/undoService/UndoService.js +3 -0
- package/dist/elements/widgets/codeView/ICodeView.d.ts +2 -0
- package/dist/elements/widgets/codeView/code-view-ace.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-ace.js +3 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +3 -1
- package/dist/elements/widgets/codeView/code-view-monaco.d.ts +2 -1
- package/dist/elements/widgets/codeView/code-view-monaco.js +11 -1
- package/dist/elements/widgets/demoView/demoView.d.ts +1 -1
- package/dist/elements/widgets/demoView/demoView.js +3 -22
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.d.ts +7 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.js +11 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.d.ts +8 -0
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider.js +11 -0
- package/dist/elements/widgets/designerView/DesignContext.d.ts +3 -0
- package/dist/elements/widgets/designerView/DesignContext.js +1 -0
- package/dist/elements/widgets/designerView/DesignerViewUseOverlayScollbars.d.ts +7 -0
- package/dist/elements/widgets/designerView/DesignerViewUseOverlayScollbars.js +13 -0
- package/dist/elements/widgets/designerView/IDesignContext.d.ts +3 -0
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.d.ts +5 -0
- package/dist/elements/widgets/designerView/IDesignViewConfigButtonsProvider.js +1 -0
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +2 -0
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -2
- package/dist/elements/widgets/designerView/designerCanvas.js +28 -13
- package/dist/elements/widgets/designerView/designerView.d.ts +3 -1
- package/dist/elements/widgets/designerView/designerView.js +20 -2
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.d.ts +5 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.js +12 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.d.ts +6 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.js +21 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.d.ts +10 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.js +18 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.d.ts +1 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.js +2 -1
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.d.ts +5 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.js +12 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.d.ts +10 -0
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.js +18 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.d.ts +0 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.js +1 -0
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.d.ts +3 -0
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.js +1 -0
- package/dist/elements/widgets/designerView/overlayLayerView.d.ts +1 -0
- package/dist/elements/widgets/designerView/overlayLayerView.js +6 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +9 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +95 -29
- package/dist/elements/widgets/designerView/tools/PointerTool.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//todo, element moving does not work atm, needs to be fixed
|
|
2
|
+
export class DesignerViewUseOverlayScollbars {
|
|
3
|
+
constructor() {
|
|
4
|
+
}
|
|
5
|
+
provideButtons(designerView, designerCanvas) {
|
|
6
|
+
let externalCss = document.createElement('style');
|
|
7
|
+
externalCss.innerHTML = '@import url("./node_modules/overlayscrollbars/css/OverlayScrollbars.min.css");';
|
|
8
|
+
designerCanvas.shadowRoot.appendChild(externalCss);
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
setTimeout(() => OverlayScrollbars([designerCanvas._outercanvas2], {}), 5000);
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,6 +8,7 @@ import { IUiCommandHandler } from "../../../commandHandling/IUiCommandHandler";
|
|
|
8
8
|
import { IPoint } from "../../../interfaces/IPoint";
|
|
9
9
|
import { OverlayLayerView } from "./overlayLayerView";
|
|
10
10
|
import { IRect } from "../../../interfaces/IRect.js";
|
|
11
|
+
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
11
12
|
export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
|
|
12
13
|
readonly serviceContainer: ServiceContainer;
|
|
13
14
|
readonly instanceServiceContainer: InstanceServiceContainer;
|
|
@@ -19,6 +20,7 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
|
|
|
19
20
|
readonly shadowRoot: ShadowRoot;
|
|
20
21
|
readonly alignOnGrid: boolean;
|
|
21
22
|
readonly alignOnSnap: boolean;
|
|
23
|
+
readonly onContentChanged: TypedEvent<void>;
|
|
22
24
|
zoomFactor: number;
|
|
23
25
|
eatEvents: Element;
|
|
24
26
|
initialize(serviceContainer: ServiceContainer): any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServiceContainer } from '../../services/ServiceContainer';
|
|
2
2
|
import { InstanceServiceContainer } from '../../services/InstanceServiceContainer';
|
|
3
3
|
import { IDesignItem } from '../../item/IDesignItem';
|
|
4
|
-
import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
|
|
4
|
+
import { BaseCustomWebComponentLazyAppend, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
5
5
|
import { IDesignerCanvas } from './IDesignerCanvas';
|
|
6
6
|
import { Snaplines } from './Snaplines';
|
|
7
7
|
import { ContextMenuHelper } from '../../helper/contextMenu/ContextMenuHelper';
|
|
@@ -28,6 +28,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
28
28
|
private _zoomFactor;
|
|
29
29
|
get zoomFactor(): number;
|
|
30
30
|
set zoomFactor(value: number);
|
|
31
|
+
onContentChanged: TypedEvent<void>;
|
|
31
32
|
private _canvas;
|
|
32
33
|
private _canvasContainer;
|
|
33
34
|
private _outercanvas2;
|
|
@@ -72,7 +73,6 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
72
73
|
getNormalizedEventCoordinates(event: MouseEvent): IPoint;
|
|
73
74
|
getNormalizedElementCoordinates(element: Element): IRect;
|
|
74
75
|
getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
|
|
75
|
-
static getHost(node: Node): Element;
|
|
76
76
|
getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): HTMLElement;
|
|
77
77
|
_rect: SVGRectElement;
|
|
78
78
|
private _pointerEventHandler;
|
|
@@ -3,7 +3,7 @@ import { InstanceServiceContainer } from '../../services/InstanceServiceContaine
|
|
|
3
3
|
import { UndoService } from '../../services/undoService/UndoService';
|
|
4
4
|
import { SelectionService } from '../../services/selectionService/SelectionService';
|
|
5
5
|
import { DesignItem } from '../../item/DesignItem';
|
|
6
|
-
import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
6
|
+
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
7
7
|
import { dragDropFormatName } from '../../../Constants';
|
|
8
8
|
import { ContentService } from '../../services/contentService/ContentService';
|
|
9
9
|
import { InsertAction } from '../../services/undoService/transactionItems/InsertAction';
|
|
@@ -42,6 +42,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
42
42
|
this._zoomFactor = value;
|
|
43
43
|
this.zoomFactorChanged();
|
|
44
44
|
}
|
|
45
|
+
onContentChanged = new TypedEvent();
|
|
45
46
|
// Private Variables
|
|
46
47
|
_canvas;
|
|
47
48
|
_canvasContainer;
|
|
@@ -190,6 +191,21 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
190
191
|
this.serviceContainer.globalContext.tool = this.serviceContainer.designerTools.get(command.parameter);
|
|
191
192
|
}
|
|
192
193
|
break;
|
|
194
|
+
case CommandType.setStrokeColor:
|
|
195
|
+
{
|
|
196
|
+
this.serviceContainer.globalContext.strokeColor = command.parameter;
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case CommandType.setFillBrush:
|
|
200
|
+
{
|
|
201
|
+
this.serviceContainer.globalContext.fillBrush = command.parameter;
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case CommandType.setStrokeThickness:
|
|
205
|
+
{
|
|
206
|
+
this.serviceContainer.globalContext.strokeThickness = command.parameter;
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
193
209
|
case CommandType.delete:
|
|
194
210
|
this.handleDeleteCommand();
|
|
195
211
|
break;
|
|
@@ -315,6 +331,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
315
331
|
}
|
|
316
332
|
setDesignItems(designItems) {
|
|
317
333
|
this.instanceServiceContainer.undoService.clear();
|
|
334
|
+
this.overlayLayer.removeAllOverlays();
|
|
318
335
|
DomHelper.removeAllChildnodes(this.overlayLayer);
|
|
319
336
|
this.rootDesignItem.clearChildren();
|
|
320
337
|
this.addDesignItems(designItems);
|
|
@@ -496,14 +513,6 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
496
513
|
const normEl = this.getNormalizedElementCoordinates(element);
|
|
497
514
|
return { x: normEvt.x - normEl.x, y: normEvt.y - normEl.y };
|
|
498
515
|
}
|
|
499
|
-
//todo remove, is in base custom webcomp domhelper
|
|
500
|
-
static getHost(node) {
|
|
501
|
-
while (node.parentElement)
|
|
502
|
-
node = node.parentElement;
|
|
503
|
-
if (node.host)
|
|
504
|
-
return node.host;
|
|
505
|
-
return node.parentNode.host;
|
|
506
|
-
}
|
|
507
516
|
getElementAtPoint(point, ignoreElementCallback) {
|
|
508
517
|
let backupPEventsMap = new Map();
|
|
509
518
|
let currentElement = this.elementFromPoint(point.x, point.y);
|
|
@@ -549,6 +558,9 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
549
558
|
_rect;
|
|
550
559
|
_pointerEventHandler(event) {
|
|
551
560
|
this._fillCalculationrects();
|
|
561
|
+
/*let clickOnScrollbar = event.clientX - this.containerBoundingRect.x > this.containerBoundingRect.width || event.clientY - this.containerBoundingRect.y > this.containerBoundingRect.height
|
|
562
|
+
if (clickOnScrollbar) https://kingsora.github.io/OverlayScrollbars/
|
|
563
|
+
return;*/
|
|
552
564
|
if (this._pointerextensions) {
|
|
553
565
|
for (let pe of this._pointerextensions)
|
|
554
566
|
pe.refresh(event);
|
|
@@ -560,18 +572,21 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
560
572
|
let currentElement = this.serviceContainer.elementAtPointService.getElementAtPoint(this, { x: event.x, y: event.y });
|
|
561
573
|
if (currentElement === this._outercanvas2 || currentElement === this.overlayLayer || !currentElement) {
|
|
562
574
|
currentElement = this._canvas;
|
|
563
|
-
}
|
|
575
|
+
} /* else {
|
|
576
|
+
if (!DesignerCanvas.hasOrIsParent(currentElement, this._canvas))
|
|
577
|
+
return;
|
|
578
|
+
}*/
|
|
564
579
|
//TODO: remove duplication when tool refactoring starts
|
|
565
|
-
this._fillCalculationrects();
|
|
580
|
+
//this._fillCalculationrects();
|
|
566
581
|
const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, this.serviceContainer, this.instanceServiceContainer);
|
|
567
582
|
if (this._lastHoverDesignItem != currentDesignItem) {
|
|
568
583
|
if (this._lastHoverDesignItem)
|
|
569
584
|
this.extensionManager.removeExtension(this._lastHoverDesignItem, ExtensionType.MouseOver);
|
|
570
|
-
if (currentDesignItem && currentDesignItem != this.rootDesignItem &&
|
|
585
|
+
if (currentDesignItem && currentDesignItem != this.rootDesignItem && DomHelper.getHost(currentElement.parentNode) !== this.overlayLayer)
|
|
571
586
|
this.extensionManager.applyExtension(currentDesignItem, ExtensionType.MouseOver);
|
|
572
587
|
this._lastHoverDesignItem = currentDesignItem;
|
|
573
588
|
}
|
|
574
|
-
if (currentElement &&
|
|
589
|
+
if (currentElement && DomHelper.getHost(currentElement.parentNode) === this.overlayLayer) {
|
|
575
590
|
if (this.eatEvents)
|
|
576
591
|
return;
|
|
577
592
|
currentElement = this.instanceServiceContainer.selectionService.primarySelection?.element ?? this._canvas;
|
|
@@ -11,10 +11,12 @@ export declare class DesignerView extends BaseCustomWebComponentConstructorAppen
|
|
|
11
11
|
set serviceContainer(value: ServiceContainer);
|
|
12
12
|
get instanceServiceContainer(): InstanceServiceContainer;
|
|
13
13
|
set instanceServiceContainer(value: InstanceServiceContainer);
|
|
14
|
+
private _designerCanvas;
|
|
15
|
+
get designerCanvas(): DesignerCanvas;
|
|
14
16
|
private _zoomInput;
|
|
17
|
+
private _lowertoolbar;
|
|
15
18
|
static readonly style: CSSStyleSheet;
|
|
16
19
|
static readonly template: HTMLTemplateElement;
|
|
17
|
-
private _designerCanvas;
|
|
18
20
|
constructor();
|
|
19
21
|
private _onWheel;
|
|
20
22
|
get designerWidth(): string;
|
|
@@ -16,7 +16,12 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
16
16
|
set instanceServiceContainer(value) {
|
|
17
17
|
this._designerCanvas.instanceServiceContainer = value;
|
|
18
18
|
}
|
|
19
|
+
_designerCanvas;
|
|
20
|
+
get designerCanvas() {
|
|
21
|
+
return this._designerCanvas;
|
|
22
|
+
}
|
|
19
23
|
_zoomInput;
|
|
24
|
+
_lowertoolbar;
|
|
20
25
|
static style = css `
|
|
21
26
|
:host {
|
|
22
27
|
display: block;
|
|
@@ -49,6 +54,12 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
49
54
|
display: block;
|
|
50
55
|
margin-right: 1px;
|
|
51
56
|
cursor: default;
|
|
57
|
+
display: flex;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
align-items: center;
|
|
60
|
+
}
|
|
61
|
+
.selected {
|
|
62
|
+
background-color: deepskyblue;
|
|
52
63
|
}
|
|
53
64
|
.toolbar-control:hover {
|
|
54
65
|
background-color:rgba(164,206,249,.6);
|
|
@@ -92,7 +103,6 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
92
103
|
<div title="snap to elements" id="alignSnap" class="toolbar-control snap-guide"></div>
|
|
93
104
|
</div>
|
|
94
105
|
</div>`;
|
|
95
|
-
_designerCanvas;
|
|
96
106
|
constructor() {
|
|
97
107
|
super();
|
|
98
108
|
const outer = this._getDomElement('outer');
|
|
@@ -138,6 +148,7 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
138
148
|
let alignGrid = this._getDomElement('alignGrid');
|
|
139
149
|
alignGrid.onclick = () => { this._designerCanvas.alignOnGrid = !this._designerCanvas.alignOnGrid; alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : ''; };
|
|
140
150
|
alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : '';
|
|
151
|
+
this._lowertoolbar = this._getDomElement('lowertoolbar');
|
|
141
152
|
}
|
|
142
153
|
_onWheel(event) {
|
|
143
154
|
if (event.ctrlKey) {
|
|
@@ -180,15 +191,22 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
180
191
|
initialize(serviceContainer) {
|
|
181
192
|
this.serviceContainer = serviceContainer;
|
|
182
193
|
this._designerCanvas.initialize(serviceContainer);
|
|
194
|
+
if (serviceContainer.designViewConfigButtons) {
|
|
195
|
+
for (let provider of serviceContainer.designViewConfigButtons) {
|
|
196
|
+
for (let btn of provider.provideButtons(this, this._designerCanvas))
|
|
197
|
+
this._lowertoolbar.appendChild(btn);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
183
200
|
}
|
|
184
201
|
getHTML(designItemsAssignmentList) {
|
|
185
|
-
this.instanceServiceContainer.selectionService.setSelectedElements(null);
|
|
202
|
+
//this.instanceServiceContainer.selectionService.setSelectedElements(null);
|
|
186
203
|
return DomConverter.ConvertToString([...this._designerCanvas.rootDesignItem.children()], designItemsAssignmentList);
|
|
187
204
|
}
|
|
188
205
|
async parseHTML(html) {
|
|
189
206
|
const parserService = this.serviceContainer.htmlParserService;
|
|
190
207
|
if (!html) {
|
|
191
208
|
this.instanceServiceContainer.undoService.clear();
|
|
209
|
+
this._designerCanvas.overlayLayer.removeAllOverlays();
|
|
192
210
|
DomHelper.removeAllChildnodes(this._designerCanvas.overlayLayer);
|
|
193
211
|
this._designerCanvas.rootDesignItem.clearChildren();
|
|
194
212
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { gridExtensionShowOverlayOptionName } from "./GridExtensionProvider.js";
|
|
2
|
+
export class GridExtensionProviderConfigButtons {
|
|
3
|
+
aaa(extensionManager, designerView) {
|
|
4
|
+
const extensionOptions = designerView.instanceServiceContainer.designContext.extensionOptions;
|
|
5
|
+
const btn = document.createElement('div');
|
|
6
|
+
btn.onclick = () => {
|
|
7
|
+
const val = extensionOptions[gridExtensionShowOverlayOptionName];
|
|
8
|
+
extensionOptions[gridExtensionShowOverlayOptionName] = val == true ? false : true;
|
|
9
|
+
};
|
|
10
|
+
return [btn];
|
|
11
|
+
}
|
|
12
|
+
}
|
package/dist/elements/widgets/designerView/extensions/GridExtensionDesignViewConfigButtons.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DesignerView } from "../designerView.js";
|
|
2
|
+
import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
3
|
+
import { IDesignViewConfigButtonsProvider } from "../IDesignViewConfigButtonsProvider.js";
|
|
4
|
+
export declare class GridExtensionDesignViewConfigButtons implements IDesignViewConfigButtonsProvider {
|
|
5
|
+
provideButtons(designerView: DesignerView, designerCanvas: IDesignerCanvas): HTMLElement[];
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gridExtensionShowOverlayOptionName } from "./GridExtensionProvider.js";
|
|
2
|
+
export class GridExtensionDesignViewConfigButtons {
|
|
3
|
+
provideButtons(designerView, designerCanvas) {
|
|
4
|
+
const extensionOptions = designerCanvas.instanceServiceContainer.designContext.extensionOptions;
|
|
5
|
+
const btn = document.createElement('div');
|
|
6
|
+
btn.innerText = 'G';
|
|
7
|
+
btn.title = 'show grid overlay';
|
|
8
|
+
btn.className = 'toolbar-control';
|
|
9
|
+
if (extensionOptions[gridExtensionShowOverlayOptionName] !== false)
|
|
10
|
+
btn.classList.add('selected');
|
|
11
|
+
btn.onclick = () => {
|
|
12
|
+
const val = extensionOptions[gridExtensionShowOverlayOptionName];
|
|
13
|
+
extensionOptions[gridExtensionShowOverlayOptionName] = val === false ? true : false;
|
|
14
|
+
if (extensionOptions[gridExtensionShowOverlayOptionName] !== false)
|
|
15
|
+
btn.classList.add('selected');
|
|
16
|
+
else
|
|
17
|
+
btn.classList.remove('selected');
|
|
18
|
+
};
|
|
19
|
+
return [btn];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDesignerExtensionProvider } from "./IDesignerExtensionProvider";
|
|
2
|
+
import { IDesignItem } from "../../../item/IDesignItem";
|
|
3
|
+
import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
4
|
+
import { IDesignerExtension } from "./IDesignerExtension";
|
|
5
|
+
import { IExtensionManager } from "./IExtensionManger";
|
|
6
|
+
export declare class GridExtensionProvider implements IDesignerExtensionProvider {
|
|
7
|
+
shouldExtend(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): boolean;
|
|
8
|
+
getExtension(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): IDesignerExtension;
|
|
9
|
+
readonly style: CSSStyleSheet;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GridExtension } from './GridExtension';
|
|
2
|
+
import { css } from "@node-projects/base-custom-webcomponent";
|
|
3
|
+
const gridExtensionShowOverlayOptionName = 'gridExtensionShowOverlay';
|
|
4
|
+
export class GridExtensionProvider {
|
|
5
|
+
shouldExtend(extensionManager, designerView, designItem) {
|
|
6
|
+
if (getComputedStyle(designItem.element).display == 'grid')
|
|
7
|
+
return designerView.instanceServiceContainer.designContext.extensionOptions[gridExtensionShowOverlayOptionName] !== false;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
getExtension(extensionManager, designerView, designItem) {
|
|
11
|
+
return new GridExtension(extensionManager, designerView, designItem);
|
|
12
|
+
}
|
|
13
|
+
style = css `
|
|
14
|
+
.svg-grid { stroke: orange; stroke-dasharray: 5; fill: #ff944722; }
|
|
15
|
+
.svg-grid-area { font-size: 8px; }
|
|
16
|
+
.svg-grid-gap { stroke: orange; stroke-dasharray: 5; fill: #0000ff22; }
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
@@ -3,6 +3,7 @@ import { IDesignItem } from "../../../item/IDesignItem";
|
|
|
3
3
|
import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
4
4
|
import { IDesignerExtension } from "./IDesignerExtension";
|
|
5
5
|
import { IExtensionManager } from "./IExtensionManger";
|
|
6
|
+
export declare const gridExtensionShowOverlayOptionName = "gridExtensionShowOverlay";
|
|
6
7
|
export declare class GridExtensionProvider implements IDesignerExtensionProvider {
|
|
7
8
|
shouldExtend(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): boolean;
|
|
8
9
|
getExtension(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): IDesignerExtension;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GridExtension } from './GridExtension';
|
|
2
2
|
import { css } from "@node-projects/base-custom-webcomponent";
|
|
3
|
+
export const gridExtensionShowOverlayOptionName = 'gridExtensionShowOverlay';
|
|
3
4
|
export class GridExtensionProvider {
|
|
4
5
|
shouldExtend(extensionManager, designerView, designItem) {
|
|
5
6
|
if (getComputedStyle(designItem.element).display == 'grid')
|
|
6
|
-
return
|
|
7
|
+
return designerView.instanceServiceContainer.designContext.extensionOptions[gridExtensionShowOverlayOptionName] !== false;
|
|
7
8
|
return false;
|
|
8
9
|
}
|
|
9
10
|
getExtension(extensionManager, designerView, designItem) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { gridExtensionShowOverlayOptionName } from "./GridExtensionProvider.js";
|
|
2
|
+
export class GridExtensionProviderConfigButtons {
|
|
3
|
+
aaa(extensionManager, designerView) {
|
|
4
|
+
const extensionOptions = designerView.instanceServiceContainer.designContext.extensionOptions;
|
|
5
|
+
const btn = document.createElement('div');
|
|
6
|
+
btn.onclick = () => {
|
|
7
|
+
const val = extensionOptions[gridExtensionShowOverlayOptionName];
|
|
8
|
+
extensionOptions[gridExtensionShowOverlayOptionName] = val == true ? false : true;
|
|
9
|
+
};
|
|
10
|
+
return [btn];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDesignerExtensionProvider } from "./IDesignerExtensionProvider";
|
|
2
|
+
import { IDesignItem } from "../../../item/IDesignItem";
|
|
3
|
+
import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
4
|
+
import { IDesignerExtension } from "./IDesignerExtension";
|
|
5
|
+
import { IExtensionManager } from "./IExtensionManger";
|
|
6
|
+
export declare class GridExtensionProvider implements IDesignerExtensionProvider {
|
|
7
|
+
shouldExtend(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): boolean;
|
|
8
|
+
getExtension(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): IDesignerExtension;
|
|
9
|
+
readonly style: CSSStyleSheet;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GridExtension } from './GridExtension';
|
|
2
|
+
import { css } from "@node-projects/base-custom-webcomponent";
|
|
3
|
+
const gridExtensionShowOverlayOptionName = 'gridExtensionShowOverlay';
|
|
4
|
+
export class GridExtensionProvider {
|
|
5
|
+
shouldExtend(extensionManager, designerView, designItem) {
|
|
6
|
+
if (getComputedStyle(designItem.element).display == 'grid')
|
|
7
|
+
return designerView.instanceServiceContainer.designContext.extensionOptions[gridExtensionShowOverlayOptionName] !== false;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
getExtension(extensionManager, designerView, designItem) {
|
|
11
|
+
return new GridExtension(extensionManager, designerView, designItem);
|
|
12
|
+
}
|
|
13
|
+
style = css `
|
|
14
|
+
.svg-grid { stroke: orange; stroke-dasharray: 5; fill: #ff944722; }
|
|
15
|
+
.svg-grid-area { font-size: 8px; }
|
|
16
|
+
.svg-grid-gap { stroke: orange; stroke-dasharray: 5; fill: #0000ff22; }
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export declare class OverlayLayerView extends BaseCustomWebComponentConstructorA
|
|
|
15
15
|
addOverlay(element: SVGGraphicsElement, overlayLayer?: OverlayLayer): void;
|
|
16
16
|
removeOverlay(element: SVGGraphicsElement): void;
|
|
17
17
|
removeAllNodesWithClass(className: string): void;
|
|
18
|
+
removeAllOverlays(): void;
|
|
18
19
|
createPoint(): DOMPointInit;
|
|
19
20
|
elementFromPoint(x: number, y: number): Element;
|
|
20
21
|
drawLine(x1: number, y1: number, x2: number, y2: number, className?: string, line?: SVGLineElement, overlayLayer?: OverlayLayer): SVGLineElement;
|
|
@@ -80,6 +80,12 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
80
80
|
e.parentNode.removeChild(e);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
removeAllOverlays() {
|
|
84
|
+
const nodes = this._svg.querySelectorAll('svg > g > *');
|
|
85
|
+
for (const e of nodes) {
|
|
86
|
+
e.parentNode.removeChild(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
83
89
|
createPoint() {
|
|
84
90
|
//@ts-ignore
|
|
85
91
|
return this._svg.createSVGPoint();
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { IDesignerCanvas } from '../IDesignerCanvas';
|
|
2
2
|
import { ITool } from './ITool';
|
|
3
3
|
import { ServiceContainer } from '../../../services/ServiceContainer.js';
|
|
4
|
+
import { IPoint } from '../../../..';
|
|
4
5
|
export declare class DrawPathTool implements ITool {
|
|
5
6
|
readonly cursor = "crosshair";
|
|
6
7
|
private _pathD;
|
|
7
8
|
private _path;
|
|
9
|
+
private _samePoint;
|
|
10
|
+
private _p2pMode;
|
|
11
|
+
private _dragMode;
|
|
12
|
+
private _pointerMoved;
|
|
13
|
+
private _eventStarted;
|
|
14
|
+
private _lastPoint;
|
|
15
|
+
private _savedPoint;
|
|
8
16
|
constructor();
|
|
9
17
|
activated(serviceContainer: ServiceContainer): void;
|
|
10
18
|
dispose(): void;
|
|
11
19
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
20
|
+
straightenLine(p1: IPoint, p2: IPoint): IPoint;
|
|
12
21
|
}
|
|
@@ -7,6 +7,13 @@ export class DrawPathTool {
|
|
|
7
7
|
cursor = 'crosshair';
|
|
8
8
|
_pathD;
|
|
9
9
|
_path;
|
|
10
|
+
_samePoint = false;
|
|
11
|
+
_p2pMode = false;
|
|
12
|
+
_dragMode = false;
|
|
13
|
+
_pointerMoved = false;
|
|
14
|
+
_eventStarted = false;
|
|
15
|
+
_lastPoint = { x: 0, y: 0 };
|
|
16
|
+
_savedPoint = { x: 0, y: 0 };
|
|
10
17
|
constructor() {
|
|
11
18
|
}
|
|
12
19
|
activated(serviceContainer) {
|
|
@@ -18,43 +25,102 @@ export class DrawPathTool {
|
|
|
18
25
|
const offset = 50;
|
|
19
26
|
switch (event.type) {
|
|
20
27
|
case EventNames.PointerDown:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
this._eventStarted = true;
|
|
29
|
+
if (!this._p2pMode) {
|
|
30
|
+
event.target.setPointerCapture(event.pointerId);
|
|
31
|
+
this._path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
32
|
+
this._pathD = "M" + currentPoint.x + " " + currentPoint.y;
|
|
33
|
+
this._path.setAttribute("D", this._pathD);
|
|
34
|
+
this._path.setAttribute("stroke", designerCanvas.serviceContainer.globalContext.strokeColor);
|
|
35
|
+
this._path.setAttribute("fill", designerCanvas.serviceContainer.globalContext.fillBrush);
|
|
36
|
+
this._path.setAttribute("stroke-width", designerCanvas.serviceContainer.globalContext.strokeThickness);
|
|
37
|
+
designerCanvas.overlayLayer.addOverlay(this._path, OverlayLayer.Foregorund);
|
|
38
|
+
}
|
|
39
|
+
if (this._lastPoint.x === currentPoint.x && this._lastPoint.y === currentPoint.y && !this._samePoint) {
|
|
40
|
+
this._samePoint = true;
|
|
41
|
+
}
|
|
42
|
+
this._lastPoint = currentPoint;
|
|
28
43
|
break;
|
|
29
44
|
case EventNames.PointerMove:
|
|
30
|
-
if (this.
|
|
31
|
-
this.
|
|
32
|
-
|
|
45
|
+
if (this._eventStarted) {
|
|
46
|
+
this._pointerMoved = true;
|
|
47
|
+
}
|
|
48
|
+
if (!this._p2pMode) {
|
|
49
|
+
this._dragMode = true;
|
|
50
|
+
if (this._path) {
|
|
51
|
+
this._pathD += "L" + currentPoint.x + " " + currentPoint.y;
|
|
52
|
+
this._path.setAttribute("d", this._pathD);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else { // shows line preview
|
|
56
|
+
if (this._path) {
|
|
57
|
+
let straightLine = currentPoint;
|
|
58
|
+
if (event.shiftKey)
|
|
59
|
+
straightLine = this.straightenLine(this._savedPoint, currentPoint);
|
|
60
|
+
this._path.setAttribute("d", this._pathD + "L" + straightLine.x + " " + straightLine.y);
|
|
61
|
+
}
|
|
33
62
|
}
|
|
34
63
|
break;
|
|
35
64
|
case EventNames.PointerUp:
|
|
36
65
|
event.target.releasePointerCapture(event.pointerId);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
if (this._eventStarted && !this._pointerMoved) {
|
|
67
|
+
this._p2pMode = true;
|
|
68
|
+
}
|
|
69
|
+
if (this._p2pMode && !this._samePoint) {
|
|
70
|
+
if (this._path) {
|
|
71
|
+
if (event.shiftKey) {
|
|
72
|
+
let straightLine = this.straightenLine(this._savedPoint, currentPoint);
|
|
73
|
+
this._pathD += "L" + straightLine.x + " " + straightLine.y;
|
|
74
|
+
this._path.setAttribute("d", this._pathD);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this._pathD += "L" + currentPoint.x + " " + currentPoint.y;
|
|
78
|
+
this._path.setAttribute("d", this._pathD);
|
|
79
|
+
}
|
|
80
|
+
this._savedPoint = currentPoint;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (this._samePoint && this._p2pMode || this._dragMode && !this._p2pMode) {
|
|
84
|
+
this._eventStarted = false;
|
|
85
|
+
this._p2pMode = false;
|
|
86
|
+
this._pointerMoved = false;
|
|
87
|
+
this._samePoint = false;
|
|
88
|
+
this._dragMode = false;
|
|
89
|
+
const rect = this._path.getBoundingClientRect();
|
|
90
|
+
designerCanvas.overlayLayer.removeOverlay(this._path);
|
|
91
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
92
|
+
const mvX = rect.x - designerCanvas.containerBoundingRect.x - offset;
|
|
93
|
+
const mvY = rect.y - designerCanvas.containerBoundingRect.y - offset;
|
|
94
|
+
const d = movePathData(this._path, mvX, mvY);
|
|
95
|
+
this._path.setAttribute("d", d);
|
|
96
|
+
svg.appendChild(this._path);
|
|
97
|
+
svg.style.left = (mvX) + 'px';
|
|
98
|
+
svg.style.top = (mvY) + 'px';
|
|
99
|
+
svg.style.position = 'absolute';
|
|
100
|
+
svg.style.width = (rect.width + 2 * offset) + 'px';
|
|
101
|
+
svg.style.height = (rect.height + 2 * offset) + 'px';
|
|
102
|
+
//designerView.rootDesignItem.element.appendChild(svg);
|
|
103
|
+
this._path = null;
|
|
104
|
+
this._pathD = null;
|
|
105
|
+
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
106
|
+
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
107
|
+
designerCanvas.serviceContainer.globalContext.finishedWithTool(this);
|
|
108
|
+
}
|
|
56
109
|
//TODO: Better Path drawing (like in SVGEDIT & Adding via Undo Framework. And adding to correct container)
|
|
57
110
|
break;
|
|
58
111
|
}
|
|
59
112
|
}
|
|
113
|
+
straightenLine(p1, p2) {
|
|
114
|
+
let newP = { x: 0, y: 0 };
|
|
115
|
+
let alpha = -1 * Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
|
|
116
|
+
if (alpha < 0)
|
|
117
|
+
alpha += 360;
|
|
118
|
+
if (alpha > 0 && alpha < 45 || alpha > 315 && alpha < 360 || alpha > 135 && alpha < 225) // right or left
|
|
119
|
+
newP = { x: p2.x, y: p1.y };
|
|
120
|
+
else if (alpha > 45 && alpha < 135 || alpha > 225 && alpha < 315) // up or down
|
|
121
|
+
newP = { x: p1.x, y: p2.y };
|
|
122
|
+
else // something else
|
|
123
|
+
newP = { x: p2.x, y: p2.y };
|
|
124
|
+
return newP;
|
|
125
|
+
}
|
|
60
126
|
}
|
|
@@ -3,7 +3,7 @@ import { PointerActionType } from "../../../../enums/PointerActionType";
|
|
|
3
3
|
import { DesignItem } from "../../../item/DesignItem";
|
|
4
4
|
import { ExtensionType } from "../extensions/ExtensionType";
|
|
5
5
|
import { NamedTools } from './NamedTools';
|
|
6
|
-
import {
|
|
6
|
+
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
7
7
|
export class PointerTool {
|
|
8
8
|
cursor = 'default';
|
|
9
9
|
_movedSinceStartedAction = false;
|
|
@@ -101,7 +101,7 @@ export class PointerTool {
|
|
|
101
101
|
currentDesignItem.element.style.pointerEvents = 'none';
|
|
102
102
|
}
|
|
103
103
|
let currentElement = designerCanvas.elementFromPoint(event.x, event.y);
|
|
104
|
-
if (
|
|
104
|
+
if (DomHelper.getHost(currentElement) !== designerCanvas.overlayLayer)
|
|
105
105
|
currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
106
106
|
}
|
|
107
107
|
else {
|