@node-projects/web-component-designer 0.0.121 → 0.0.123
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/PathDataPolyfill.js +5 -5
- package/dist/elements/item/DesignItem.d.ts +1 -0
- package/dist/elements/item/DesignItem.js +4 -1
- package/dist/elements/item/IDesignItem.d.ts +1 -0
- package/dist/elements/services/htmlParserService/LitElementParserService.d.ts +12 -0
- package/dist/elements/services/htmlParserService/LitElementParserService.js +106 -0
- package/dist/elements/services/htmlParserService/NodeHtmlParserService copy.d.ts +11 -0
- package/dist/elements/services/htmlParserService/NodeHtmlParserService copy.js +96 -0
- package/dist/elements/services/placementService/FlexBoxPlacementService.js +67 -9
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +1 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +43 -3
- package/dist/elements/widgets/designerView/designerView.js +1 -27
- package/dist/elements/widgets/designerView/extensions/AbstractExtensionBase.d.ts +2 -1
- package/dist/elements/widgets/designerView/extensions/AbstractExtensionBase.js +7 -0
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.d.ts +2 -2
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +16 -14
- package/dist/elements/widgets/designerView/extensions/IExtensionManger.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/PositionExtension.d.ts +0 -2
- package/dist/elements/widgets/designerView/extensions/PositionExtension.js +6 -8
- package/dist/elements/widgets/designerView/extensions/PositionExtensionProvider.js +1 -1
- package/dist/elements/widgets/designerView/extensions/svg/EllipsisExtension.js +1 -0
- package/dist/elements/widgets/designerView/extensions/svg/LineExtension.js +1 -0
- package/dist/elements/widgets/designerView/extensions/svg/PathExtension.js +1 -0
- package/dist/elements/widgets/designerView/extensions/svg/RectExtension.js +1 -0
- package/dist/elements/widgets/designerView/overlayLayerView.d.ts +4 -1
- package/dist/elements/widgets/designerView/overlayLayerView.js +39 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +6 -6
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +6 -6
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +6 -6
- package/dist/elements/widgets/designerView/tools/PointerTool.js +3 -0
- package/dist/elements/widgets/treeView/treeViewExtended.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -916,25 +916,25 @@ export function moveSVGPath(path, xFactor, yFactor) {
|
|
|
916
916
|
case ('l'):
|
|
917
917
|
case ('T'):
|
|
918
918
|
case ('t'):
|
|
919
|
-
newPathData += p.type + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor);
|
|
919
|
+
newPathData += p.type + " " + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " ";
|
|
920
920
|
break;
|
|
921
921
|
case ('Z'):
|
|
922
922
|
case ('z'):
|
|
923
|
-
newPathData += p.type;
|
|
923
|
+
newPathData += p.type + " ";
|
|
924
924
|
break;
|
|
925
925
|
case ('C'):
|
|
926
926
|
case ('c'):
|
|
927
|
-
newPathData += p.type + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + (p.values[2] - xFactor) + " " + (p.values[3] - yFactor) + " " + (p.values[4] - xFactor) + " " + (p.values[5] - yFactor);
|
|
927
|
+
newPathData += p.type + " " + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + (p.values[2] - xFactor) + " " + (p.values[3] - yFactor) + " " + (p.values[4] - xFactor) + " " + (p.values[5] - yFactor) + " ";
|
|
928
928
|
break;
|
|
929
929
|
case ('S'):
|
|
930
930
|
case ('s'):
|
|
931
931
|
case ('Q'):
|
|
932
932
|
case ('q'):
|
|
933
|
-
newPathData += p.type + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + (p.values[2] - xFactor) + " " + (p.values[3] - yFactor);
|
|
933
|
+
newPathData += p.type + " " + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + (p.values[2] - xFactor) + " " + (p.values[3] - yFactor) + " ";
|
|
934
934
|
break;
|
|
935
935
|
case ('A'):
|
|
936
936
|
case ('a'):
|
|
937
|
-
newPathData += p.type + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + p.values[2] + " " + p.values[3] + " " + p.values[4] + " " + (p.values[5] - xFactor) + " " + (p.values[6] - yFactor);
|
|
937
|
+
newPathData += p.type + " " + (p.values[0] - xFactor) + " " + (p.values[1] - yFactor) + " " + p.values[2] + " " + p.values[3] + " " + p.values[4] + " " + (p.values[5] - xFactor) + " " + (p.values[6] - yFactor) + " ";
|
|
938
938
|
break;
|
|
939
939
|
}
|
|
940
940
|
}
|
|
@@ -41,6 +41,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
41
41
|
set content(value: string);
|
|
42
42
|
get innerHTML(): string;
|
|
43
43
|
set innerHTML(value: string);
|
|
44
|
+
get isEmptyTextNode(): boolean;
|
|
44
45
|
private _hideAtDesignTime;
|
|
45
46
|
get hideAtDesignTime(): boolean;
|
|
46
47
|
set hideAtDesignTime(value: boolean);
|
|
@@ -85,7 +85,7 @@ export class DesignItem {
|
|
|
85
85
|
action = new InsertChildAction(designItem, this.parent, this.parent.indexOf(this));
|
|
86
86
|
}
|
|
87
87
|
else if (where == 'afterend') {
|
|
88
|
-
action = new InsertChildAction(designItem, this.parent, this.parent.indexOf(this));
|
|
88
|
+
action = new InsertChildAction(designItem, this.parent, this.parent.indexOf(this) + 1);
|
|
89
89
|
}
|
|
90
90
|
this.instanceServiceContainer.undoService.execute(action);
|
|
91
91
|
}
|
|
@@ -124,6 +124,9 @@ export class DesignItem {
|
|
|
124
124
|
this.element.innerHTML = value;
|
|
125
125
|
this.updateChildrenFromNodesChildren();
|
|
126
126
|
}
|
|
127
|
+
get isEmptyTextNode() {
|
|
128
|
+
return this.nodeType === NodeType.TextNode && this.content?.trim() == '';
|
|
129
|
+
}
|
|
127
130
|
_hideAtDesignTime;
|
|
128
131
|
get hideAtDesignTime() {
|
|
129
132
|
return this._hideAtDesignTime;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer";
|
|
2
|
+
import { ServiceContainer } from "../ServiceContainer";
|
|
3
|
+
import { IHtmlParserService } from "./IHtmlParserService";
|
|
4
|
+
import { IDesignItem } from '../../item/IDesignItem';
|
|
5
|
+
export declare class LitElementParserService implements IHtmlParserService {
|
|
6
|
+
private _parserUrl;
|
|
7
|
+
private _esprimaUrl;
|
|
8
|
+
constructor(parserUrl?: string, esprimaUrl?: string);
|
|
9
|
+
parse(module: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): Promise<IDesignItem[]>;
|
|
10
|
+
private _parseDiv;
|
|
11
|
+
_createDesignItemsRecursive(item: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, namespace: string): IDesignItem;
|
|
12
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { DesignItem } from '../../item/DesignItem';
|
|
2
|
+
import { CssAttributeParser } from "../../helper/CssAttributeParser";
|
|
3
|
+
import { newElementFromString } from "../../helper/ElementHelper";
|
|
4
|
+
// Alternative Parser, cause when you use the Browser, it instanciates the CusomElements, and some Elemnts remove
|
|
5
|
+
// attributes from their DOM, so you loose Data
|
|
6
|
+
export class LitElementParserService {
|
|
7
|
+
_parserUrl;
|
|
8
|
+
_esprimaUrl;
|
|
9
|
+
constructor(parserUrl = '../../../../../node-html-parser-esm/dist/index.js', esprimaUrl = '../../../../../esprima-next/dist/esm/esprima.js') {
|
|
10
|
+
this._parserUrl = parserUrl;
|
|
11
|
+
this._esprimaUrl = esprimaUrl;
|
|
12
|
+
}
|
|
13
|
+
async parse(module, serviceContainer, instanceServiceContainer) {
|
|
14
|
+
let esprima = await import(this._esprimaUrl);
|
|
15
|
+
const parsedModule = esprima.parseModule(module);
|
|
16
|
+
const classDecl = parsedModule.body.find(x => x.type == esprima.Syntax.ClassDeclaration);
|
|
17
|
+
const renderMethod = classDecl.body.body.find(x => x.type == esprima.Syntax.MethodDefinition && x.key.name == 'render');
|
|
18
|
+
const renderMethodStatement = renderMethod.value.body.body[0];
|
|
19
|
+
const taggedTemplate = renderMethodStatement.argument;
|
|
20
|
+
const templateLiteral = taggedTemplate.quasi;
|
|
21
|
+
const html = templateLiteral.quasis.map(x => x.value.raw).join();
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
let parser = await import(this._parserUrl);
|
|
24
|
+
const parsed = parser.parse(html, { comment: true });
|
|
25
|
+
let designItems = [];
|
|
26
|
+
for (let p of parsed.childNodes) {
|
|
27
|
+
let di = this._createDesignItemsRecursive(p, serviceContainer, instanceServiceContainer, null);
|
|
28
|
+
if (di != null)
|
|
29
|
+
designItems.push(di);
|
|
30
|
+
else
|
|
31
|
+
console.warn("NodeHtmlParserService - could not parse element", p);
|
|
32
|
+
}
|
|
33
|
+
return designItems;
|
|
34
|
+
}
|
|
35
|
+
_parseDiv = document.createElement("div");
|
|
36
|
+
_createDesignItemsRecursive(item, serviceContainer, instanceServiceContainer, namespace) {
|
|
37
|
+
let designItem = null;
|
|
38
|
+
if (item.nodeType == 1) {
|
|
39
|
+
let element;
|
|
40
|
+
let manualCreatedElement = false;
|
|
41
|
+
if (!namespace)
|
|
42
|
+
element = newElementFromString('<' + item.rawTagName + ' ' + item.rawAttrs + '></' + item.rawTagName + '>'); // some custom elements only parse attributes during constructor call
|
|
43
|
+
if (!element) {
|
|
44
|
+
if (namespace)
|
|
45
|
+
element = document.createElementNS(namespace, item.rawTagName);
|
|
46
|
+
else
|
|
47
|
+
element = document.createElement(item.rawTagName);
|
|
48
|
+
manualCreatedElement = true;
|
|
49
|
+
}
|
|
50
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
51
|
+
let hideAtDesignTime = false;
|
|
52
|
+
let hideAtRunTime = false;
|
|
53
|
+
let lockAtDesignTime = false;
|
|
54
|
+
let style = '';
|
|
55
|
+
let attr = item.attributes;
|
|
56
|
+
for (let a in attr) {
|
|
57
|
+
if (a !== 'style') {
|
|
58
|
+
designItem.attributes.set(a, attr[a]);
|
|
59
|
+
if (manualCreatedElement) {
|
|
60
|
+
element.setAttribute(a, attr[a]);
|
|
61
|
+
}
|
|
62
|
+
if (a === 'node-projects-hide-at-design-time')
|
|
63
|
+
hideAtDesignTime = true;
|
|
64
|
+
else if (a === 'node-projects-hide-at-run-time')
|
|
65
|
+
hideAtRunTime = true;
|
|
66
|
+
else if (a === 'node-projects-lock-at-design-time')
|
|
67
|
+
lockAtDesignTime = true;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
style = attr[a];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if ((element instanceof HTMLElement || element instanceof SVGElement) && style) {
|
|
74
|
+
let styleParser = new CssAttributeParser();
|
|
75
|
+
styleParser.parse(style);
|
|
76
|
+
for (let s of styleParser.entries) {
|
|
77
|
+
designItem.styles.set(s.name, s.value);
|
|
78
|
+
if (manualCreatedElement) {
|
|
79
|
+
element.style[s.name] = s.value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!lockAtDesignTime && (element instanceof HTMLElement || element instanceof SVGElement)) {
|
|
84
|
+
requestAnimationFrame(() => element.style.pointerEvents = 'auto');
|
|
85
|
+
}
|
|
86
|
+
designItem.hideAtDesignTime = hideAtDesignTime;
|
|
87
|
+
designItem.hideAtRunTime = hideAtRunTime;
|
|
88
|
+
designItem.lockAtDesignTime = lockAtDesignTime;
|
|
89
|
+
element.draggable = false; //even if it should be true, for better designer exp.
|
|
90
|
+
for (let c of item.childNodes) {
|
|
91
|
+
let di = this._createDesignItemsRecursive(c, serviceContainer, instanceServiceContainer, element instanceof SVGElement ? 'http://www.w3.org/2000/svg' : null);
|
|
92
|
+
designItem._insertChildInternal(di);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (item.nodeType == 3) {
|
|
96
|
+
this._parseDiv.innerHTML = item.rawText;
|
|
97
|
+
let element = this._parseDiv.childNodes[0];
|
|
98
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
99
|
+
}
|
|
100
|
+
else if (item.nodeType == 8) {
|
|
101
|
+
let element = document.createComment(item.rawText);
|
|
102
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
103
|
+
}
|
|
104
|
+
return designItem;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstanceServiceContainer } from "../InstanceServiceContainer";
|
|
2
|
+
import { ServiceContainer } from "../ServiceContainer";
|
|
3
|
+
import { IHtmlParserService } from "./IHtmlParserService";
|
|
4
|
+
import { IDesignItem } from '../../item/IDesignItem';
|
|
5
|
+
export declare class NodeHtmlParserService implements IHtmlParserService {
|
|
6
|
+
private _parserUrl;
|
|
7
|
+
constructor(parserUrl?: string);
|
|
8
|
+
parse(html: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): Promise<IDesignItem[]>;
|
|
9
|
+
private _parseDiv;
|
|
10
|
+
_createDesignItemsRecursive(item: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, namespace: string): IDesignItem;
|
|
11
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { DesignItem } from '../../item/DesignItem';
|
|
2
|
+
import { CssAttributeParser } from "../../helper/CssAttributeParser";
|
|
3
|
+
import { newElementFromString } from "../../helper/ElementHelper";
|
|
4
|
+
// Alternative Parser, cause when you use the Browser, it instanciates the CusomElements, and some Elemnts remove
|
|
5
|
+
// attributes from their DOM, so you loose Data
|
|
6
|
+
export class NodeHtmlParserService {
|
|
7
|
+
_parserUrl;
|
|
8
|
+
constructor(parserUrl = '../../../../../node-html-parser-esm/dist/index.js') {
|
|
9
|
+
this._parserUrl = parserUrl;
|
|
10
|
+
}
|
|
11
|
+
async parse(html, serviceContainer, instanceServiceContainer) {
|
|
12
|
+
//@ts-ignore
|
|
13
|
+
let parser = await import(this._parserUrl);
|
|
14
|
+
const parsed = parser.parse(html, { comment: true });
|
|
15
|
+
let designItems = [];
|
|
16
|
+
for (let p of parsed.childNodes) {
|
|
17
|
+
let di = this._createDesignItemsRecursive(p, serviceContainer, instanceServiceContainer, null);
|
|
18
|
+
if (di != null)
|
|
19
|
+
designItems.push(di);
|
|
20
|
+
else
|
|
21
|
+
console.warn("NodeHtmlParserService - could not parse element", p);
|
|
22
|
+
}
|
|
23
|
+
return designItems;
|
|
24
|
+
}
|
|
25
|
+
_parseDiv = document.createElement("div");
|
|
26
|
+
_createDesignItemsRecursive(item, serviceContainer, instanceServiceContainer, namespace) {
|
|
27
|
+
let designItem = null;
|
|
28
|
+
if (item.nodeType == 1) {
|
|
29
|
+
let element;
|
|
30
|
+
let manualCreatedElement = false;
|
|
31
|
+
if (!namespace)
|
|
32
|
+
element = newElementFromString('<' + item.rawTagName + ' ' + item.rawAttrs + '></' + item.rawTagName + '>'); // some custom elements only parse attributes during constructor call
|
|
33
|
+
if (!element) {
|
|
34
|
+
if (namespace)
|
|
35
|
+
element = document.createElementNS(namespace, item.rawTagName);
|
|
36
|
+
else
|
|
37
|
+
element = document.createElement(item.rawTagName);
|
|
38
|
+
manualCreatedElement = true;
|
|
39
|
+
}
|
|
40
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
41
|
+
let hideAtDesignTime = false;
|
|
42
|
+
let hideAtRunTime = false;
|
|
43
|
+
let lockAtDesignTime = false;
|
|
44
|
+
let style = '';
|
|
45
|
+
let attr = item.attributes;
|
|
46
|
+
for (let a in attr) {
|
|
47
|
+
if (a !== 'style') {
|
|
48
|
+
designItem.attributes.set(a, attr[a]);
|
|
49
|
+
if (manualCreatedElement) {
|
|
50
|
+
element.setAttribute(a, attr[a]);
|
|
51
|
+
}
|
|
52
|
+
if (a === 'node-projects-hide-at-design-time')
|
|
53
|
+
hideAtDesignTime = true;
|
|
54
|
+
else if (a === 'node-projects-hide-at-run-time')
|
|
55
|
+
hideAtRunTime = true;
|
|
56
|
+
else if (a === 'node-projects-lock-at-design-time')
|
|
57
|
+
lockAtDesignTime = true;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
style = attr[a];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if ((element instanceof HTMLElement || element instanceof SVGElement) && style) {
|
|
64
|
+
let styleParser = new CssAttributeParser();
|
|
65
|
+
styleParser.parse(style);
|
|
66
|
+
for (let s of styleParser.entries) {
|
|
67
|
+
designItem.styles.set(s.name, s.value);
|
|
68
|
+
if (manualCreatedElement) {
|
|
69
|
+
element.style[s.name] = s.value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!lockAtDesignTime && (element instanceof HTMLElement || element instanceof SVGElement)) {
|
|
74
|
+
requestAnimationFrame(() => element.style.pointerEvents = 'auto');
|
|
75
|
+
}
|
|
76
|
+
designItem.hideAtDesignTime = hideAtDesignTime;
|
|
77
|
+
designItem.hideAtRunTime = hideAtRunTime;
|
|
78
|
+
designItem.lockAtDesignTime = lockAtDesignTime;
|
|
79
|
+
element.draggable = false; //even if it should be true, for better designer exp.
|
|
80
|
+
for (let c of item.childNodes) {
|
|
81
|
+
let di = this._createDesignItemsRecursive(c, serviceContainer, instanceServiceContainer, element instanceof SVGElement ? 'http://www.w3.org/2000/svg' : null);
|
|
82
|
+
designItem._insertChildInternal(di);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (item.nodeType == 3) {
|
|
86
|
+
this._parseDiv.innerHTML = item.rawText;
|
|
87
|
+
let element = this._parseDiv.childNodes[0];
|
|
88
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
89
|
+
}
|
|
90
|
+
else if (item.nodeType == 8) {
|
|
91
|
+
let element = document.createComment(item.rawText);
|
|
92
|
+
designItem = new DesignItem(element, serviceContainer, instanceServiceContainer);
|
|
93
|
+
}
|
|
94
|
+
return designItem;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DefaultPlacementService } from './DefaultPlacementService.js';
|
|
1
2
|
export class FlexBoxPlacementService {
|
|
2
3
|
enterContainer(container, items) {
|
|
3
4
|
for (let i of items) {
|
|
@@ -9,6 +10,12 @@ export class FlexBoxPlacementService {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
leaveContainer(container, items) {
|
|
13
|
+
for (let i of items) {
|
|
14
|
+
if (!i.lastContainerSize) {
|
|
15
|
+
const rect = i.element.getBoundingClientRect();
|
|
16
|
+
i.lastContainerSize = { width: rect.width, height: rect.height };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
serviceForContainer(container, containerStyle) {
|
|
14
21
|
if (containerStyle.display == 'flex' || containerStyle.display == 'inline-flex')
|
|
@@ -28,17 +35,68 @@ export class FlexBoxPlacementService {
|
|
|
28
35
|
return container.element.getBoundingClientRect();
|
|
29
36
|
}
|
|
30
37
|
placePoint(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
|
|
31
|
-
|
|
38
|
+
const defaultPlacementService = container.serviceContainer.getLastServiceWhere('containerService', x => x instanceof DefaultPlacementService);
|
|
39
|
+
return defaultPlacementService.placePoint(event, placementView, container, startPoint, offsetInControl, newPoint, items);
|
|
32
40
|
}
|
|
33
41
|
place(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const pos = placementView.getNormalizedEventCoordinates(event);
|
|
43
|
+
const style = getComputedStyle(container.element);
|
|
44
|
+
const childrenWithPos = Array.from(container.children()).filter(x => !x.isEmptyTextNode).map(x => [x, placementView.getNormalizedElementCoordinates(x.element)]);
|
|
45
|
+
if (style.flexDirection == 'row') {
|
|
46
|
+
childrenWithPos.sort(x => x[1].x);
|
|
47
|
+
let elBefore = null;
|
|
48
|
+
for (let c of childrenWithPos) {
|
|
49
|
+
if (c[1].x + c[1].width / 2 < pos.x) {
|
|
50
|
+
elBefore = c;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let posBefore = childrenWithPos.indexOf(elBefore);
|
|
54
|
+
let posDrag = childrenWithPos.indexOf(childrenWithPos.find(x => x[0] == items[0]));
|
|
55
|
+
if (elBefore && elBefore[0] != items[0]) {
|
|
56
|
+
if (posBefore + 1 === posDrag)
|
|
57
|
+
return;
|
|
58
|
+
let cg = items[0].openGroup('move in flexbox');
|
|
59
|
+
items[0].remove();
|
|
60
|
+
elBefore[0].insertAdjacentElement(items[0], 'afterend');
|
|
61
|
+
cg.commit();
|
|
62
|
+
}
|
|
63
|
+
else if (elBefore == null) {
|
|
64
|
+
if (posDrag == 0)
|
|
65
|
+
return;
|
|
66
|
+
let cg = items[0].openGroup('move in flexbox');
|
|
67
|
+
items[0].remove();
|
|
68
|
+
container.insertChild(items[0], 0);
|
|
69
|
+
cg.commit();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (style.flexDirection == 'column') {
|
|
73
|
+
childrenWithPos.sort(x => x[1].y);
|
|
74
|
+
let elBefore = null;
|
|
75
|
+
for (let c of childrenWithPos) {
|
|
76
|
+
if (c[1].y + c[1].height / 2 < pos.y) {
|
|
77
|
+
elBefore = c;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let posBefore = childrenWithPos.indexOf(elBefore);
|
|
81
|
+
let posDrag = childrenWithPos.indexOf(childrenWithPos.find(x => x[0] == items[0]));
|
|
82
|
+
if (elBefore && elBefore[0] != items[0]) {
|
|
83
|
+
if (posBefore + 1 === posDrag)
|
|
84
|
+
return;
|
|
85
|
+
let cg = items[0].openGroup('move in flexbox');
|
|
86
|
+
items[0].remove();
|
|
87
|
+
elBefore[0].insertAdjacentElement(items[0], 'afterend');
|
|
88
|
+
cg.commit();
|
|
89
|
+
}
|
|
90
|
+
else if (elBefore == null) {
|
|
91
|
+
if (posDrag == 0)
|
|
92
|
+
return;
|
|
93
|
+
let cg = items[0].openGroup('move in flexbox');
|
|
94
|
+
items[0].remove();
|
|
95
|
+
container.insertChild(items[0], 0);
|
|
96
|
+
cg.commit();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
placementView.extensionManager.refreshAllExtensions([container]);
|
|
42
100
|
}
|
|
43
101
|
finishPlace(event, placementView, container, startPoint, offsetInControl, newPoint, items) {
|
|
44
102
|
}
|
|
@@ -66,6 +66,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
66
66
|
get designerOffsetHeight(): number;
|
|
67
67
|
set additionalStyles(value: CSSStyleSheet[]);
|
|
68
68
|
executeCommand(command: IUiCommand): Promise<void>;
|
|
69
|
+
zoomToFit(): void;
|
|
69
70
|
canExecuteCommand(command: IUiCommand): boolean;
|
|
70
71
|
handleSelectAll(): void;
|
|
71
72
|
handleCopyCommand(): Promise<void>;
|
|
@@ -16,7 +16,7 @@ import { ExtensionType } from "./extensions/ExtensionType";
|
|
|
16
16
|
import { ExtensionManager } from "./extensions/ExtensionManager";
|
|
17
17
|
import { NamedTools } from "./tools/NamedTools";
|
|
18
18
|
import { Screenshot } from '../../helper/Screenshot';
|
|
19
|
-
import { dataURItoBlob, exportData } from "../../helper/Helper";
|
|
19
|
+
import { dataURItoBlob, exportData, sleep } from "../../helper/Helper";
|
|
20
20
|
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
21
21
|
import { OverlayLayer } from "./extensions/OverlayLayer";
|
|
22
22
|
import { OverlayLayerView } from './overlayLayerView';
|
|
@@ -232,8 +232,19 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
232
232
|
switch (command.type) {
|
|
233
233
|
case CommandType.screenshot:
|
|
234
234
|
{
|
|
235
|
-
if (!this.instanceServiceContainer.selectionService.primarySelection)
|
|
236
|
-
|
|
235
|
+
if (!this.instanceServiceContainer.selectionService.primarySelection) {
|
|
236
|
+
this.zoomToFit();
|
|
237
|
+
const backgroundImage = this._canvas.style.backgroundImage;
|
|
238
|
+
this._canvas.style.backgroundImage = 'none';
|
|
239
|
+
await sleep(100);
|
|
240
|
+
const el = this.rootDesignItem.element;
|
|
241
|
+
const sel = this.instanceServiceContainer.selectionService.selectedElements;
|
|
242
|
+
this.instanceServiceContainer.selectionService.setSelectedElements(null);
|
|
243
|
+
const screenshot = await Screenshot.takeScreenshot(el, el.clientWidth, el.clientHeight);
|
|
244
|
+
await exportData(dataURItoBlob(screenshot), "screenshot.png");
|
|
245
|
+
this.instanceServiceContainer.selectionService.setSelectedElements(sel);
|
|
246
|
+
this._canvas.style.backgroundImage = backgroundImage;
|
|
247
|
+
}
|
|
237
248
|
else {
|
|
238
249
|
if (!Screenshot.screenshotsEnabled) {
|
|
239
250
|
alert("you need to select current tab in next browser dialog, or screenshots will not work correctly");
|
|
@@ -291,6 +302,35 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
291
302
|
break;
|
|
292
303
|
}
|
|
293
304
|
}
|
|
305
|
+
zoomToFit() {
|
|
306
|
+
const autoZomOffset = 10;
|
|
307
|
+
let maxX = 0, maxY = 0, minX = 0, minY = 0;
|
|
308
|
+
this.canvasOffset = { x: 0, y: 0 };
|
|
309
|
+
this.zoomFactor = 1;
|
|
310
|
+
for (let n of DomHelper.getAllChildNodes(this.rootDesignItem.element)) {
|
|
311
|
+
if (n instanceof Element) {
|
|
312
|
+
const rect = n.getBoundingClientRect();
|
|
313
|
+
minX = minX < rect.x ? minX : rect.x;
|
|
314
|
+
minY = minY < rect.y ? minY : rect.y;
|
|
315
|
+
maxX = maxX > rect.x + rect.width + autoZomOffset ? maxX : rect.x + rect.width + autoZomOffset;
|
|
316
|
+
maxY = maxY > rect.y + rect.height + autoZomOffset ? maxY : rect.y + rect.height + autoZomOffset;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const cvRect = this.getBoundingClientRect();
|
|
320
|
+
maxX -= cvRect.x;
|
|
321
|
+
maxY -= cvRect.y;
|
|
322
|
+
let scaleX = cvRect.width / (maxX / this.zoomFactor);
|
|
323
|
+
let scaleY = cvRect.height / (maxY / this.zoomFactor);
|
|
324
|
+
const dimensions = this.getDesignSurfaceDimensions();
|
|
325
|
+
if (dimensions.width)
|
|
326
|
+
scaleX = cvRect.width / dimensions.width;
|
|
327
|
+
if (dimensions.height)
|
|
328
|
+
scaleY = cvRect.height / dimensions.height;
|
|
329
|
+
let fak = scaleX < scaleY ? scaleX : scaleY;
|
|
330
|
+
if (!isNaN(fak))
|
|
331
|
+
this.zoomFactor = fak;
|
|
332
|
+
//this._zoomInput.value = Math.round(this.zoomFactor * 100) + '%';
|
|
333
|
+
}
|
|
294
334
|
canExecuteCommand(command) {
|
|
295
335
|
const modelCommandService = this.serviceContainer.modelCommandService;
|
|
296
336
|
if (modelCommandService) {
|
|
@@ -4,7 +4,6 @@ import { DomConverter } from './DomConverter.js';
|
|
|
4
4
|
import { DefaultHtmlParserService } from '../../services/htmlParserService/DefaultHtmlParserService.js';
|
|
5
5
|
import { EventNames } from '../../../enums/EventNames.js';
|
|
6
6
|
import { DesignerToolbar } from './tools/toolBar/DesignerToolbar.js';
|
|
7
|
-
const autoZomOffset = 10;
|
|
8
7
|
export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
9
8
|
_sVert;
|
|
10
9
|
_sHor;
|
|
@@ -221,32 +220,7 @@ export class DesignerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
221
220
|
this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
|
|
222
221
|
}
|
|
223
222
|
zoomToFit() {
|
|
224
|
-
|
|
225
|
-
this._designerCanvas.canvasOffset = { x: 0, y: 0 };
|
|
226
|
-
this._designerCanvas.zoomFactor = 1;
|
|
227
|
-
for (let n of DomHelper.getAllChildNodes(this.designerCanvas.rootDesignItem.element)) {
|
|
228
|
-
if (n instanceof Element) {
|
|
229
|
-
const rect = n.getBoundingClientRect();
|
|
230
|
-
minX = minX < rect.x ? minX : rect.x;
|
|
231
|
-
minY = minY < rect.y ? minY : rect.y;
|
|
232
|
-
maxX = maxX > rect.x + rect.width + autoZomOffset ? maxX : rect.x + rect.width + autoZomOffset;
|
|
233
|
-
maxY = maxY > rect.y + rect.height + autoZomOffset ? maxY : rect.y + rect.height + autoZomOffset;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const cvRect = this.designerCanvas.getBoundingClientRect();
|
|
237
|
-
maxX -= cvRect.x;
|
|
238
|
-
maxY -= cvRect.y;
|
|
239
|
-
let scaleX = cvRect.width / (maxX / this._designerCanvas.zoomFactor);
|
|
240
|
-
let scaleY = cvRect.height / (maxY / this._designerCanvas.zoomFactor);
|
|
241
|
-
const dimensions = this.designerCanvas.getDesignSurfaceDimensions();
|
|
242
|
-
if (dimensions.width)
|
|
243
|
-
scaleX = cvRect.width / dimensions.width;
|
|
244
|
-
if (dimensions.height)
|
|
245
|
-
scaleY = cvRect.height / dimensions.height;
|
|
246
|
-
let fak = scaleX < scaleY ? scaleX : scaleY;
|
|
247
|
-
if (!isNaN(fak))
|
|
248
|
-
this._designerCanvas.zoomFactor = fak;
|
|
249
|
-
this._zoomInput.value = Math.round(this._designerCanvas.zoomFactor * 100) + '%';
|
|
223
|
+
this._designerCanvas.zoomToFit();
|
|
250
224
|
}
|
|
251
225
|
_onScrollbar(e) {
|
|
252
226
|
if (e?.detail == 'incrementLarge')
|
|
@@ -3,7 +3,7 @@ import { IExtensionManager } from "./IExtensionManger";
|
|
|
3
3
|
import { OverlayLayerView } from '../overlayLayerView';
|
|
4
4
|
import { OverlayLayer } from './OverlayLayer';
|
|
5
5
|
export declare abstract class AbstractExtensionBase {
|
|
6
|
-
protected overlays:
|
|
6
|
+
protected overlays: SVGElement[];
|
|
7
7
|
protected overlayLayerView: OverlayLayerView;
|
|
8
8
|
protected extensionManager: IExtensionManager;
|
|
9
9
|
protected designerCanvas: IDesignerCanvas;
|
|
@@ -13,4 +13,5 @@ export declare abstract class AbstractExtensionBase {
|
|
|
13
13
|
protected _drawCircle(x: number, y: number, radius: number, className?: string, circle?: SVGCircleElement, overlayLayer?: OverlayLayer): SVGCircleElement;
|
|
14
14
|
protected _drawRect(x: number, y: number, w: number, h: number, className?: string, rect?: SVGRectElement, overlayLayer?: OverlayLayer): SVGRectElement;
|
|
15
15
|
protected _drawText(text: string, x: number, y: number, className?: string, textEl?: SVGTextElement, overlayLayer?: OverlayLayer): SVGTextElement;
|
|
16
|
+
protected _drawTextWithBackground(text: string, x: number, y: number, backgroundColor: string, className?: string, existingEls?: [SVGFilterElement, SVGFEFloodElement, SVGTextElement, SVGTextElement], overlayLayer?: OverlayLayer): [SVGFilterElement, SVGFEFloodElement, SVGTextElement, SVGTextElement];
|
|
16
17
|
}
|
|
@@ -47,4 +47,11 @@ export class AbstractExtensionBase {
|
|
|
47
47
|
}
|
|
48
48
|
return newText;
|
|
49
49
|
}
|
|
50
|
+
_drawTextWithBackground(text, x, y, backgroundColor, className, existingEls, overlayLayer) {
|
|
51
|
+
const newEls = this.overlayLayerView.drawTextWithBackground(text, x, y, backgroundColor, className, existingEls, overlayLayer);
|
|
52
|
+
if (!existingEls) {
|
|
53
|
+
this.overlays.push(...newEls);
|
|
54
|
+
}
|
|
55
|
+
return newEls;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
@@ -13,7 +13,7 @@ export declare class ExtensionManager implements IExtensionManager {
|
|
|
13
13
|
removeExtension(designItem: IDesignItem, extensionType?: ExtensionType): void;
|
|
14
14
|
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): void;
|
|
15
15
|
refreshExtension(designItem: IDesignItem, extensionType?: ExtensionType): void;
|
|
16
|
-
refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): void;
|
|
17
|
-
refreshAllExtensions(designItems: IDesignItem[]): void;
|
|
16
|
+
refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType, ignoredExtension?: any): void;
|
|
17
|
+
refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: any): void;
|
|
18
18
|
refreshAllAppliedExtentions(): void;
|
|
19
19
|
}
|
|
@@ -204,7 +204,7 @@ export class ExtensionManager {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
refreshExtensions(designItems, extensionType) {
|
|
207
|
+
refreshExtensions(designItems, extensionType, ignoredExtension) {
|
|
208
208
|
if (designItems) {
|
|
209
209
|
if (extensionType) {
|
|
210
210
|
for (let i of designItems) {
|
|
@@ -212,7 +212,8 @@ export class ExtensionManager {
|
|
|
212
212
|
if (exts) {
|
|
213
213
|
for (let e of exts) {
|
|
214
214
|
try {
|
|
215
|
-
e
|
|
215
|
+
if (e != ignoredExtension)
|
|
216
|
+
e.refresh();
|
|
216
217
|
}
|
|
217
218
|
catch (err) {
|
|
218
219
|
console.error(err);
|
|
@@ -226,7 +227,8 @@ export class ExtensionManager {
|
|
|
226
227
|
for (let appE of i.appliedDesignerExtensions) {
|
|
227
228
|
for (let e of appE[1]) {
|
|
228
229
|
try {
|
|
229
|
-
e
|
|
230
|
+
if (e != ignoredExtension)
|
|
231
|
+
e.refresh();
|
|
230
232
|
}
|
|
231
233
|
catch (err) {
|
|
232
234
|
console.error(err);
|
|
@@ -237,18 +239,18 @@ export class ExtensionManager {
|
|
|
237
239
|
}
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
|
-
refreshAllExtensions(designItems) {
|
|
242
|
+
refreshAllExtensions(designItems, ignoredExtension) {
|
|
241
243
|
if (designItems) {
|
|
242
|
-
this.refreshExtensions(designItems, ExtensionType.Permanent);
|
|
243
|
-
this.refreshExtensions(designItems, ExtensionType.Selection);
|
|
244
|
-
this.refreshExtensions(designItems, ExtensionType.PrimarySelection);
|
|
245
|
-
this.refreshExtensions(designItems, ExtensionType.PrimarySelectionContainer);
|
|
246
|
-
this.refreshExtensions(designItems, ExtensionType.MouseOver);
|
|
247
|
-
this.refreshExtensions(designItems, ExtensionType.OnlyOneItemSelected);
|
|
248
|
-
this.refreshExtensions(designItems, ExtensionType.MultipleItemsSelected);
|
|
249
|
-
this.refreshExtensions(designItems, ExtensionType.ContainerDragOver);
|
|
250
|
-
this.refreshExtensions(designItems, ExtensionType.ContainerDrag);
|
|
251
|
-
this.refreshExtensions(designItems, ExtensionType.Doubleclick);
|
|
244
|
+
this.refreshExtensions(designItems, ExtensionType.Permanent, ignoredExtension);
|
|
245
|
+
this.refreshExtensions(designItems, ExtensionType.Selection, ignoredExtension);
|
|
246
|
+
this.refreshExtensions(designItems, ExtensionType.PrimarySelection, ignoredExtension);
|
|
247
|
+
this.refreshExtensions(designItems, ExtensionType.PrimarySelectionContainer, ignoredExtension);
|
|
248
|
+
this.refreshExtensions(designItems, ExtensionType.MouseOver, ignoredExtension);
|
|
249
|
+
this.refreshExtensions(designItems, ExtensionType.OnlyOneItemSelected, ignoredExtension);
|
|
250
|
+
this.refreshExtensions(designItems, ExtensionType.MultipleItemsSelected, ignoredExtension);
|
|
251
|
+
this.refreshExtensions(designItems, ExtensionType.ContainerDragOver, ignoredExtension);
|
|
252
|
+
this.refreshExtensions(designItems, ExtensionType.ContainerDrag, ignoredExtension);
|
|
253
|
+
this.refreshExtensions(designItems, ExtensionType.Doubleclick, ignoredExtension);
|
|
252
254
|
}
|
|
253
255
|
}
|
|
254
256
|
refreshAllAppliedExtentions() {
|
|
@@ -7,6 +7,6 @@ export interface IExtensionManager {
|
|
|
7
7
|
removeExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): any;
|
|
8
8
|
refreshExtension(designItem: IDesignItem, extensionType?: ExtensionType): any;
|
|
9
9
|
refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType): any;
|
|
10
|
-
refreshAllExtensions(designItems: IDesignItem[]): any;
|
|
10
|
+
refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: any): any;
|
|
11
11
|
refreshAllAppliedExtentions(): any;
|
|
12
12
|
}
|
|
@@ -7,9 +7,7 @@ export declare class PositionExtension extends AbstractExtension {
|
|
|
7
7
|
private _line2;
|
|
8
8
|
private _line3;
|
|
9
9
|
private _line4;
|
|
10
|
-
private _rectX;
|
|
11
10
|
private _textX;
|
|
12
|
-
private _rectY;
|
|
13
11
|
private _textY;
|
|
14
12
|
constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
|
|
15
13
|
extend(): void;
|
|
@@ -4,9 +4,7 @@ export class PositionExtension extends AbstractExtension {
|
|
|
4
4
|
_line2;
|
|
5
5
|
_line3;
|
|
6
6
|
_line4;
|
|
7
|
-
_rectX;
|
|
8
7
|
_textX;
|
|
9
|
-
_rectY;
|
|
10
8
|
_textY;
|
|
11
9
|
constructor(extensionManager, designerView, extendedItem) {
|
|
12
10
|
super(extensionManager, designerView, extendedItem);
|
|
@@ -31,12 +29,12 @@ export class PositionExtension extends AbstractExtension {
|
|
|
31
29
|
this._line4.style.strokeDasharray = '' + (4 / this.designerCanvas.scaleFactor);
|
|
32
30
|
let x = Math.round(itemRect.x - itemParentRect.x);
|
|
33
31
|
let y = Math.round(itemRect.y - itemParentRect.y);
|
|
34
|
-
this.
|
|
35
|
-
this._textX =
|
|
36
|
-
this._textX.style.fontSize = '
|
|
37
|
-
this.
|
|
38
|
-
this._textY =
|
|
39
|
-
this._textY.style.fontSize = '
|
|
32
|
+
this._textX = this._drawTextWithBackground('' + x, itemParentRect.x + x / 2, itemRect.y + itemRect.height / 2, 'white', 'svg-position-text', this._textX);
|
|
33
|
+
this._textX[2].style.fontSize = (12 / this.designerCanvas.scaleFactor) + 'px';
|
|
34
|
+
this._textX[3].style.fontSize = (12 / this.designerCanvas.scaleFactor) + 'px';
|
|
35
|
+
this._textY = this._drawTextWithBackground('' + y, itemRect.x + itemRect.width / 2, itemParentRect.y + y / 2, 'white', 'svg-position-text', this._textY);
|
|
36
|
+
this._textY[2].style.fontSize = (12 / this.designerCanvas.scaleFactor) + 'px';
|
|
37
|
+
this._textY[3].style.fontSize = (12 / this.designerCanvas.scaleFactor) + 'px';
|
|
40
38
|
}
|
|
41
39
|
dispose() {
|
|
42
40
|
this._removeAllOverlays();
|
|
@@ -11,6 +11,6 @@ export class PositionExtensionProvider {
|
|
|
11
11
|
return new PositionExtension(extensionManager, designerView, designItem);
|
|
12
12
|
}
|
|
13
13
|
style = css `
|
|
14
|
-
.svg-position-text
|
|
14
|
+
.svg-position-text { text-anchor: middle; alignment-baseline: central; }
|
|
15
15
|
`;
|
|
16
16
|
}
|
|
@@ -73,6 +73,7 @@ export class EllipsisExtension extends AbstractExtension {
|
|
|
73
73
|
}
|
|
74
74
|
e.setAttribute("rx", this._newRx.toString());
|
|
75
75
|
e.setAttribute("ry", this._newRy.toString());
|
|
76
|
+
this.designerCanvas.extensionManager.refreshAllExtensions([this.extendedItem], this);
|
|
76
77
|
this._redrawPathCircle(this._cx, this._cy - this._newRy, this._circle1);
|
|
77
78
|
this._redrawPathCircle(this._cx + this._newRx, this._cy, this._circle2);
|
|
78
79
|
this._redrawPathCircle(this._cx, this._cy + this._newRy, this._circle3);
|
|
@@ -53,6 +53,7 @@ export class LineExtension extends AbstractExtension {
|
|
|
53
53
|
this._newCirclePoint = { x: this._circlePos.x + dx, y: this._circlePos.y + dy };
|
|
54
54
|
this._newLinePoint = { x: this._originalPoint.x + dx, y: this._originalPoint.y + dy };
|
|
55
55
|
}
|
|
56
|
+
this.designerCanvas.extensionManager.refreshAllExtensions([this.extendedItem], this);
|
|
56
57
|
circle.setAttribute("cx", this._newCirclePoint.x.toString());
|
|
57
58
|
circle.setAttribute("cy", this._newCirclePoint.y.toString());
|
|
58
59
|
l.setAttribute("x" + index, this._newLinePoint.x.toString());
|
|
@@ -148,6 +148,7 @@ export class PathExtension extends AbstractExtension {
|
|
|
148
148
|
circle.setAttribute("cy", (this._circlePos.y + dy).toString());
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
+
this.designerCanvas.extensionManager.refreshAllExtensions([this.extendedItem], this);
|
|
151
152
|
this.extendedItem.element.setAttribute("d", createPathD(this._pathdata));
|
|
152
153
|
}
|
|
153
154
|
break;
|
|
@@ -76,6 +76,7 @@ export class RectExtension extends AbstractExtension {
|
|
|
76
76
|
r.setAttribute("height", this._rect.h.toString());
|
|
77
77
|
circle.setAttribute("cx", (this._circlePos.x + dx).toString());
|
|
78
78
|
circle.setAttribute("cy", (this._circlePos.y + dy).toString());
|
|
79
|
+
this.designerCanvas.extensionManager.refreshAllExtensions([this.extendedItem], this);
|
|
79
80
|
this._redrawPathCircle(this._rect.x, this._rect.y, this._circle1);
|
|
80
81
|
this._redrawPathCircle(this._rect.x + this._rect.w, this._rect.y, this._circle2);
|
|
81
82
|
this._redrawPathCircle(this._rect.x + this._rect.w, this._rect.y + this._rect.h, this._circle3);
|
|
@@ -10,10 +10,12 @@ export declare class OverlayLayerView extends BaseCustomWebComponentConstructorA
|
|
|
10
10
|
private _gBackground;
|
|
11
11
|
private _gNormal;
|
|
12
12
|
private _gForeground;
|
|
13
|
+
private _defs;
|
|
14
|
+
private _id;
|
|
13
15
|
constructor(serviceContainer: ServiceContainer);
|
|
14
16
|
private _initialize;
|
|
15
17
|
addOverlay(element: SVGGraphicsElement, overlayLayer?: OverlayLayer): void;
|
|
16
|
-
removeOverlay(element:
|
|
18
|
+
removeOverlay(element: SVGElement): void;
|
|
17
19
|
removeAllNodesWithClass(className: string): void;
|
|
18
20
|
removeAllOverlays(): void;
|
|
19
21
|
createPoint(): DOMPointInit;
|
|
@@ -22,4 +24,5 @@ export declare class OverlayLayerView extends BaseCustomWebComponentConstructorA
|
|
|
22
24
|
drawCircle(x: number, y: number, radius: number, className?: string, circle?: SVGCircleElement, overlayLayer?: OverlayLayer): SVGCircleElement;
|
|
23
25
|
drawRect(x: number, y: number, w: number, h: number, className?: string, rect?: SVGRectElement, overlayLayer?: OverlayLayer): SVGRectElement;
|
|
24
26
|
drawText(text: string, x: number, y: number, className?: string, textEl?: SVGTextElement, overlayLayer?: OverlayLayer): SVGTextElement;
|
|
27
|
+
drawTextWithBackground(text: string, x: number, y: number, backgroundColor: string, className?: string, existingEls?: [SVGFilterElement, SVGFEFloodElement, SVGTextElement, SVGTextElement], overlayLayer?: OverlayLayer): [SVGFilterElement, SVGFEFloodElement, SVGTextElement, SVGTextElement];
|
|
25
28
|
}
|
|
@@ -3,6 +3,7 @@ import { OverlayLayer } from './extensions/OverlayLayer.js';
|
|
|
3
3
|
export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
4
4
|
static template = html `
|
|
5
5
|
<svg id="svg" style="pointer-events: none;">
|
|
6
|
+
<defs id="defs"></defs>
|
|
6
7
|
<g id="background"></g>
|
|
7
8
|
<g id="normal"></g>
|
|
8
9
|
<g id="foreground"></g>
|
|
@@ -27,6 +28,8 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
27
28
|
_gBackground;
|
|
28
29
|
_gNormal;
|
|
29
30
|
_gForeground;
|
|
31
|
+
_defs;
|
|
32
|
+
_id = 0;
|
|
30
33
|
constructor(serviceContainer) {
|
|
31
34
|
super();
|
|
32
35
|
this._serviceContainer = serviceContainer;
|
|
@@ -34,6 +37,7 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
34
37
|
this._gBackground = this._getDomElement('background');
|
|
35
38
|
this._gNormal = this._getDomElement('normal');
|
|
36
39
|
this._gForeground = this._getDomElement('foreground');
|
|
40
|
+
this._defs = this._getDomElement('defs');
|
|
37
41
|
this._initialize();
|
|
38
42
|
}
|
|
39
43
|
_initialize() {
|
|
@@ -143,5 +147,40 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
143
147
|
textEl.setAttribute('class', className);
|
|
144
148
|
return textEl;
|
|
145
149
|
}
|
|
150
|
+
drawTextWithBackground(text, x, y, backgroundColor, className, existingEls, overlayLayer) {
|
|
151
|
+
if (!existingEls) {
|
|
152
|
+
let filter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
|
|
153
|
+
filter.setAttribute("x", "0");
|
|
154
|
+
filter.setAttribute("y", "0");
|
|
155
|
+
filter.setAttribute("width", "1");
|
|
156
|
+
filter.setAttribute("height", "1");
|
|
157
|
+
filter.setAttribute("id", "solid_" + (++this._id));
|
|
158
|
+
let flood = document.createElementNS("http://www.w3.org/2000/svg", "feFlood");
|
|
159
|
+
flood.setAttribute("flood-color", backgroundColor);
|
|
160
|
+
filter.appendChild(flood);
|
|
161
|
+
let composite = document.createElementNS("http://www.w3.org/2000/svg", "feComposite");
|
|
162
|
+
composite.setAttribute("in", "SourceGraphic");
|
|
163
|
+
composite.setAttribute("operator", "xor");
|
|
164
|
+
filter.appendChild(composite);
|
|
165
|
+
this._defs.appendChild(filter);
|
|
166
|
+
let textEl1 = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
167
|
+
textEl1.setAttribute("filter", "url(#solid_" + this._id + ")");
|
|
168
|
+
let textEl2 = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
169
|
+
this.addOverlay(textEl1, overlayLayer);
|
|
170
|
+
this.addOverlay(textEl2, overlayLayer);
|
|
171
|
+
existingEls = [filter, flood, textEl1, textEl2];
|
|
172
|
+
}
|
|
173
|
+
existingEls[2].setAttribute('x', x);
|
|
174
|
+
existingEls[3].setAttribute('x', x);
|
|
175
|
+
existingEls[2].setAttribute('y', y);
|
|
176
|
+
existingEls[3].setAttribute('y', y);
|
|
177
|
+
existingEls[2].textContent = text;
|
|
178
|
+
existingEls[3].textContent = text;
|
|
179
|
+
if (className) {
|
|
180
|
+
existingEls[2].setAttribute('class', className);
|
|
181
|
+
existingEls[3].setAttribute('class', className);
|
|
182
|
+
}
|
|
183
|
+
return existingEls;
|
|
184
|
+
}
|
|
146
185
|
}
|
|
147
186
|
customElements.define(OverlayLayerView.is, OverlayLayerView);
|
|
@@ -18,7 +18,7 @@ export class DrawEllipsisTool {
|
|
|
18
18
|
}
|
|
19
19
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
20
20
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
21
|
-
const offset =
|
|
21
|
+
const offset = 10;
|
|
22
22
|
switch (event.type) {
|
|
23
23
|
case EventNames.PointerDown:
|
|
24
24
|
this._startPoint = currentPoint;
|
|
@@ -69,19 +69,19 @@ export class DrawEllipsisTool {
|
|
|
69
69
|
case EventNames.PointerUp:
|
|
70
70
|
event.target.releasePointerCapture(event.pointerId);
|
|
71
71
|
designerCanvas.releaseActiveTool();
|
|
72
|
-
|
|
72
|
+
let coords = designerCanvas.getNormalizedElementCoordinates(this._path);
|
|
73
73
|
designerCanvas.overlayLayer.removeOverlay(this._path);
|
|
74
74
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
75
|
-
const mvX =
|
|
76
|
-
const mvY =
|
|
75
|
+
const mvX = coords.x - offset;
|
|
76
|
+
const mvY = coords.y - offset;
|
|
77
77
|
svg.appendChild(this._path);
|
|
78
78
|
this._path.setAttribute("cx", (this._cx - mvX).toString());
|
|
79
79
|
this._path.setAttribute("cy", (this._cy - mvY).toString());
|
|
80
80
|
svg.style.left = (mvX) + 'px';
|
|
81
81
|
svg.style.top = (mvY) + 'px';
|
|
82
82
|
svg.style.position = 'absolute';
|
|
83
|
-
svg.style.width = (
|
|
84
|
-
svg.style.height = (
|
|
83
|
+
svg.style.width = (coords.width + 2 * offset) + 'px';
|
|
84
|
+
svg.style.height = (coords.height + 2 * offset) + 'px';
|
|
85
85
|
svg.style.overflow = 'visible';
|
|
86
86
|
this._path = null;
|
|
87
87
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
@@ -16,7 +16,7 @@ export class DrawLineTool {
|
|
|
16
16
|
}
|
|
17
17
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
18
18
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
19
|
-
const offset =
|
|
19
|
+
const offset = 10;
|
|
20
20
|
switch (event.type) {
|
|
21
21
|
case EventNames.PointerDown:
|
|
22
22
|
this._startPoint = currentPoint;
|
|
@@ -52,11 +52,11 @@ export class DrawLineTool {
|
|
|
52
52
|
case EventNames.PointerUp:
|
|
53
53
|
event.target.releasePointerCapture(event.pointerId);
|
|
54
54
|
designerCanvas.releaseActiveTool();
|
|
55
|
-
|
|
55
|
+
let coords = designerCanvas.getNormalizedElementCoordinates(this._path);
|
|
56
56
|
designerCanvas.overlayLayer.removeOverlay(this._path);
|
|
57
57
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
58
|
-
const mvX =
|
|
59
|
-
const mvY =
|
|
58
|
+
const mvX = coords.x - offset;
|
|
59
|
+
const mvY = coords.y - offset;
|
|
60
60
|
this._path.setAttribute("x1", (this._startPoint.x - mvX).toString());
|
|
61
61
|
this._path.setAttribute("y1", (this._startPoint.y - mvY).toString());
|
|
62
62
|
this._path.setAttribute("x2", (this._endPoint.x - mvX).toString());
|
|
@@ -65,8 +65,8 @@ export class DrawLineTool {
|
|
|
65
65
|
svg.style.left = (mvX) + 'px';
|
|
66
66
|
svg.style.top = (mvY) + 'px';
|
|
67
67
|
svg.style.position = 'absolute';
|
|
68
|
-
svg.style.width = (
|
|
69
|
-
svg.style.height = (
|
|
68
|
+
svg.style.width = (coords.width + 2 * offset) + 'px';
|
|
69
|
+
svg.style.height = (coords.height + 2 * offset) + 'px';
|
|
70
70
|
svg.style.overflow = 'visible';
|
|
71
71
|
this._path = null;
|
|
72
72
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
@@ -21,7 +21,7 @@ export class DrawRectTool {
|
|
|
21
21
|
}
|
|
22
22
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
23
23
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
24
|
-
const offset =
|
|
24
|
+
const offset = 10;
|
|
25
25
|
switch (event.type) {
|
|
26
26
|
case EventNames.PointerDown:
|
|
27
27
|
this._startPoint = currentPoint;
|
|
@@ -84,19 +84,19 @@ export class DrawRectTool {
|
|
|
84
84
|
case EventNames.PointerUp:
|
|
85
85
|
event.target.releasePointerCapture(event.pointerId);
|
|
86
86
|
designerCanvas.releaseActiveTool();
|
|
87
|
-
|
|
87
|
+
let coords = designerCanvas.getNormalizedElementCoordinates(this._path);
|
|
88
88
|
designerCanvas.overlayLayer.removeOverlay(this._path);
|
|
89
89
|
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
90
|
-
const mvX =
|
|
91
|
-
const mvY =
|
|
90
|
+
const mvX = coords.x - offset;
|
|
91
|
+
const mvY = coords.y - offset;
|
|
92
92
|
this._path.setAttribute("x", (this._px - mvX).toString());
|
|
93
93
|
this._path.setAttribute("y", (this._py - mvY).toString());
|
|
94
94
|
svg.appendChild(this._path);
|
|
95
95
|
svg.style.left = (mvX) + 'px';
|
|
96
96
|
svg.style.top = (mvY) + 'px';
|
|
97
97
|
svg.style.position = 'absolute';
|
|
98
|
-
svg.style.width = (
|
|
99
|
-
svg.style.height = (
|
|
98
|
+
svg.style.width = (coords.width + 2 * offset) + 'px';
|
|
99
|
+
svg.style.height = (coords.height + 2 * offset) + 'px';
|
|
100
100
|
svg.style.overflow = 'visible';
|
|
101
101
|
this._path = null;
|
|
102
102
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
@@ -171,6 +171,9 @@ export class PointerTool {
|
|
|
171
171
|
}
|
|
172
172
|
case EventNames.PointerMove:
|
|
173
173
|
{
|
|
174
|
+
if (event.buttons == 0) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
174
177
|
const elementMoved = currentPoint.x != this._initialPoint.x || currentPoint.y != this._initialPoint.y;
|
|
175
178
|
if (this._actionType != PointerActionType.Drag && elementMoved) {
|
|
176
179
|
this._actionType = PointerActionType.Drag;
|
|
@@ -377,7 +377,7 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
377
377
|
ref: item
|
|
378
378
|
});
|
|
379
379
|
for (let i of item.children()) {
|
|
380
|
-
if (i.
|
|
380
|
+
if (!i.isEmptyTextNode) {
|
|
381
381
|
this._getChildren(i, newNode);
|
|
382
382
|
}
|
|
383
383
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export * from "./elements/services/htmlWriterService/HtmlWriterService.js";
|
|
|
56
56
|
export * from "./elements/services/htmlWriterService/LitTsElementWriterService.js";
|
|
57
57
|
export * from "./elements/services/htmlParserService/DefaultHtmlParserService.js";
|
|
58
58
|
export * from "./elements/services/htmlParserService/NodeHtmlParserService.js";
|
|
59
|
+
export * from "./elements/services/htmlParserService/LitElementParserService.js";
|
|
59
60
|
export type { IHtmlParserService } from "./elements/services/htmlParserService/IHtmlParserService.js";
|
|
60
61
|
export type { IIntializationService } from "./elements/services/initializationService/IIntializationService.js";
|
|
61
62
|
export * from "./elements/services/instanceService/DefaultInstanceService.js";
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ export * from "./elements/services/htmlWriterService/HtmlWriterService.js";
|
|
|
35
35
|
export * from "./elements/services/htmlWriterService/LitTsElementWriterService.js";
|
|
36
36
|
export * from "./elements/services/htmlParserService/DefaultHtmlParserService.js";
|
|
37
37
|
export * from "./elements/services/htmlParserService/NodeHtmlParserService.js";
|
|
38
|
+
export * from "./elements/services/htmlParserService/LitElementParserService.js";
|
|
38
39
|
export * from "./elements/services/instanceService/DefaultInstanceService.js";
|
|
39
40
|
export * from "./elements/services/manifestParsers/WebcomponentManifestParserService.js";
|
|
40
41
|
export * from "./elements/services/modelCommandService/DefaultModelCommandService.js";
|