@node-projects/web-component-designer 0.0.65 → 0.0.66
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/services/DefaultServiceBootstrap.js +4 -2
- package/dist/elements/services/placementService/DefaultPlacementService.js +1 -1
- package/dist/elements/services/placementService/ISnaplinesProviderService.d.ts +5 -4
- package/dist/elements/services/placementService/SnaplinesProviderService.d.ts +5 -4
- package/dist/elements/services/placementService/SnaplinesProviderService.js +15 -13
- package/dist/elements/widgets/designerView/IPlacementView.d.ts +2 -0
- package/dist/elements/widgets/designerView/Snaplines.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +1 -4
- package/dist/elements/widgets/designerView/designerView.d.ts +3 -0
- package/dist/elements/widgets/designerView/designerView.js +15 -2
- package/dist/elements/widgets/designerView/extensions/AltToEnterContainerExtension.js +3 -3
- package/dist/elements/widgets/designerView/extensions/SelectionDefaultExtension.js +2 -2
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.d.ts +2 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +28 -10
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +31 -12
- package/dist/elements/widgets/designerView/tools/PointerTool.js +1 -1
- package/dist/elements/widgets/paletteView/paletteTreeView.js +0 -5
- package/package.json +1 -1
- package/dist/elements/controls/SimpleSplitView2.d.ts +0 -11
- package/dist/elements/controls/SimpleSplitView2.js +0 -63
- package/dist/elements/controls/aa.d.ts +0 -24
- package/dist/elements/controls/aa.js +0 -98
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.d.ts +0 -7
- package/dist/elements/widgets/designerView/ButtonSeperatorProvider copy.js +0 -11
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.d.ts +0 -5
- package/dist/elements/widgets/designerView/extensions/GridExtensionConfigButtons.js +0 -12
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/GridExtensionProvider copy.js +0 -18
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.d.ts +0 -5
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderConfigButtons.js +0 -12
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.d.ts +0 -10
- package/dist/elements/widgets/designerView/extensions/GridExtensionProviderOptions.js +0 -18
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.d.ts +0 -0
- package/dist/elements/widgets/designerView/extensions/IDesignViewConfigButtonsProvider.js +0 -1
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.d.ts +0 -3
- package/dist/elements/widgets/designerView/extensions/IExtensionConfiguration.js +0 -1
|
@@ -48,7 +48,7 @@ import { DefaultModelCommandService } from './modelCommandService/DefaultModelCo
|
|
|
48
48
|
import { ButtonSeperatorProvider } from '../widgets/designerView/ButtonSeperatorProvider';
|
|
49
49
|
import { GridExtensionDesignViewConfigButtons } from '../widgets/designerView/extensions/GridExtensionDesignViewConfigButtons';
|
|
50
50
|
import { DemoProviderService } from './demoProviderService/DemoProviderService';
|
|
51
|
-
import { CursorLinePointerExtensionProvider } from '../widgets/designerView/extensions/pointerExtensions/CursorLinePointerExtensionProvider.js';
|
|
51
|
+
//import { CursorLinePointerExtensionProvider } from '../widgets/designerView/extensions/pointerExtensions/CursorLinePointerExtensionProvider.js';
|
|
52
52
|
import { DrawRectTool } from '../widgets/designerView/tools/DrawRectTool.js';
|
|
53
53
|
import { DrawEllipsisTool } from '../widgets/designerView/tools/DrawEllipsisTool.js';
|
|
54
54
|
import { DrawLineTool } from '../widgets/designerView/tools/DrawLineTool.js';
|
|
@@ -117,7 +117,9 @@ export function createDefaultServiceContainer() {
|
|
|
117
117
|
serviceContainer.designerTools.set(NamedTools.MagicWandSelector, new MagicWandSelectorTool());
|
|
118
118
|
serviceContainer.designerTools.set(NamedTools.PickColor, new PickColorTool());
|
|
119
119
|
serviceContainer.designerTools.set(NamedTools.Text, new TextTool());
|
|
120
|
-
serviceContainer.designerPointerExtensions.push(
|
|
120
|
+
serviceContainer.designerPointerExtensions.push(
|
|
121
|
+
//new CursorLinePointerExtensionProvider()
|
|
122
|
+
);
|
|
121
123
|
serviceContainer.designViewConfigButtons.push(new ButtonSeperatorProvider(20), new GridExtensionDesignViewConfigButtons());
|
|
122
124
|
serviceContainer.designerContextMenuExtensions = [
|
|
123
125
|
new CopyPasteContextMenu(),
|
|
@@ -31,7 +31,7 @@ export class DefaultPlacementService {
|
|
|
31
31
|
}
|
|
32
32
|
else if (placementView.alignOnSnap) {
|
|
33
33
|
let rect = item.element.getBoundingClientRect();
|
|
34
|
-
let newPos = placementView.snapLines.snapToPosition({ x: newPoint.x - offsetInControl.x, y: newPoint.y - offsetInControl.y }, { width: rect.width, height: rect.height }, { x: trackX > 0 ? 1 : -1, y: trackY > 0 ? 1 : -1 });
|
|
34
|
+
let newPos = placementView.snapLines.snapToPosition({ x: (newPoint.x - offsetInControl.x), y: (newPoint.y - offsetInControl.y) }, { width: rect.width / placementView.scaleFactor, height: rect.height / placementView.scaleFactor }, { x: trackX > 0 ? 1 : -1, y: trackY > 0 ? 1 : -1 });
|
|
35
35
|
if (newPos.x !== null) {
|
|
36
36
|
trackX = newPos.x - Math.round(startPoint.x) + Math.round(offsetInControl.x);
|
|
37
37
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IService } from "../IService";
|
|
2
2
|
import { IDesignItem } from "../../item/IDesignItem";
|
|
3
|
+
import { IRect } from "../../../interfaces/IRect.js";
|
|
3
4
|
export interface ISnaplinesProviderService extends IService {
|
|
4
5
|
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
6
|
outerRect: DOMRect;
|
|
6
|
-
positionsH: [number,
|
|
7
|
-
positionsMiddleH: [number,
|
|
8
|
-
positionsV: [number,
|
|
9
|
-
positionsMiddleV: [number,
|
|
7
|
+
positionsH: [number, IRect][];
|
|
8
|
+
positionsMiddleH: [number, IRect][];
|
|
9
|
+
positionsV: [number, IRect][];
|
|
10
|
+
positionsMiddleV: [number, IRect][];
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { IRect } from '../../../interfaces/IRect.js';
|
|
1
2
|
import type { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
3
|
import { ISnaplinesProviderService } from './ISnaplinesProviderService.js';
|
|
3
4
|
export declare class SnaplinesProviderService implements ISnaplinesProviderService {
|
|
4
5
|
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
6
|
outerRect: DOMRect;
|
|
6
|
-
positionsH: [number,
|
|
7
|
-
positionsMiddleH: [number,
|
|
8
|
-
positionsV: [number,
|
|
9
|
-
positionsMiddleV: [number,
|
|
7
|
+
positionsH: [number, IRect][];
|
|
8
|
+
positionsMiddleH: [number, IRect][];
|
|
9
|
+
positionsV: [number, IRect][];
|
|
10
|
+
positionsMiddleV: [number, IRect][];
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -2,6 +2,7 @@ import { DomHelper } from '@node-projects/base-custom-webcomponent';
|
|
|
2
2
|
export class SnaplinesProviderService {
|
|
3
3
|
provideSnaplines(containerItem, ignoredItems) {
|
|
4
4
|
{
|
|
5
|
+
const canvas = containerItem.instanceServiceContainer.designerCanvas;
|
|
5
6
|
const ignMap = new Map(ignoredItems.map(i => [i.element, i]));
|
|
6
7
|
const outerRect = containerItem.element.getBoundingClientRect();
|
|
7
8
|
const positionsH = [];
|
|
@@ -11,19 +12,20 @@ export class SnaplinesProviderService {
|
|
|
11
12
|
let ignoreElements = ignoredItems.map(x => x.element);
|
|
12
13
|
for (let n of DomHelper.getAllChildNodes(containerItem.element, false, ignoreElements)) {
|
|
13
14
|
if (!ignMap.has(n)) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const p = n.getBoundingClientRect();
|
|
16
|
+
const pLeft = (p.x - outerRect.x) / canvas.scaleFactor;
|
|
17
|
+
const pMidH = (p.x - outerRect.x + p.width / 2) / canvas.scaleFactor;
|
|
18
|
+
const pRight = (p.x - outerRect.x + p.width) / canvas.scaleFactor;
|
|
19
|
+
const pTop = (p.y - outerRect.y) / canvas.scaleFactor;
|
|
20
|
+
const pMidV = (p.y - outerRect.y + p.height / 2) / canvas.scaleFactor;
|
|
21
|
+
const pBottom = (p.y - outerRect.y + p.height) / canvas.scaleFactor;
|
|
22
|
+
const transformedP = { x: pLeft + outerRect.x, y: pTop + outerRect.y, width: p.width / canvas.scaleFactor, height: p.height / canvas.scaleFactor };
|
|
23
|
+
positionsH.push([pLeft, transformedP]);
|
|
24
|
+
positionsMiddleH.push([pMidH, transformedP]);
|
|
25
|
+
positionsH.push([pRight, transformedP]);
|
|
26
|
+
positionsV.push([pTop, transformedP]);
|
|
27
|
+
positionsMiddleV.push([pMidV, transformedP]);
|
|
28
|
+
positionsV.push([pBottom, transformedP]);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
positionsH.sort((a, b) => a[0] - b[0]);
|
|
@@ -2,6 +2,7 @@ import type { IDesignItem } from "../../item/IDesignItem";
|
|
|
2
2
|
import type { IPoint } from "../../../interfaces/IPoint";
|
|
3
3
|
import type { ISize } from '../../../interfaces/ISize';
|
|
4
4
|
import { OverlayLayerView } from "./overlayLayerView";
|
|
5
|
+
import { IRect } from "../../../interfaces/IRect.js";
|
|
5
6
|
export declare class Snaplines {
|
|
6
7
|
snapOffset: number;
|
|
7
8
|
private _overlayLayerView;
|
|
@@ -16,5 +17,5 @@ export declare class Snaplines {
|
|
|
16
17
|
clearSnaplines(): void;
|
|
17
18
|
calculateSnaplines(ignoredItems: IDesignItem[]): void;
|
|
18
19
|
snapToPosition(position: IPoint, size: ISize, moveDirection: IPoint): IPoint;
|
|
19
|
-
drawSnaplines(position: IPoint, size: ISize, rectsH:
|
|
20
|
+
drawSnaplines(position: IPoint, size: ISize, rectsH: IRect[], rectsV: IRect[]): void;
|
|
20
21
|
}
|
|
@@ -530,7 +530,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
530
530
|
}
|
|
531
531
|
getNormalizedElementCoordinates(element) {
|
|
532
532
|
const targetRect = element.getBoundingClientRect();
|
|
533
|
-
return { x: targetRect.x - this.containerBoundingRect.x, y: targetRect.y - this.containerBoundingRect.y, width: targetRect.width, height: targetRect.height };
|
|
533
|
+
return { x: (targetRect.x - this.containerBoundingRect.x) / this.scaleFactor, y: (targetRect.y - this.containerBoundingRect.y) / this.scaleFactor, width: targetRect.width / this.scaleFactor, height: targetRect.height / this.scaleFactor };
|
|
534
534
|
}
|
|
535
535
|
getNormalizedOffsetInElement(event, element) {
|
|
536
536
|
const normEvt = this.getNormalizedEventCoordinates(event);
|
|
@@ -582,9 +582,6 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
582
582
|
_rect;
|
|
583
583
|
_pointerEventHandler(event) {
|
|
584
584
|
this._fillCalculationrects();
|
|
585
|
-
/*let clickOnScrollbar = event.clientX - this.containerBoundingRect.x > this.containerBoundingRect.width || event.clientY - this.containerBoundingRect.y > this.containerBoundingRect.height
|
|
586
|
-
if (clickOnScrollbar) https://kingsora.github.io/OverlayScrollbars/
|
|
587
|
-
return;*/
|
|
588
585
|
if (this._pointerextensions) {
|
|
589
586
|
for (let pe of this._pointerextensions)
|
|
590
587
|
pe.refresh(event);
|
|
@@ -7,6 +7,8 @@ import { DesignerCanvas } from "./designerCanvas.js";
|
|
|
7
7
|
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
8
8
|
import { IStringPosition } from '../../services/htmlWriterService/IStringPosition.js';
|
|
9
9
|
export declare class DesignerView extends BaseCustomWebComponentConstructorAppend implements IUiCommandHandler {
|
|
10
|
+
private _sVert;
|
|
11
|
+
private _sHor;
|
|
10
12
|
get serviceContainer(): ServiceContainer;
|
|
11
13
|
set serviceContainer(value: ServiceContainer);
|
|
12
14
|
get instanceServiceContainer(): InstanceServiceContainer;
|
|
@@ -18,6 +20,7 @@ export declare class DesignerView extends BaseCustomWebComponentConstructorAppen
|
|
|
18
20
|
static readonly style: CSSStyleSheet;
|
|
19
21
|
static readonly template: HTMLTemplateElement;
|
|
20
22
|
constructor();
|
|
23
|
+
private _onScrollbar;
|
|
21
24
|
private _onWheel;
|
|
22
25
|
get designerWidth(): string;
|
|
23
26
|
set designerWidth(value: string);
|
|
@@ -5,6 +5,8 @@ import { DefaultHtmlParserService } from '../../services/htmlParserService/Defau
|
|
|
5
5
|
import { EventNames } from '../../../enums/EventNames.js';
|
|
6
6
|
const autoZomOffset = 10;
|
|
7
7
|
export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
8
|
+
_sVert;
|
|
9
|
+
_sHor;
|
|
8
10
|
get serviceContainer() {
|
|
9
11
|
return this._designerCanvas.serviceContainer;
|
|
10
12
|
}
|
|
@@ -114,8 +116,8 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
114
116
|
}`;
|
|
115
117
|
static template = html `
|
|
116
118
|
<div id="outer">
|
|
117
|
-
<node-projects-plain-scrollbar value="0.5" class="bottom-scroll"></node-projects-plain-scrollbar>
|
|
118
|
-
<node-projects-plain-scrollbar value="0.5" orientation="vertical" class="right-scroll"></node-projects-plain-scrollbar>
|
|
119
|
+
<node-projects-plain-scrollbar id="s-hor" value="0.5" class="bottom-scroll"></node-projects-plain-scrollbar>
|
|
120
|
+
<node-projects-plain-scrollbar id="s-vert" value="0.5" orientation="vertical" class="right-scroll"></node-projects-plain-scrollbar>
|
|
119
121
|
<div class="bottom-right"></div>
|
|
120
122
|
<div id="lowertoolbar">
|
|
121
123
|
<input id="zoomInput" type="text" value="100%">
|
|
@@ -163,6 +165,8 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
163
165
|
zoomReset.onclick = () => {
|
|
164
166
|
this._designerCanvas.canvasOffset = { x: 0, y: 0 };
|
|
165
167
|
this._designerCanvas.zoomFactor = 1;
|
|
168
|
+
this._sVert.value = 0.5;
|
|
169
|
+
this._sHor.value = 0.5;
|
|
166
170
|
this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
|
|
167
171
|
};
|
|
168
172
|
let zoomFit = this._getDomElement('zoomFit');
|
|
@@ -195,6 +199,15 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
195
199
|
alignGrid.onclick = () => { this._designerCanvas.alignOnGrid = !this._designerCanvas.alignOnGrid; alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : ''; };
|
|
196
200
|
alignGrid.style.backgroundColor = this._designerCanvas.alignOnGrid ? 'deepskyblue' : '';
|
|
197
201
|
this._lowertoolbar = this._getDomElement('lowertoolbar');
|
|
202
|
+
this._sVert = this._getDomElement('s-vert');
|
|
203
|
+
this._sHor = this._getDomElement('s-hor');
|
|
204
|
+
this._sVert.addEventListener('scrollbar-input', () => this._onScrollbar());
|
|
205
|
+
this._sHor.addEventListener('scrollbar-input', () => this._onScrollbar());
|
|
206
|
+
}
|
|
207
|
+
_onScrollbar() {
|
|
208
|
+
const x = this.designerCanvas.offsetWidth * (this._sHor.value - 0.5) * -1;
|
|
209
|
+
const y = this.designerCanvas.offsetHeight * (this._sVert.value - 0.5) * -1;
|
|
210
|
+
this.designerCanvas.canvasOffset = { x, y };
|
|
198
211
|
}
|
|
199
212
|
_onWheel(event) {
|
|
200
213
|
if (event.ctrlKey) {
|
|
@@ -10,9 +10,9 @@ export class AltToEnterContainerExtension extends AbstractExtension {
|
|
|
10
10
|
this.refresh();
|
|
11
11
|
}
|
|
12
12
|
refresh() {
|
|
13
|
-
let itemRect = this.extendedItem.element
|
|
14
|
-
this._text = this._drawText("Press ALT to enter container", itemRect.x
|
|
15
|
-
this._rect = this._drawRect(itemRect.x
|
|
13
|
+
let itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
|
|
14
|
+
this._text = this._drawText("Press ALT to enter container", itemRect.x + 5, itemRect.y + 12, 'svg-text-enter-container', this._text, OverlayLayer.Foregorund);
|
|
15
|
+
this._rect = this._drawRect(itemRect.x, itemRect.y, itemRect.width, itemRect.height, 'svg-rect-enter-container', this._rect, OverlayLayer.Foregorund);
|
|
16
16
|
}
|
|
17
17
|
dispose() {
|
|
18
18
|
this._removeAllOverlays();
|
|
@@ -8,13 +8,13 @@ export class SelectionDefaultExtension extends AbstractExtension {
|
|
|
8
8
|
this.refresh();
|
|
9
9
|
}
|
|
10
10
|
refresh() {
|
|
11
|
-
const itemRect = this.extendedItem.element
|
|
11
|
+
const itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
|
|
12
12
|
const computedStyle = getComputedStyle(this.extendedItem.element);
|
|
13
13
|
const left = Number.parseFloat(computedStyle.marginLeft.replace('px', ''));
|
|
14
14
|
const top = Number.parseFloat(computedStyle.marginTop.replace('px', ''));
|
|
15
15
|
const right = Number.parseFloat(computedStyle.marginRight.replace('px', ''));
|
|
16
16
|
const bottom = Number.parseFloat(computedStyle.marginBottom.replace('px', ''));
|
|
17
|
-
this._rect = this._drawRect(
|
|
17
|
+
this._rect = this._drawRect(itemRect.x - left, itemRect.y - top, left + itemRect.width + right, top + itemRect.height + bottom, 'svg-selection', this._rect);
|
|
18
18
|
}
|
|
19
19
|
dispose() {
|
|
20
20
|
this._removeAllOverlays();
|
|
@@ -8,6 +8,8 @@ export class DrawEllipsisTool {
|
|
|
8
8
|
_path;
|
|
9
9
|
_startPoint;
|
|
10
10
|
_radius;
|
|
11
|
+
_cx;
|
|
12
|
+
_cy;
|
|
11
13
|
constructor() {
|
|
12
14
|
}
|
|
13
15
|
activated(serviceContainer) {
|
|
@@ -34,16 +36,32 @@ export class DrawEllipsisTool {
|
|
|
34
36
|
case EventNames.PointerMove:
|
|
35
37
|
if (this._path) {
|
|
36
38
|
this._radius = { x: Math.abs(currentPoint.x - this._startPoint.x), y: Math.abs(currentPoint.y - this._startPoint.y) };
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
|
|
39
|
+
if (event.ctrlKey) {
|
|
40
|
+
this._path.setAttribute("cx", this._startPoint.x.toString());
|
|
41
|
+
this._path.setAttribute("cy", this._startPoint.y.toString());
|
|
42
|
+
this._cx = this._startPoint.x;
|
|
43
|
+
this._cy = this._startPoint.y;
|
|
44
|
+
if (event.shiftKey) {
|
|
45
|
+
const radius = calculateNormLegth(this._startPoint, currentPoint);
|
|
46
|
+
this._path.setAttribute("rx", radius.toString());
|
|
47
|
+
this._path.setAttribute("ry", radius.toString());
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this._path.setAttribute("rx", this._radius.x.toString());
|
|
51
|
+
this._path.setAttribute("ry", this._radius.y.toString());
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
else {
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
if (event.shiftKey) {
|
|
56
|
+
const radius = calculateNormLegth(this._startPoint, currentPoint);
|
|
57
|
+
this._radius = { x: radius, y: radius };
|
|
58
|
+
}
|
|
59
|
+
this._cx = currentPoint.x < this._startPoint.x ? this._startPoint.x - this._radius.x / 2 : this._startPoint.x + this._radius.x / 2;
|
|
60
|
+
this._cy = currentPoint.y < this._startPoint.y ? this._startPoint.y - this._radius.y / 2 : this._startPoint.y + this._radius.y / 2;
|
|
61
|
+
this._path.setAttribute("cx", this._cx.toString());
|
|
62
|
+
this._path.setAttribute("cy", this._cy.toString());
|
|
63
|
+
this._path.setAttribute("rx", (this._radius.x / 2).toString());
|
|
64
|
+
this._path.setAttribute("ry", (this._radius.y / 2).toString());
|
|
47
65
|
}
|
|
48
66
|
}
|
|
49
67
|
break;
|
|
@@ -55,8 +73,8 @@ export class DrawEllipsisTool {
|
|
|
55
73
|
const mvX = rect.x - designerCanvas.containerBoundingRect.x - offset;
|
|
56
74
|
const mvY = rect.y - designerCanvas.containerBoundingRect.y - offset;
|
|
57
75
|
svg.appendChild(this._path);
|
|
58
|
-
this._path.setAttribute("cx", (this.
|
|
59
|
-
this._path.setAttribute("cy", (this.
|
|
76
|
+
this._path.setAttribute("cx", (this._cx - mvX).toString());
|
|
77
|
+
this._path.setAttribute("cy", (this._cy - mvY).toString());
|
|
60
78
|
svg.style.left = (mvX) + 'px';
|
|
61
79
|
svg.style.top = (mvY) + 'px';
|
|
62
80
|
svg.style.position = 'absolute';
|
|
@@ -42,22 +42,41 @@ export class DrawRectTool {
|
|
|
42
42
|
this._maxX = currentPoint.x > this._startPoint.x ? currentPoint.x : this._startPoint.x;
|
|
43
43
|
this._minY = currentPoint.y < this._startPoint.y ? currentPoint.y : this._startPoint.y;
|
|
44
44
|
this._maxY = currentPoint.y > this._startPoint.y ? currentPoint.y : this._startPoint.y;
|
|
45
|
-
if (event.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (event.ctrlKey) {
|
|
46
|
+
if (event.shiftKey) {
|
|
47
|
+
const normLength = 2 * calculateNormLegth(this._startPoint, currentPoint);
|
|
48
|
+
this._px = this._startPoint.x - normLength / 2;
|
|
49
|
+
this._py = this._startPoint.y - normLength / 2;
|
|
50
|
+
this._path.setAttribute("width", (normLength).toString());
|
|
51
|
+
this._path.setAttribute("height", (normLength).toString());
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const w = 2 * (this._maxX - this._minX);
|
|
55
|
+
const h = 2 * (this._maxY - this._minY);
|
|
56
|
+
this._px = currentPoint.x < this._startPoint.x ? currentPoint.x : this._startPoint.x - w / 2;
|
|
57
|
+
this._py = currentPoint.y < this._startPoint.y ? currentPoint.y : this._startPoint.y - h / 2;
|
|
58
|
+
this._path.setAttribute("width", (w).toString());
|
|
59
|
+
this._path.setAttribute("height", (h).toString());
|
|
60
|
+
}
|
|
49
61
|
this._path.setAttribute("x", this._px.toString());
|
|
50
62
|
this._path.setAttribute("y", this._py.toString());
|
|
51
|
-
this._path.setAttribute("width", (normLength).toString());
|
|
52
|
-
this._path.setAttribute("height", (normLength).toString());
|
|
53
63
|
}
|
|
54
64
|
else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
if (event.shiftKey) {
|
|
66
|
+
const normLength = calculateNormLegth(this._startPoint, currentPoint);
|
|
67
|
+
this._px = currentPoint.x < this._startPoint.x ? this._startPoint.x - normLength : this._startPoint.x;
|
|
68
|
+
this._py = currentPoint.y < this._startPoint.y ? this._startPoint.y - normLength : this._startPoint.y;
|
|
69
|
+
this._path.setAttribute("width", (normLength).toString());
|
|
70
|
+
this._path.setAttribute("height", (normLength).toString());
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this._px = currentPoint.x < this._startPoint.x ? currentPoint.x : this._startPoint.x;
|
|
74
|
+
this._py = currentPoint.y < this._startPoint.y ? currentPoint.y : this._startPoint.y;
|
|
75
|
+
this._path.setAttribute("width", (this._maxX - this._minX).toString());
|
|
76
|
+
this._path.setAttribute("height", (this._maxY - this._minY).toString());
|
|
77
|
+
}
|
|
78
|
+
this._path.setAttribute("x", this._px.toString());
|
|
79
|
+
this._path.setAttribute("y", this._py.toString());
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
break;
|
|
@@ -23,7 +23,7 @@ export class PointerTool {
|
|
|
23
23
|
dispose() {
|
|
24
24
|
}
|
|
25
25
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
26
|
-
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
|
|
26
|
+
if (((event.ctrlKey || event.metaKey) && event.shiftKey) || event.buttons == 4) {
|
|
27
27
|
const panTool = designerCanvas.serviceContainer.designerTools.get(NamedTools.Pan);
|
|
28
28
|
if (panTool) {
|
|
29
29
|
panTool.pointerEventHandler(designerCanvas, event, currentElement);
|
|
@@ -73,11 +73,6 @@ export class PaletteTreeView extends BaseCustomWebComponentConstructorAppend {
|
|
|
73
73
|
extensions: ['childcounter', 'dnd5', 'filter'],
|
|
74
74
|
quicksearch: true,
|
|
75
75
|
source: [],
|
|
76
|
-
activate: (event, data) => {
|
|
77
|
-
let node = data.node;
|
|
78
|
-
let designItem = node.data.ref;
|
|
79
|
-
designItem.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
|
|
80
|
-
},
|
|
81
76
|
dnd5: {
|
|
82
77
|
dropMarkerParent: this.shadowRoot,
|
|
83
78
|
preventRecursion: true,
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
-
export declare class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
-
static readonly style: CSSStyleSheet;
|
|
4
|
-
static readonly template: HTMLTemplateElement;
|
|
5
|
-
static properties: {
|
|
6
|
-
orientation: StringConstructor;
|
|
7
|
-
};
|
|
8
|
-
orientation: 'vertical' | 'horizontal';
|
|
9
|
-
constructor();
|
|
10
|
-
ready(): void;
|
|
11
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
-
export class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
-
static style = css `
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
#split {
|
|
8
|
-
position: relative;
|
|
9
|
-
height: 100%;
|
|
10
|
-
width: 100%;
|
|
11
|
-
grid-template-rows: calc(var(--split) * 1%) 5px calc((100 - var(--split)) * 1%);
|
|
12
|
-
display: grid;
|
|
13
|
-
align-items: center;
|
|
14
|
-
}
|
|
15
|
-
:host(:not([orientation="vertical"])) > div > #splitter {
|
|
16
|
-
cursor: ew-resize;
|
|
17
|
-
width: 5px;
|
|
18
|
-
}
|
|
19
|
-
:host([orientation="vertical"]) > div > #splitter {
|
|
20
|
-
cursor: ns-resize;
|
|
21
|
-
height: 5px;
|
|
22
|
-
}`;
|
|
23
|
-
static template = html `
|
|
24
|
-
<div id="split" style="--split: 50;">
|
|
25
|
-
<slot name="top"></slot>
|
|
26
|
-
<div id="splitter"></div>
|
|
27
|
-
<slot name="bottom"></slot>
|
|
28
|
-
</div>`;
|
|
29
|
-
static properties = {
|
|
30
|
-
orientation: String
|
|
31
|
-
};
|
|
32
|
-
orientation = 'vertical';
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
}
|
|
36
|
-
ready() {
|
|
37
|
-
this._parseAttributesToProperties();
|
|
38
|
-
this.setAttribute('orientation', this.orientation);
|
|
39
|
-
const split = this._getDomElement("split");
|
|
40
|
-
const splitter = this._getDomElement("splitter");
|
|
41
|
-
let start = null;
|
|
42
|
-
splitter.addEventListener('pointerdown', (e) => {
|
|
43
|
-
splitter.setPointerCapture(e.pointerId);
|
|
44
|
-
start = true;
|
|
45
|
-
});
|
|
46
|
-
splitter.addEventListener('pointerup', (e) => {
|
|
47
|
-
splitter.releasePointerCapture(e.pointerId);
|
|
48
|
-
start = null;
|
|
49
|
-
});
|
|
50
|
-
splitter.addEventListener('pointermove', (e) => {
|
|
51
|
-
if (start !== null) {
|
|
52
|
-
let splitValue = parseFloat(split.style.getPropertyValue('--split'));
|
|
53
|
-
if (this.orientation === 'horizontal')
|
|
54
|
-
splitValue += e.movementX * 100 / split.clientWidth;
|
|
55
|
-
else
|
|
56
|
-
splitValue += e.movementY * 100 / split.clientHeight;
|
|
57
|
-
if (!isNaN(splitValue))
|
|
58
|
-
split.style.setProperty("--split", splitValue);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
customElements.define('node-projects-simple-split-view', SimpleSplitView);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Split View is an image comparison component
|
|
3
|
-
*
|
|
4
|
-
* <split-view>
|
|
5
|
-
* <picture slot="top">[...]</picture>
|
|
6
|
-
* <picture slot="bottom">[...]</picture>
|
|
7
|
-
* </split-view>
|
|
8
|
-
*
|
|
9
|
-
* Options are;
|
|
10
|
-
*
|
|
11
|
-
* start (number) The point where the comparison line should start (0 = left, 1000 = right)
|
|
12
|
-
* mode (string) A CSS mix-blend-mode to use for comparison
|
|
13
|
-
*/
|
|
14
|
-
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
15
|
-
export declare class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
|
|
16
|
-
static readonly style: CSSStyleSheet;
|
|
17
|
-
static readonly template: HTMLTemplateElement;
|
|
18
|
-
static properties: {
|
|
19
|
-
start: NumberConstructor;
|
|
20
|
-
};
|
|
21
|
-
constructor();
|
|
22
|
-
start: number;
|
|
23
|
-
ready(): void;
|
|
24
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Split View is an image comparison component
|
|
3
|
-
*
|
|
4
|
-
* <split-view>
|
|
5
|
-
* <picture slot="top">[...]</picture>
|
|
6
|
-
* <picture slot="bottom">[...]</picture>
|
|
7
|
-
* </split-view>
|
|
8
|
-
*
|
|
9
|
-
* Options are;
|
|
10
|
-
*
|
|
11
|
-
* start (number) The point where the comparison line should start (0 = left, 1000 = right)
|
|
12
|
-
* mode (string) A CSS mix-blend-mode to use for comparison
|
|
13
|
-
*/
|
|
14
|
-
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
15
|
-
export class SimpleSplitView extends BaseCustomWebComponentConstructorAppend {
|
|
16
|
-
static style = css `
|
|
17
|
-
:host {
|
|
18
|
-
display: block;
|
|
19
|
-
}
|
|
20
|
-
:host([hidden]) { display: none }
|
|
21
|
-
.split {
|
|
22
|
-
position: relative;
|
|
23
|
-
height: 100%;
|
|
24
|
-
display: grid;
|
|
25
|
-
align-items: center;
|
|
26
|
-
--split: 100;
|
|
27
|
-
}
|
|
28
|
-
.top,
|
|
29
|
-
.bottom {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 0;
|
|
32
|
-
left: 0;
|
|
33
|
-
right: 0;
|
|
34
|
-
bottom: 0;
|
|
35
|
-
}
|
|
36
|
-
.bottom {
|
|
37
|
-
background-color: red;
|
|
38
|
-
}
|
|
39
|
-
.top {
|
|
40
|
-
z-index: 2;
|
|
41
|
-
right: calc(8px + (((100% - 16px) / 100) * (100 - var(--split))));
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
border-right: 1px solid white;
|
|
44
|
-
}
|
|
45
|
-
input {
|
|
46
|
-
position: absolute;
|
|
47
|
-
width: 100%;
|
|
48
|
-
height: 100%;
|
|
49
|
-
margin: 0;
|
|
50
|
-
padding: 0;
|
|
51
|
-
z-index: 3;
|
|
52
|
-
background-color: transparent;
|
|
53
|
-
-webkit-appearance: none;
|
|
54
|
-
}
|
|
55
|
-
input[type="range"]:focus {
|
|
56
|
-
outline: var(--outline, -webkit-focus-ring-color auto 1px);
|
|
57
|
-
}`;
|
|
58
|
-
static template = html `
|
|
59
|
-
<div class="split" id="split" role="img" aria-label="Comparison of two images">
|
|
60
|
-
<div class="bottom" id="bottom" aria-label="First image to compare">
|
|
61
|
-
<slot name="bottom"></slot>
|
|
62
|
-
</div>
|
|
63
|
-
<div class="top" id="top" aria-label="Second image to compare">
|
|
64
|
-
<slot name="top"></slot>
|
|
65
|
-
</div>
|
|
66
|
-
<label id="label" for="slider">Slide left and right to compare images</label>
|
|
67
|
-
<input type="range" role="slider" min="0" max="100" value="50" name="slider" id="slider" aria-labelledby="label" aria-valuemin="0" aria-valuemax="100">
|
|
68
|
-
</div>`;
|
|
69
|
-
static properties = {
|
|
70
|
-
start: Number
|
|
71
|
-
};
|
|
72
|
-
constructor() {
|
|
73
|
-
super();
|
|
74
|
-
}
|
|
75
|
-
start;
|
|
76
|
-
ready() {
|
|
77
|
-
this._parseAttributesToProperties();
|
|
78
|
-
const splitter = this._getDomElement("split");
|
|
79
|
-
const slider = this._getDomElement("slider");
|
|
80
|
-
const label = this._getDomElement("label");
|
|
81
|
-
const top = this._getDomElement("top");
|
|
82
|
-
const splitViewLabelText = this.getAttribute("split-view-label") || 'Comparison of two images';
|
|
83
|
-
const sliderLabelText = this.getAttribute("slider-label") || 'Press left and right to compare images';
|
|
84
|
-
const mode = this.getAttribute("mode") || "normal";
|
|
85
|
-
slider.addEventListener("input", (event) => {
|
|
86
|
-
const split = +event.target.value;
|
|
87
|
-
splitter.style.setProperty("--split", split);
|
|
88
|
-
slider.setAttribute('aria-valuenow', split);
|
|
89
|
-
});
|
|
90
|
-
splitter.style.setProperty("--split", this.start);
|
|
91
|
-
slider.setAttribute('aria-valuenow', this.start);
|
|
92
|
-
slider.value = this.start;
|
|
93
|
-
splitter.setAttribute('aria-label', splitViewLabelText);
|
|
94
|
-
label.innerText = sliderLabelText;
|
|
95
|
-
top.style.mixBlendMode = mode;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
customElements.define('node-projects-simple-split-view', SimpleSplitView);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IDesignerCanvas } from "./IDesignerCanvas.js";
|
|
2
|
-
import { IDesignViewConfigButtonsProvider } from "./IDesignViewConfigButtonsProvider.js";
|
|
3
|
-
export declare class ButtonSeperatorProvider implements IDesignViewConfigButtonsProvider {
|
|
4
|
-
_space: number;
|
|
5
|
-
constructor(space: number);
|
|
6
|
-
provideButtons(designerCanvas: IDesignerCanvas): HTMLElement[];
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|