@node-projects/web-component-designer 0.0.77 → 0.0.81
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 +1 -0
- package/dist/elements/documentContainer.js +2 -2
- package/dist/elements/helper/ElementHelper.d.ts +6 -0
- package/dist/elements/helper/ElementHelper.js +10 -0
- package/dist/elements/helper/PathDataPolyfill.d.ts +11 -10
- package/dist/elements/helper/PathDataPolyfill.js +36 -1
- package/dist/elements/services/DefaultServiceBootstrap.js +6 -2
- package/dist/elements/services/ServiceContainer.d.ts +1 -1
- package/dist/elements/services/ServiceContainer.js +2 -2
- package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +1 -1
- package/dist/elements/services/demoProviderService/DemoProviderService.js +2 -1
- package/dist/elements/services/demoProviderService/IDemoProviderService.d.ts +1 -1
- package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.d.ts +10 -0
- package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.js +62 -0
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.d.ts +22 -0
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.js +133 -0
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.d.ts +2 -2
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.js +34 -19
- package/dist/elements/services/htmlWriterService/HtmlWriterService.d.ts +8 -8
- package/dist/elements/services/htmlWriterService/HtmlWriterService.js +13 -42
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.d.ts +2 -0
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.js +5 -3
- package/dist/elements/services/htmlWriterService/IHtmlWriterService.d.ts +5 -6
- package/dist/elements/services/htmlWriterService/LitTsElementWriterService.d.ts +9 -0
- package/dist/elements/services/htmlWriterService/LitTsElementWriterService.js +43 -0
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.d.ts +27 -0
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.js +93 -0
- package/dist/elements/services/initializationService/DefaultIntializationService.d.ts +6 -0
- package/dist/elements/services/initializationService/DefaultIntializationService.js +22 -0
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.d.ts +3 -1
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +42 -28
- package/dist/elements/widgets/codeView/code-view-ace.js +1 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +1 -1
- package/dist/elements/widgets/demoView/IDemoView.d.ts +1 -1
- package/dist/elements/widgets/demoView/demoView.d.ts +1 -1
- package/dist/elements/widgets/demoView/demoView.js +2 -2
- package/dist/elements/widgets/designerView/DomConverter.d.ts +3 -3
- package/dist/elements/widgets/designerView/DomConverter.js +8 -11
- package/dist/elements/widgets/designerView/extensions/PathExtension.d.ts +0 -1
- package/dist/elements/widgets/designerView/extensions/PathExtension.js +100 -12
- package/dist/elements/widgets/designerView/extensions/contextMenu/CopyPasteContextMenu.js +0 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.d.ts +8 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.js +31 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.d.ts +8 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.js +34 -0
- package/dist/elements/widgets/designerView/overlayLayerView.js +1 -2
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +0 -1
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +17 -9
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +1 -0
- package/dist/elements/widgets/treeView/treeViewExtended.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +7 -7
- package/dist/elements/services/htmlWriterService/LitElementWriterService.d.ts +0 -12
- package/dist/elements/services/htmlWriterService/LitElementWriterService.js +0 -107
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.d.ts +0 -26
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.js +0 -69
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.d.ts +0 -0
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.js +0 -1
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.d.ts +0 -26
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.js +0 -69
package/.github/FUNDING.yml
CHANGED
|
@@ -146,7 +146,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
146
146
|
else if (this._tabControl.selectedIndex === 2) {
|
|
147
147
|
}
|
|
148
148
|
else if (this._tabControl.selectedIndex === 3)
|
|
149
|
-
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content);
|
|
149
|
+
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content, this.additionalStyleString);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
get content() {
|
|
@@ -191,7 +191,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
191
191
|
this._splitDiv.appendChild(this.codeView);
|
|
192
192
|
}
|
|
193
193
|
if (i.newIndex === 3) {
|
|
194
|
-
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content);
|
|
194
|
+
this.demoView.display(this._serviceContainer, this.designerView.instanceServiceContainer, this._content, this.additionalStyleString);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
if (this._content)
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export declare function newElementFromString(text: any): Element;
|
|
2
|
+
export declare enum ElementDisplayType {
|
|
3
|
+
none = 0,
|
|
4
|
+
inline = 1,
|
|
5
|
+
block = 2
|
|
6
|
+
}
|
|
2
7
|
export declare function isInline(element: HTMLElement): boolean;
|
|
8
|
+
export declare function getElementDisplaytype(element: HTMLElement): ElementDisplayType;
|
|
3
9
|
export declare function isEmptyTextNode(node: Node): boolean;
|
|
@@ -4,9 +4,19 @@ export function newElementFromString(text) {
|
|
|
4
4
|
const fragment = range.createContextualFragment(text);
|
|
5
5
|
return fragment.firstChild;
|
|
6
6
|
}
|
|
7
|
+
export var ElementDisplayType;
|
|
8
|
+
(function (ElementDisplayType) {
|
|
9
|
+
ElementDisplayType[ElementDisplayType["none"] = 0] = "none";
|
|
10
|
+
ElementDisplayType[ElementDisplayType["inline"] = 1] = "inline";
|
|
11
|
+
ElementDisplayType[ElementDisplayType["block"] = 2] = "block";
|
|
12
|
+
})(ElementDisplayType || (ElementDisplayType = {}));
|
|
7
13
|
export function isInline(element) {
|
|
8
14
|
return element != null && window.getComputedStyle(element).display.startsWith('inline');
|
|
9
15
|
}
|
|
16
|
+
export function getElementDisplaytype(element) {
|
|
17
|
+
const display = window.getComputedStyle(element).display;
|
|
18
|
+
return display == 'none' ? ElementDisplayType.none : display.startsWith('inline') ? ElementDisplayType.inline : ElementDisplayType.block;
|
|
19
|
+
}
|
|
10
20
|
export function isEmptyTextNode(node) {
|
|
11
21
|
return node.textContent.trim() == '' && node.textContent.indexOf('\xa0' /* */) < 0;
|
|
12
22
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { IPoint } from "../../interfaces/IPoint.js";
|
|
2
2
|
export {};
|
|
3
|
-
declare type PathDataM = {
|
|
3
|
+
export declare type PathDataM = {
|
|
4
4
|
type: 'M' | 'm';
|
|
5
5
|
values: [x: number, y: number];
|
|
6
6
|
};
|
|
7
|
-
declare type PathDataL = {
|
|
7
|
+
export declare type PathDataL = {
|
|
8
8
|
type: 'L' | 'l';
|
|
9
9
|
values: [x: number, y: number];
|
|
10
10
|
};
|
|
11
|
-
declare type PathDataT = {
|
|
11
|
+
export declare type PathDataT = {
|
|
12
12
|
type: 'T' | 't';
|
|
13
13
|
values: [x: number, y: number];
|
|
14
14
|
};
|
|
15
|
-
declare type PathDataH = {
|
|
15
|
+
export declare type PathDataH = {
|
|
16
16
|
type: 'H' | 'h';
|
|
17
17
|
values: [x: number];
|
|
18
18
|
};
|
|
19
|
-
declare type PathDataV = {
|
|
19
|
+
export declare type PathDataV = {
|
|
20
20
|
type: 'V' | 'v';
|
|
21
21
|
values: [y: number];
|
|
22
22
|
};
|
|
23
|
-
declare type PathDataZ = {
|
|
23
|
+
export declare type PathDataZ = {
|
|
24
24
|
type: 'Z' | 'z';
|
|
25
25
|
values?: [];
|
|
26
26
|
};
|
|
27
|
-
declare type PathDataC = {
|
|
27
|
+
export declare type PathDataC = {
|
|
28
28
|
type: 'C' | 'c';
|
|
29
29
|
values: [x1: number, y1: number, x2: number, y2: number, x: number, y: number];
|
|
30
30
|
};
|
|
31
|
-
declare type PathDataS = {
|
|
31
|
+
export declare type PathDataS = {
|
|
32
32
|
type: 'S' | 's';
|
|
33
33
|
values: [x2: number, y2: number, x: number, y: number];
|
|
34
34
|
};
|
|
35
|
-
declare type PathDataQ = {
|
|
35
|
+
export declare type PathDataQ = {
|
|
36
36
|
type: 'Q' | 'q';
|
|
37
37
|
values: [x1: number, y1: number, x: number, y: number];
|
|
38
38
|
};
|
|
39
|
-
declare type PathDataA = {
|
|
39
|
+
export declare type PathDataA = {
|
|
40
40
|
type: 'A' | 'a';
|
|
41
41
|
values: [rx: number, ry: number, ang: number, flag1: 0 | 1, flag2: 0 | 1, x: number, y: number];
|
|
42
42
|
};
|
|
@@ -47,6 +47,7 @@ export declare function straightenLine(p1: IPoint, p2: IPoint): IPoint;
|
|
|
47
47
|
export declare function calculateNormLegth(p1: IPoint, p2: IPoint): number;
|
|
48
48
|
export declare function calculateAlpha(p1: IPoint, p2: IPoint): number;
|
|
49
49
|
export declare function moveSVGPath(path: SVGPathElement, xFactor: number, yFactor: number): string;
|
|
50
|
+
export declare function createPathD(path: PathData[]): string;
|
|
50
51
|
declare global {
|
|
51
52
|
interface SVGGraphicsElement {
|
|
52
53
|
getPathData(options?: {
|
|
@@ -857,7 +857,7 @@ if (!SVGPathElement.prototype.getPathData || !SVGPathElement.prototype.setPathDa
|
|
|
857
857
|
})();
|
|
858
858
|
}
|
|
859
859
|
export function straightenLine(p1, p2) {
|
|
860
|
-
let newP
|
|
860
|
+
let newP;
|
|
861
861
|
let alpha = calculateAlpha(p1, p2);
|
|
862
862
|
let normLength;
|
|
863
863
|
if ((alpha >= 337.5 && alpha < 360 || alpha >= 0 && alpha < 22.5)) { // 0
|
|
@@ -941,3 +941,38 @@ export function moveSVGPath(path, xFactor, yFactor) {
|
|
|
941
941
|
}
|
|
942
942
|
return newPathData;
|
|
943
943
|
}
|
|
944
|
+
export function createPathD(path) {
|
|
945
|
+
let pathD = "";
|
|
946
|
+
for (let p of path) {
|
|
947
|
+
switch (p.type) {
|
|
948
|
+
case 'M':
|
|
949
|
+
pathD += p.type + p.values[0] + " " + p.values[1];
|
|
950
|
+
break;
|
|
951
|
+
case 'L':
|
|
952
|
+
pathD += p.type + p.values[0] + " " + p.values[1];
|
|
953
|
+
break;
|
|
954
|
+
case 'H':
|
|
955
|
+
break;
|
|
956
|
+
case 'V':
|
|
957
|
+
break;
|
|
958
|
+
case 'Z':
|
|
959
|
+
pathD += p.type;
|
|
960
|
+
break;
|
|
961
|
+
case 'C':
|
|
962
|
+
case 'c':
|
|
963
|
+
pathD += p.type + p.values[0] + " " + p.values[1] + " " + p.values[2] + " " + p.values[3] + " " + p.values[4] + " " + p.values[5];
|
|
964
|
+
break;
|
|
965
|
+
case 'S':
|
|
966
|
+
break;
|
|
967
|
+
case 'Q':
|
|
968
|
+
case 'q':
|
|
969
|
+
pathD += p.type + p.values[0] + " " + p.values[1] + " " + p.values[2] + " " + p.values[3];
|
|
970
|
+
break;
|
|
971
|
+
case 'T':
|
|
972
|
+
break;
|
|
973
|
+
case 'A':
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return pathD;
|
|
978
|
+
}
|
|
@@ -4,7 +4,6 @@ import { LitElementPropertiesService } from './propertiesService/services/LitEle
|
|
|
4
4
|
import { NativeElementsPropertiesService } from './propertiesService/services/NativeElementsPropertiesService.js';
|
|
5
5
|
import { DefaultInstanceService } from './instanceService/DefaultInstanceService.js';
|
|
6
6
|
import { DefaultEditorTypesService } from './propertiesService/DefaultEditorTypesService.js';
|
|
7
|
-
import { HtmlWriterService } from './htmlWriterService/HtmlWriterService.js';
|
|
8
7
|
import { BaseCustomWebComponentPropertiesService } from './propertiesService/services/BaseCustomWebComponentPropertiesService.js';
|
|
9
8
|
import { DefaultPlacementService } from './placementService/DefaultPlacementService.js';
|
|
10
9
|
import { DefaultHtmlParserService } from './htmlParserService/DefaultHtmlParserService.js';
|
|
@@ -52,6 +51,9 @@ import { DemoProviderService } from './demoProviderService/DemoProviderService';
|
|
|
52
51
|
import { DrawRectTool } from '../widgets/designerView/tools/DrawRectTool.js';
|
|
53
52
|
import { DrawEllipsisTool } from '../widgets/designerView/tools/DrawEllipsisTool.js';
|
|
54
53
|
import { DrawLineTool } from '../widgets/designerView/tools/DrawLineTool.js';
|
|
54
|
+
import { HtmlWriterService } from './htmlWriterService/HtmlWriterService.js';
|
|
55
|
+
import { RectContextMenu } from '../widgets/designerView/extensions/contextMenu/RectContextMenu.js';
|
|
56
|
+
import { PathContextMenu } from '../widgets/designerView/extensions/contextMenu/PathContextMenu.js';
|
|
55
57
|
export function createDefaultServiceContainer() {
|
|
56
58
|
let serviceContainer = new ServiceContainer();
|
|
57
59
|
serviceContainer.register("propertyService", new PolymerPropertiesService());
|
|
@@ -125,7 +127,9 @@ export function createDefaultServiceContainer() {
|
|
|
125
127
|
new CopyPasteContextMenu(),
|
|
126
128
|
new ZMoveContextMenu(),
|
|
127
129
|
new MultipleItemsSelectedContextMenu(),
|
|
128
|
-
new
|
|
130
|
+
new PathContextMenu(),
|
|
131
|
+
new RectContextMenu(),
|
|
132
|
+
new ItemsBelowContextMenu(),
|
|
129
133
|
];
|
|
130
134
|
return serviceContainer;
|
|
131
135
|
}
|
|
@@ -67,7 +67,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
67
67
|
get elementsServices(): IElementsService[];
|
|
68
68
|
get instanceServices(): IInstanceService[];
|
|
69
69
|
get editorTypesServices(): IEditorTypesService[];
|
|
70
|
-
get
|
|
70
|
+
get htmlWriterService(): IHtmlWriterService;
|
|
71
71
|
get htmlParserService(): IHtmlParserService;
|
|
72
72
|
get intializationService(): IIntializationService;
|
|
73
73
|
get elementAtPointService(): IElementAtPointService;
|
|
@@ -40,8 +40,8 @@ export class ServiceContainer extends BaseServiceContainer {
|
|
|
40
40
|
get editorTypesServices() {
|
|
41
41
|
return this.getServices('editorTypesService');
|
|
42
42
|
}
|
|
43
|
-
get
|
|
44
|
-
return this.
|
|
43
|
+
get htmlWriterService() {
|
|
44
|
+
return this.getLastService('htmlWriterService');
|
|
45
45
|
}
|
|
46
46
|
get htmlParserService() {
|
|
47
47
|
return this.getLastService('htmlParserService');
|
|
@@ -2,5 +2,5 @@ import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
|
2
2
|
import { ServiceContainer } from "../ServiceContainer.js";
|
|
3
3
|
import { IDemoProviderService } from "./IDemoProviderService.js";
|
|
4
4
|
export declare class DemoProviderService implements IDemoProviderService {
|
|
5
|
-
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): Promise<void>;
|
|
5
|
+
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string, style: string): Promise<void>;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
2
2
|
export class DemoProviderService {
|
|
3
|
-
provideDemo(container, serviceContainer, instanceServiceContainer, code) {
|
|
3
|
+
provideDemo(container, serviceContainer, instanceServiceContainer, code, style) {
|
|
4
4
|
return new Promise(resolve => {
|
|
5
5
|
const iframe = document.createElement('iframe');
|
|
6
6
|
iframe.style.width = '100%';
|
|
@@ -21,6 +21,7 @@ export class DemoProviderService {
|
|
|
21
21
|
}
|
|
22
22
|
doc.write("document.body.style.display='';");
|
|
23
23
|
doc.write('</script>');
|
|
24
|
+
doc.write('<style>' + (style ?? '') + '</style>');
|
|
24
25
|
doc.write('<body style="display:none; width: 100%; height: 100%; margin: 0; padding: 0; position: absolute;">' + code + '</body>');
|
|
25
26
|
doc.close();
|
|
26
27
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstanceServiceContainer } from "../InstanceServiceContainer.js";
|
|
2
2
|
import { ServiceContainer } from "../ServiceContainer.js";
|
|
3
3
|
export interface IDemoProviderService {
|
|
4
|
-
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string): any;
|
|
4
|
+
provideDemo(container: HTMLElement, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, code: string, style: string): any;
|
|
5
5
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { IHtmlWriterService } from './IHtmlWriterService.js';
|
|
3
|
+
import { IHtmlWriterOptions } from './IHtmlWriterOptions.js';
|
|
4
|
+
import { IndentedTextWriter } from '../../helper/IndentedTextWriter.js';
|
|
5
|
+
import { IStringPosition } from './IStringPosition.js';
|
|
6
|
+
export declare abstract class AbstractHtmlWriterService implements IHtmlWriterService {
|
|
7
|
+
abstract write(indentedTextWriter: IndentedTextWriter, designItems: IDesignItem[], rootContainerKeepInline: boolean, options: IHtmlWriterOptions, designItemsAssignmentList?: Map<IDesignItem, IStringPosition>): any;
|
|
8
|
+
writeAttributes(indentedTextWriter: IndentedTextWriter, designItem: IDesignItem, options: IHtmlWriterOptions): void;
|
|
9
|
+
writeStyles(indentedTextWriter: IndentedTextWriter, designItem: IDesignItem, options: IHtmlWriterOptions): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DomConverter } from '../../widgets/designerView/DomConverter.js';
|
|
2
|
+
import { CssCombiner } from '../../helper/CssCombiner.js';
|
|
3
|
+
import { PropertiesHelper } from '../propertiesService/services/PropertiesHelper.js';
|
|
4
|
+
export class AbstractHtmlWriterService {
|
|
5
|
+
writeAttributes(indentedTextWriter, designItem, options) {
|
|
6
|
+
if (designItem.hasAttributes) {
|
|
7
|
+
for (const a of designItem.attributes) {
|
|
8
|
+
indentedTextWriter.write(' ');
|
|
9
|
+
if (typeof a[1] === 'string') {
|
|
10
|
+
if (a[1] === "")
|
|
11
|
+
indentedTextWriter.write(a[0]);
|
|
12
|
+
else {
|
|
13
|
+
if (options.parseJsonInAttributes &&
|
|
14
|
+
((a[1].startsWith('{') && !a[1].startsWith('{{') && a[1].endsWith('}')) ||
|
|
15
|
+
(a[1].startsWith('[') && !a[1].startsWith('[[') && a[1].endsWith(']')))) {
|
|
16
|
+
try {
|
|
17
|
+
let j = JSON.parse(a[1]);
|
|
18
|
+
let txt;
|
|
19
|
+
if (options.jsonWriteMode == 'beauty')
|
|
20
|
+
txt = JSON.stringify(j, null, 2);
|
|
21
|
+
else
|
|
22
|
+
txt = JSON.stringify(j);
|
|
23
|
+
indentedTextWriter.write(a[0] + '=\'' + DomConverter.normalizeAttributeValue(txt, true) + '\'');
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
const content = DomConverter.normalizeAttributeValue(a[1]);
|
|
29
|
+
if (content.indexOf('"')) {
|
|
30
|
+
const contentSingle = DomConverter.normalizeAttributeValue(a[1], true);
|
|
31
|
+
if (contentSingle.length < content.length)
|
|
32
|
+
indentedTextWriter.write(a[0] + '=\'' + contentSingle + '\'');
|
|
33
|
+
else
|
|
34
|
+
indentedTextWriter.write(a[0] + '="' + content + '"');
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
indentedTextWriter.write(a[0] + '="' + content + '"');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (!a[1])
|
|
41
|
+
indentedTextWriter.write(a[0]);
|
|
42
|
+
else {
|
|
43
|
+
//TODO: writing of bindings, really ???
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
writeStyles(indentedTextWriter, designItem, options) {
|
|
49
|
+
if (designItem.hasStyles) {
|
|
50
|
+
indentedTextWriter.write(' style="');
|
|
51
|
+
let styles = designItem.styles;
|
|
52
|
+
if (options.compressCssToShorthandProperties)
|
|
53
|
+
styles = CssCombiner.combine(styles);
|
|
54
|
+
for (const s of styles) {
|
|
55
|
+
if (s[0]) {
|
|
56
|
+
indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
indentedTextWriter.write('"');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { IHtmlWriterService } from './IHtmlWriterService.js';
|
|
3
|
+
import { IHtmlWriterOptions } from './IHtmlWriterOptions.js';
|
|
4
|
+
import { IndentedTextWriter } from '../../helper/IndentedTextWriter.js';
|
|
5
|
+
import { IStringPosition } from './IStringPosition.js';
|
|
6
|
+
declare enum ElementContainerType {
|
|
7
|
+
block = 0,
|
|
8
|
+
complex = 1
|
|
9
|
+
}
|
|
10
|
+
export declare class FormatingHtmlWriterService implements IHtmlWriterService {
|
|
11
|
+
private writeAttributes;
|
|
12
|
+
private writeStyles;
|
|
13
|
+
private _writeTextNode;
|
|
14
|
+
private _writeCommentNode;
|
|
15
|
+
private _writeElementNode;
|
|
16
|
+
private _writeDesignItemList;
|
|
17
|
+
private _writeNewlineAndIntend;
|
|
18
|
+
private _writeInternal;
|
|
19
|
+
getContainerType(element: HTMLElement): ElementContainerType;
|
|
20
|
+
write(indentedTextWriter: IndentedTextWriter, designItems: IDesignItem[], rootContainerKeepInline: boolean, options: IHtmlWriterOptions, designItemsAssignmentList?: Map<IDesignItem, IStringPosition>): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { DomConverter } from '../../widgets/designerView/DomConverter.js';
|
|
2
|
+
import { CssCombiner } from '../../helper/CssCombiner.js';
|
|
3
|
+
import { NodeType } from '../../item/NodeType.js';
|
|
4
|
+
import { PropertiesHelper } from '../propertiesService/services/PropertiesHelper.js';
|
|
5
|
+
import { ElementDisplayType, getElementDisplaytype } from '../../helper/ElementHelper.js';
|
|
6
|
+
var ElementContainerType;
|
|
7
|
+
(function (ElementContainerType) {
|
|
8
|
+
ElementContainerType[ElementContainerType["block"] = 0] = "block";
|
|
9
|
+
ElementContainerType[ElementContainerType["complex"] = 1] = "complex";
|
|
10
|
+
})(ElementContainerType || (ElementContainerType = {}));
|
|
11
|
+
// const defaultDisplayNoneContainerDisplayType: ElementContainerType = ElementContainerType.complex;
|
|
12
|
+
export class FormatingHtmlWriterService {
|
|
13
|
+
writeAttributes(writeContext, designItem) {
|
|
14
|
+
if (designItem.hasAttributes) {
|
|
15
|
+
for (const a of designItem.attributes) {
|
|
16
|
+
writeContext.indentedTextWriter.write(' ');
|
|
17
|
+
if (typeof a[1] === 'string') {
|
|
18
|
+
if (a[1] === "")
|
|
19
|
+
writeContext.indentedTextWriter.write(a[0]);
|
|
20
|
+
else
|
|
21
|
+
writeContext.indentedTextWriter.write(a[0] + '="' + DomConverter.normalizeAttributeValue(a[1]) + '"');
|
|
22
|
+
}
|
|
23
|
+
else if (!a[1])
|
|
24
|
+
writeContext.indentedTextWriter.write(a[0]);
|
|
25
|
+
else {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
writeStyles(writeContext, designItem) {
|
|
31
|
+
if (designItem.hasStyles) {
|
|
32
|
+
writeContext.indentedTextWriter.write(' style="');
|
|
33
|
+
let styles = designItem.styles;
|
|
34
|
+
if (writeContext.options.compressCssToShorthandProperties)
|
|
35
|
+
styles = CssCombiner.combine(styles);
|
|
36
|
+
for (const s of styles) {
|
|
37
|
+
if (s[0]) {
|
|
38
|
+
writeContext.indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
writeContext.indentedTextWriter.write('"');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
_writeTextNode(writeContext, designItem) {
|
|
45
|
+
writeContext.lastElementDisplayType = ElementDisplayType.inline;
|
|
46
|
+
let content = DomConverter.normalizeContentValue(designItem.content).trim();
|
|
47
|
+
if (content) {
|
|
48
|
+
writeContext.indentedTextWriter.write(content);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
_writeCommentNode(writeContext, designItem) {
|
|
52
|
+
writeContext.indentedTextWriter.write('<!--' + designItem.content + '-->');
|
|
53
|
+
}
|
|
54
|
+
_writeElementNode(writeContext, designItem) {
|
|
55
|
+
// const cs = getComputedStyle(designItem.element);
|
|
56
|
+
//cs.whiteSpace === 'pre'
|
|
57
|
+
//isInPre
|
|
58
|
+
//is in inline?
|
|
59
|
+
const currentElementDisplayType = getElementDisplaytype(designItem.element);
|
|
60
|
+
writeContext.lastElementDisplayType = currentElementDisplayType;
|
|
61
|
+
writeContext.indentedTextWriter.write('<' + designItem.name);
|
|
62
|
+
this.writeAttributes(writeContext, designItem);
|
|
63
|
+
this.writeStyles(writeContext, designItem);
|
|
64
|
+
writeContext.indentedTextWriter.write('>');
|
|
65
|
+
let contentSingleTextNode = false;
|
|
66
|
+
if (designItem.hasChildren) {
|
|
67
|
+
const children = designItem.children();
|
|
68
|
+
contentSingleTextNode = designItem.childCount === 1 && designItem.firstChild.nodeType === NodeType.TextNode;
|
|
69
|
+
if (contentSingleTextNode) {
|
|
70
|
+
this._writeInternal(writeContext, designItem.firstChild);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
let previousContainerDisplayType = writeContext.containerDisplayType;
|
|
74
|
+
writeContext.containerDisplayType = this.getContainerType(designItem.element);
|
|
75
|
+
writeContext.indentedTextWriter.levelRaise();
|
|
76
|
+
this._writeDesignItemList(currentElementDisplayType, writeContext, children);
|
|
77
|
+
writeContext.indentedTextWriter.levelShrink();
|
|
78
|
+
writeContext.containerDisplayType = previousContainerDisplayType;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (designItem.hasContent) {
|
|
82
|
+
writeContext.indentedTextWriter.write(DomConverter.normalizeContentValue(designItem.content));
|
|
83
|
+
}
|
|
84
|
+
if (!DomConverter.IsSelfClosingElement(designItem.name)) {
|
|
85
|
+
if (currentElementDisplayType === ElementDisplayType.block && designItem.hasChildren && !contentSingleTextNode) {
|
|
86
|
+
this._writeNewlineAndIntend(writeContext);
|
|
87
|
+
}
|
|
88
|
+
//write newline & intend ???
|
|
89
|
+
writeContext.indentedTextWriter.write('</' + designItem.name + '>');
|
|
90
|
+
if (currentElementDisplayType !== ElementDisplayType.none) {
|
|
91
|
+
writeContext.lastElementDisplayType = currentElementDisplayType;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
_writeDesignItemList(currentElementDisplayType, writeContext, children) {
|
|
96
|
+
for (const c of children) {
|
|
97
|
+
if (writeContext.lastElementDisplayType == null) {
|
|
98
|
+
//first entry, do nothing
|
|
99
|
+
}
|
|
100
|
+
else if (writeContext.containerDisplayType === ElementContainerType.complex)
|
|
101
|
+
this._writeNewlineAndIntend(writeContext);
|
|
102
|
+
else if (writeContext.lastElementDisplayType !== ElementDisplayType.inline /*|| currentElementDisplayType !== ElementDisplayType.inline*/)
|
|
103
|
+
this._writeNewlineAndIntend(writeContext);
|
|
104
|
+
this._writeInternal(writeContext, c);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_writeNewlineAndIntend(writeContext) {
|
|
108
|
+
writeContext.indentedTextWriter.writeNewline();
|
|
109
|
+
writeContext.indentedTextWriter.writeIndent();
|
|
110
|
+
}
|
|
111
|
+
_writeInternal(writeContext, designItem) {
|
|
112
|
+
const start = writeContext.indentedTextWriter.position;
|
|
113
|
+
if (designItem.nodeType === NodeType.TextNode)
|
|
114
|
+
this._writeTextNode(writeContext, designItem);
|
|
115
|
+
else if (designItem.nodeType === NodeType.Comment)
|
|
116
|
+
this._writeCommentNode(writeContext, designItem);
|
|
117
|
+
else if (designItem.nodeType === NodeType.Element)
|
|
118
|
+
this._writeElementNode(writeContext, designItem);
|
|
119
|
+
if (writeContext.designItemsAssignmentList) {
|
|
120
|
+
writeContext.designItemsAssignmentList.set(designItem, { start: start, length: writeContext.indentedTextWriter.position - start - 1 });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
getContainerType(element) {
|
|
124
|
+
const display = window.getComputedStyle(element).display;
|
|
125
|
+
if (display === 'block' || display === "inline-block" || display == '')
|
|
126
|
+
return ElementContainerType.block;
|
|
127
|
+
return ElementContainerType.complex;
|
|
128
|
+
}
|
|
129
|
+
write(indentedTextWriter, designItems, rootContainerKeepInline, options, designItemsAssignmentList) {
|
|
130
|
+
const context = { indentedTextWriter, options, lastElementDisplayType: null, containerDisplayType: ElementContainerType.block, designItemsAssignmentList };
|
|
131
|
+
this._writeDesignItemList(ElementDisplayType.inline, context, designItems);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -4,9 +4,9 @@ import { IHtmlWriterOptions } from './IHtmlWriterOptions';
|
|
|
4
4
|
import { IndentedTextWriter } from '../../helper/IndentedTextWriter';
|
|
5
5
|
import { IStringPosition } from './IStringPosition';
|
|
6
6
|
export declare class HtmlWriterService implements IHtmlWriterService {
|
|
7
|
-
canWrite(designItem: IDesignItem): boolean;
|
|
8
7
|
private _conditionalyWriteIndent;
|
|
9
8
|
private _conditionalyWriteNewline;
|
|
10
|
-
write(indentedTextWriter: IndentedTextWriter,
|
|
9
|
+
write(indentedTextWriter: IndentedTextWriter, designItems: IDesignItem[], rootContainerKeepInline: boolean, options: IHtmlWriterOptions, designItemsAssignmentList?: Map<IDesignItem, IStringPosition>): void;
|
|
10
|
+
private internalWrite;
|
|
11
11
|
private writeTextNode;
|
|
12
12
|
}
|
|
@@ -2,14 +2,12 @@ import { DomConverter } from '../../widgets/designerView/DomConverter';
|
|
|
2
2
|
import { CssCombiner } from '../../helper/CssCombiner';
|
|
3
3
|
import { NodeType } from '../../item/NodeType';
|
|
4
4
|
import { PropertiesHelper } from '../propertiesService/services/PropertiesHelper';
|
|
5
|
-
import { isInline } from '../../helper/ElementHelper.js';
|
|
5
|
+
import { isEmptyTextNode, isInline } from '../../helper/ElementHelper.js';
|
|
6
6
|
export class HtmlWriterService {
|
|
7
|
-
canWrite(designItem) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
7
|
_conditionalyWriteIndent(indentedTextWriter, designItem) {
|
|
11
8
|
if ((designItem.element instanceof HTMLElement && !isInline(designItem.element)) ||
|
|
12
|
-
(designItem.element.previousElementSibling instanceof HTMLElement && !isInline(designItem.element.previousElementSibling))
|
|
9
|
+
(designItem.element.previousElementSibling instanceof HTMLElement && !isInline(designItem.element.previousElementSibling)) ||
|
|
10
|
+
(designItem.element.previousElementSibling == null && !isInline(designItem.element.parentElement) && (designItem.element.previousSibling == null || isEmptyTextNode(designItem.element.previousSibling))))
|
|
13
11
|
indentedTextWriter.writeIndent();
|
|
14
12
|
}
|
|
15
13
|
_conditionalyWriteNewline(indentedTextWriter, designItem) {
|
|
@@ -17,10 +15,20 @@ export class HtmlWriterService {
|
|
|
17
15
|
(designItem.element.nextElementSibling instanceof HTMLElement && !isInline(designItem.element.nextElementSibling)))
|
|
18
16
|
indentedTextWriter.writeNewline();
|
|
19
17
|
}
|
|
20
|
-
write(indentedTextWriter,
|
|
18
|
+
write(indentedTextWriter, designItems, rootContainerKeepInline, options, designItemsAssignmentList) {
|
|
19
|
+
for (const d of designItems) {
|
|
20
|
+
this.internalWrite(indentedTextWriter, d, options, designItemsAssignmentList);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
internalWrite(indentedTextWriter, designItem, options, designItemsAssignmentList) {
|
|
21
24
|
let start = indentedTextWriter.position;
|
|
22
25
|
if (designItem.nodeType == NodeType.TextNode) {
|
|
23
|
-
|
|
26
|
+
if (isEmptyTextNode(designItem.element) &&
|
|
27
|
+
((designItem.element.previousSibling instanceof HTMLElement && !isInline(designItem.element.previousSibling)) ||
|
|
28
|
+
(designItem.element.nextSibling instanceof HTMLElement && !isInline(designItem.element.nextSibling)))) {
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
this.writeTextNode(indentedTextWriter, designItem, true);
|
|
24
32
|
}
|
|
25
33
|
else if (designItem.nodeType == NodeType.Comment) {
|
|
26
34
|
this._conditionalyWriteIndent(indentedTextWriter, designItem);
|
|
@@ -59,24 +67,30 @@ export class HtmlWriterService {
|
|
|
59
67
|
indentedTextWriter.write('"');
|
|
60
68
|
}
|
|
61
69
|
indentedTextWriter.write('>');
|
|
70
|
+
let contentSingleTextNode = false;
|
|
62
71
|
if (designItem.hasChildren) {
|
|
63
72
|
const children = designItem.children();
|
|
64
|
-
|
|
65
|
-
if (
|
|
73
|
+
contentSingleTextNode = designItem.childCount === 1 && designItem.firstChild.nodeType === NodeType.TextNode;
|
|
74
|
+
if (contentSingleTextNode) {
|
|
66
75
|
this.writeTextNode(indentedTextWriter, designItem, false);
|
|
67
76
|
}
|
|
68
77
|
else {
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
if (designItem.element instanceof HTMLElement && !isInline(designItem.element)) {
|
|
79
|
+
indentedTextWriter.writeNewline();
|
|
80
|
+
indentedTextWriter.levelRaise();
|
|
81
|
+
}
|
|
71
82
|
for (const c of children) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
this.internalWrite(indentedTextWriter, c, options, designItemsAssignmentList);
|
|
84
|
+
let childSingleTextNode = c.childCount === 1 && c.firstChild.nodeType === NodeType.TextNode;
|
|
85
|
+
if (childSingleTextNode)
|
|
86
|
+
indentedTextWriter.writeNewline();
|
|
87
|
+
}
|
|
88
|
+
if (designItem.element instanceof HTMLElement && !isInline(designItem.element)) {
|
|
89
|
+
indentedTextWriter.levelShrink();
|
|
90
|
+
if (!indentedTextWriter.isLastCharNewline())
|
|
91
|
+
indentedTextWriter.writeNewline();
|
|
92
|
+
indentedTextWriter.writeIndent();
|
|
77
93
|
}
|
|
78
|
-
indentedTextWriter.levelShrink();
|
|
79
|
-
indentedTextWriter.writeIndent();
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
else if (designItem.hasContent) {
|
|
@@ -84,7 +98,8 @@ export class HtmlWriterService {
|
|
|
84
98
|
}
|
|
85
99
|
if (!DomConverter.IsSelfClosingElement(designItem.name))
|
|
86
100
|
indentedTextWriter.write('</' + designItem.name + '>');
|
|
87
|
-
|
|
101
|
+
if (!contentSingleTextNode)
|
|
102
|
+
this._conditionalyWriteNewline(indentedTextWriter, designItem);
|
|
88
103
|
}
|
|
89
104
|
if (designItemsAssignmentList) {
|
|
90
105
|
designItemsAssignmentList.set(designItem, { start: start, length: indentedTextWriter.position - start - 1 });
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { IDesignItem } from '../../item/IDesignItem';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export declare class HtmlWriterService
|
|
7
|
-
canWrite(designItem: IDesignItem): boolean;
|
|
1
|
+
import { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { IHtmlWriterOptions } from './IHtmlWriterOptions.js';
|
|
3
|
+
import { IndentedTextWriter } from '../../helper/IndentedTextWriter.js';
|
|
4
|
+
import { IStringPosition } from './IStringPosition.js';
|
|
5
|
+
import { AbstractHtmlWriterService } from './AbstractHtmlWriterService.js';
|
|
6
|
+
export declare class HtmlWriterService extends AbstractHtmlWriterService {
|
|
8
7
|
private _conditionalyWriteIndent;
|
|
9
8
|
private _conditionalyWriteNewline;
|
|
10
|
-
write(indentedTextWriter: IndentedTextWriter,
|
|
9
|
+
write(indentedTextWriter: IndentedTextWriter, designItems: IDesignItem[], rootContainerKeepInline: boolean, options: IHtmlWriterOptions, designItemsAssignmentList?: Map<IDesignItem, IStringPosition>): void;
|
|
10
|
+
private internalWrite;
|
|
11
11
|
private writeTextNode;
|
|
12
12
|
}
|