@node-projects/web-component-designer 0.0.16 → 0.0.21
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/config/elements-native.json +42 -0
- package/dist/elements/documentContainer.js +1 -0
- package/dist/elements/item/DesignItem.d.ts +1 -0
- package/dist/elements/item/DesignItem.js +36 -27
- package/dist/elements/item/IDesignItem.d.ts +1 -0
- package/dist/elements/services/DefaultServiceBootstrap.js +12 -0
- package/dist/elements/services/ServiceContainer.d.ts +9 -0
- package/dist/elements/services/ServiceContainer.js +9 -0
- package/dist/elements/services/dragDropService/DragDropService.d.ts +6 -0
- package/dist/elements/services/dragDropService/DragDropService.js +28 -0
- package/dist/elements/services/dragDropService/IDragDropService.d.ts +5 -0
- package/dist/elements/{loader/ICustomElementsManifest.js → services/dragDropService/IDragDropService.js} +0 -0
- package/dist/elements/services/instanceService/IPrepareElementsForDesignerService.d.ts +4 -0
- package/dist/elements/{loader/IOldCustomElementsManifest copy.js → services/instanceService/IPrepareElementsForDesignerService.js} +0 -0
- package/dist/elements/services/instanceService/PrepareElementsForDesignerService.d.ts +6 -0
- package/dist/elements/services/instanceService/PrepareElementsForDesignerService.js +23 -0
- package/dist/elements/services/placementService/ISnaplinesProviderService.d.ts +11 -0
- package/dist/elements/services/placementService/ISnaplinesProviderService.js +1 -0
- package/dist/elements/services/placementService/SnaplinesProviderService.d.ts +11 -0
- package/dist/elements/services/placementService/SnaplinesProviderService.js +36 -0
- package/dist/elements/services/undoService/transactionItems/InsertAction.js +3 -0
- package/dist/elements/widgets/designerView/IDesignerView.d.ts +1 -0
- package/dist/elements/widgets/designerView/Snaplines.js +6 -25
- package/dist/elements/widgets/designerView/designerView.d.ts +4 -2
- package/dist/elements/widgets/designerView/designerView.js +58 -29
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextCkEditorExtension.d.ts +14 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextCkEditorExtension.js +42 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextCkEditorExtensionProvider.d.ts +9 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextCkEditorExtensionProvider.js +9 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.d.ts +17 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.js +78 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtensionProvider.d.ts +9 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtensionProvider.js +11 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextTinyMceExtension.d.ts +27 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextTinyMceExtension.js +61 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextTinyMceExtensionProvider.d.ts +9 -0
- package/dist/elements/widgets/designerView/extensions/EditText/EditTextTinyMceExtensionProvider.js +9 -0
- package/dist/elements/widgets/designerView/extensions/ExtensionType.d.ts +5 -1
- package/dist/elements/widgets/designerView/extensions/ExtensionType.js +4 -0
- package/dist/elements/widgets/designerView/extensions/GridExtension.js +5 -4
- package/dist/elements/widgets/designerView/extensions/RotateExtension.js +3 -3
- package/dist/elements/widgets/designerView/overlayLayerView.d.ts +2 -2
- package/dist/elements/widgets/designerView/overlayLayerView.js +3 -2
- package/dist/enums/EventNames.d.ts +5 -1
- package/dist/enums/EventNames.js +4 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/package.json +3 -3
- package/dist/elements/loader/CustomElementsManifestLoader.d.ts +0 -8
- package/dist/elements/loader/CustomElementsManifestLoader.js +0 -45
- package/dist/elements/loader/ICustomElementsManifest.d.ts +0 -24
- package/dist/elements/loader/IOldCustomElementsManifest copy.d.ts +0 -24
- package/dist/elements/loader/OldCustomElementsManifestLoader copy.d.ts +0 -8
- package/dist/elements/loader/OldCustomElementsManifestLoader copy.js +0 -45
- package/dist/elements/widgets/designerView/extensions/ExtensionLayer.d.ts +0 -5
- package/dist/elements/widgets/designerView/extensions/ExtensionLayer.js +0 -6
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"elements":
|
|
3
|
+
[
|
|
4
|
+
"div",
|
|
5
|
+
"input",
|
|
6
|
+
{"tag" : "button", "defaultWidth": "80px", "defaultHeight": "30px", "defaultContent": "Button" },
|
|
7
|
+
"img",
|
|
8
|
+
"iframe",
|
|
9
|
+
{"tag" : "a" },
|
|
10
|
+
"p",
|
|
11
|
+
"span",
|
|
12
|
+
"b",
|
|
13
|
+
"i",
|
|
14
|
+
"u",
|
|
15
|
+
"br",
|
|
16
|
+
"em",
|
|
17
|
+
"q",
|
|
18
|
+
"small",
|
|
19
|
+
"strong",
|
|
20
|
+
"form",
|
|
21
|
+
"h1",
|
|
22
|
+
"h2",
|
|
23
|
+
"h3",
|
|
24
|
+
"h4",
|
|
25
|
+
"h5",
|
|
26
|
+
"h6",
|
|
27
|
+
"ol",
|
|
28
|
+
"ul",
|
|
29
|
+
"li",
|
|
30
|
+
"pre",
|
|
31
|
+
"table",
|
|
32
|
+
"caption",
|
|
33
|
+
"colgroup",
|
|
34
|
+
"col",
|
|
35
|
+
"thead",
|
|
36
|
+
"th",
|
|
37
|
+
"tbody",
|
|
38
|
+
"tr",
|
|
39
|
+
"td",
|
|
40
|
+
"tfoot"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -12,6 +12,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
|
|
|
12
12
|
this._tabControl = new DesignerTabControl();
|
|
13
13
|
div.appendChild(this._tabControl);
|
|
14
14
|
this.designerView = new DesignerView();
|
|
15
|
+
this.designerView.setAttribute('exportparts', 'canvas');
|
|
15
16
|
this.designerView.title = 'Designer';
|
|
16
17
|
this._tabControl.appendChild(this.designerView);
|
|
17
18
|
this.designerView.initialize(this._serviceContainer);
|
|
@@ -44,6 +44,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
44
44
|
get lockAtDesignTime(): boolean;
|
|
45
45
|
set lockAtDesignTime(value: boolean);
|
|
46
46
|
static createDesignItemFromInstance(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): DesignItem;
|
|
47
|
+
updateChildrenFromNodesChildren(): void;
|
|
47
48
|
constructor(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer);
|
|
48
49
|
openGroup(title: string, affectedItems?: IDesignItem[]): ChangeGroup;
|
|
49
50
|
getOrCreateDesignItem(node: Node): IDesignItem;
|
|
@@ -93,6 +93,7 @@ export class DesignItem {
|
|
|
93
93
|
this._childArray = [];
|
|
94
94
|
DomHelper.removeAllChildnodes(this.element);
|
|
95
95
|
}
|
|
96
|
+
//abstract text content to own property. so only chnage via designer api will use it.
|
|
96
97
|
get hasContent() {
|
|
97
98
|
return this.nodeType == NodeType.TextNode || (this._childArray.length === 0 && this.content !== null);
|
|
98
99
|
}
|
|
@@ -154,37 +155,45 @@ export class DesignItem {
|
|
|
154
155
|
}
|
|
155
156
|
static createDesignItemFromInstance(node, serviceContainer, instanceServiceContainer) {
|
|
156
157
|
let designItem = new DesignItem(node, serviceContainer, instanceServiceContainer);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
if (designItem.nodeType == NodeType.Element) {
|
|
159
|
+
for (let a of designItem.element.attributes) {
|
|
160
|
+
if (a.name !== 'style') {
|
|
161
|
+
designItem.attributes.set(a.name, a.value);
|
|
162
|
+
if (a.name === hideAtDesignTimeAttributeName)
|
|
163
|
+
designItem._hideAtDesignTime = true;
|
|
164
|
+
if (a.name === hideAtRunTimeAttributeName)
|
|
165
|
+
designItem._hideAtRunTime = true;
|
|
166
|
+
if (a.name === lockAtDesignTimeAttributeName)
|
|
167
|
+
designItem._lockAtDesignTime = true;
|
|
168
|
+
}
|
|
169
|
+
if (node instanceof HTMLElement || node instanceof SVGElement) {
|
|
170
|
+
for (let s of node.style) {
|
|
171
|
+
let val = node.style[s];
|
|
172
|
+
if (val && typeof val === 'string')
|
|
173
|
+
designItem.styles.set(s, node.style[s]);
|
|
174
|
+
}
|
|
175
|
+
if (!designItem._lockAtDesignTime)
|
|
176
|
+
node.style.pointerEvents = 'auto';
|
|
177
|
+
else
|
|
178
|
+
node.style.pointerEvents = 'none';
|
|
179
|
+
//node.style.cursor = 'pointer';
|
|
180
|
+
}
|
|
181
|
+
node.draggable = false; //even if it should be true, for better designer exp.
|
|
166
182
|
}
|
|
167
183
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
designItem.updateChildrenFromNodesChildren();
|
|
185
|
+
return designItem;
|
|
186
|
+
}
|
|
187
|
+
updateChildrenFromNodesChildren() {
|
|
188
|
+
this._childArray = [];
|
|
189
|
+
if (this.nodeType == NodeType.Element) {
|
|
190
|
+
if (this.element.children && this.element.children.length === 0 && this.element.childNodes.length <= 1)
|
|
191
|
+
this.content = this.element.textContent; //was soll das bringen???
|
|
192
|
+
else {
|
|
193
|
+
for (const c of this.element.childNodes)
|
|
194
|
+
this._childArray.push(DesignItem.createDesignItemFromInstance(c, this.serviceContainer, this.instanceServiceContainer));
|
|
173
195
|
}
|
|
174
|
-
if (!designItem._lockAtDesignTime)
|
|
175
|
-
node.style.pointerEvents = 'auto';
|
|
176
|
-
else
|
|
177
|
-
node.style.pointerEvents = 'none';
|
|
178
|
-
//node.style.cursor = 'pointer';
|
|
179
196
|
}
|
|
180
|
-
node.draggable = false; //even if it should be true, for better designer exp.
|
|
181
|
-
if (designItem.element.children.length === 0)
|
|
182
|
-
designItem.content = designItem.element.textContent;
|
|
183
|
-
else {
|
|
184
|
-
for (const c of designItem.element.children)
|
|
185
|
-
designItem._childArray.push(DesignItem.createDesignItemFromInstance(c, serviceContainer, instanceServiceContainer));
|
|
186
|
-
}
|
|
187
|
-
return designItem;
|
|
188
197
|
}
|
|
189
198
|
openGroup(title, affectedItems) {
|
|
190
199
|
return this.instanceServiceContainer.undoService.openGroup(title, affectedItems);
|
|
@@ -39,6 +39,11 @@ import { PolymerBindingsService } from './bindingsService/PolymerBindingsService
|
|
|
39
39
|
import { ItemsBelowContextMenu } from '../widgets/designerView/extensions/contextMenu/ItemsBelowContextMenu.js';
|
|
40
40
|
import { GridPlacementService } from './placementService/GridPlacementService.js';
|
|
41
41
|
import { ElementAtPointService } from './elementAtPointService/ElementAtPointService';
|
|
42
|
+
import { FlexBoxPlacementService } from './placementService/FlexBoxPlacementService';
|
|
43
|
+
import { SnaplinesProviderService } from './placementService/SnaplinesProviderService';
|
|
44
|
+
import { PrepareElementsForDesignerService } from './instanceService/PrepareElementsForDesignerService';
|
|
45
|
+
import { DragDropService } from './dragDropService/DragDropService';
|
|
46
|
+
import { EditTextExtensionProvider } from '../widgets/designerView/extensions/EditText/EditTextExtensionProvider.js';
|
|
42
47
|
export function createDefaultServiceContainer() {
|
|
43
48
|
let serviceContainer = new ServiceContainer();
|
|
44
49
|
serviceContainer.register("propertyService", new PolymerPropertiesService());
|
|
@@ -51,9 +56,13 @@ export function createDefaultServiceContainer() {
|
|
|
51
56
|
serviceContainer.register("htmlWriterService", new HtmlWriterService());
|
|
52
57
|
serviceContainer.register("containerService", new DefaultPlacementService());
|
|
53
58
|
serviceContainer.register("containerService", new GridPlacementService());
|
|
59
|
+
serviceContainer.register("containerService", new FlexBoxPlacementService());
|
|
60
|
+
serviceContainer.register("snaplinesProviderService", new SnaplinesProviderService());
|
|
54
61
|
serviceContainer.register("htmlParserService", new DefaultHtmlParserService());
|
|
55
62
|
serviceContainer.register("bindingService", new PolymerBindingsService());
|
|
56
63
|
serviceContainer.register("elementAtPointService", new ElementAtPointService());
|
|
64
|
+
serviceContainer.register("prepareElementsForDesignerService", new PrepareElementsForDesignerService());
|
|
65
|
+
serviceContainer.register("dragDropService", new DragDropService());
|
|
57
66
|
serviceContainer.designerExtensions.set(ExtensionType.Permanent, [
|
|
58
67
|
new ResizeExtensionProvider(false),
|
|
59
68
|
new InvisibleDivExtensionProvider()
|
|
@@ -83,6 +92,9 @@ export function createDefaultServiceContainer() {
|
|
|
83
92
|
serviceContainer.designerExtensions.set(ExtensionType.ContainerDragOver, [
|
|
84
93
|
new AltToEnterContainerExtensionProvider()
|
|
85
94
|
]);
|
|
95
|
+
serviceContainer.designerExtensions.set(ExtensionType.Doubleclick, [
|
|
96
|
+
new EditTextExtensionProvider()
|
|
97
|
+
]);
|
|
86
98
|
serviceContainer.designerTools.set(NamedTools.Pointer, new PointerTool());
|
|
87
99
|
serviceContainer.designerTools.set(NamedTools.DrawSelection, new RectangleSelectorTool());
|
|
88
100
|
serviceContainer.designerTools.set(NamedTools.DrawPath, new DrawPathTool());
|
|
@@ -17,9 +17,13 @@ import { IContextMenuExtension } from "../widgets/designerView/extensions/contex
|
|
|
17
17
|
import { GlobalContext } from './GlobalContext';
|
|
18
18
|
import { IBindingService } from "./bindingsService/IBindingService";
|
|
19
19
|
import { IElementAtPointService } from './elementAtPointService/IElementAtPointService';
|
|
20
|
+
import { ISnaplinesProviderService } from "./placementService/ISnaplinesProviderService.js";
|
|
21
|
+
import { IPrepareElementsForDesignerService } from './instanceService/IPrepareElementsForDesignerService';
|
|
22
|
+
import { IDragDropService } from './dragDropService/IDragDropService';
|
|
20
23
|
interface ServiceNameMap {
|
|
21
24
|
"propertyService": IPropertiesService;
|
|
22
25
|
"containerService": IPlacementService;
|
|
26
|
+
"snaplinesProviderService": ISnaplinesProviderService;
|
|
23
27
|
"elementsService": IElementsService;
|
|
24
28
|
"instanceService": IInstanceService;
|
|
25
29
|
"editorTypesService": IEditorTypesService;
|
|
@@ -28,6 +32,8 @@ interface ServiceNameMap {
|
|
|
28
32
|
"intializationService": IIntializationService;
|
|
29
33
|
"bindingService": IBindingService;
|
|
30
34
|
"elementAtPointService": IElementAtPointService;
|
|
35
|
+
"prepareElementsForDesignerService": IPrepareElementsForDesignerService;
|
|
36
|
+
"dragDropService": IDragDropService;
|
|
31
37
|
}
|
|
32
38
|
export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMap> {
|
|
33
39
|
readonly config: {
|
|
@@ -41,6 +47,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
41
47
|
get bindingServices(): IBindingService[];
|
|
42
48
|
get propertiesServices(): IPropertiesService[];
|
|
43
49
|
get containerServices(): IPlacementService[];
|
|
50
|
+
get snaplinesProviderService(): ISnaplinesProviderService;
|
|
44
51
|
get elementsServices(): IElementsService[];
|
|
45
52
|
get instanceServices(): IInstanceService[];
|
|
46
53
|
get editorTypesServices(): IEditorTypesService[];
|
|
@@ -48,5 +55,7 @@ export declare class ServiceContainer extends BaseServiceContainer<ServiceNameMa
|
|
|
48
55
|
get htmlParserService(): IHtmlParserService;
|
|
49
56
|
get intializationService(): IIntializationService;
|
|
50
57
|
get elementAtPointService(): IElementAtPointService;
|
|
58
|
+
get prepareElementsForDesignerService(): IPrepareElementsForDesignerService;
|
|
59
|
+
get dragDropService(): IDragDropService;
|
|
51
60
|
}
|
|
52
61
|
export {};
|
|
@@ -22,6 +22,9 @@ export class ServiceContainer extends BaseServiceContainer {
|
|
|
22
22
|
get containerServices() {
|
|
23
23
|
return this.getServices('containerService');
|
|
24
24
|
}
|
|
25
|
+
get snaplinesProviderService() {
|
|
26
|
+
return this.getLastService('snaplinesProviderService');
|
|
27
|
+
}
|
|
25
28
|
get elementsServices() {
|
|
26
29
|
return this.getServices('elementsService');
|
|
27
30
|
}
|
|
@@ -43,4 +46,10 @@ export class ServiceContainer extends BaseServiceContainer {
|
|
|
43
46
|
get elementAtPointService() {
|
|
44
47
|
return this.getLastService('elementAtPointService');
|
|
45
48
|
}
|
|
49
|
+
get prepareElementsForDesignerService() {
|
|
50
|
+
return this.getLastService('prepareElementsForDesignerService');
|
|
51
|
+
}
|
|
52
|
+
get dragDropService() {
|
|
53
|
+
return this.getLastService('dragDropService');
|
|
54
|
+
}
|
|
46
55
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IDesignerView } from "../../widgets/designerView/IDesignerView.js";
|
|
2
|
+
import { IDragDropService } from "./IDragDropService.js";
|
|
3
|
+
export declare class DragDropService implements IDragDropService {
|
|
4
|
+
dragOver(event: DragEvent): 'none' | 'copy' | 'link' | 'move';
|
|
5
|
+
drop(designerView: IDesignerView, event: DragEvent): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DesignItem } from '../../item/DesignItem';
|
|
2
|
+
import { InsertAction } from "../undoService/transactionItems/InsertAction.js";
|
|
3
|
+
export class DragDropService {
|
|
4
|
+
dragOver(event) {
|
|
5
|
+
if (event.dataTransfer.items[0].type.startsWith('image/'))
|
|
6
|
+
return 'copy';
|
|
7
|
+
return 'none';
|
|
8
|
+
}
|
|
9
|
+
drop(designerView, event) {
|
|
10
|
+
if (event.dataTransfer.files[0].type.startsWith('image/')) {
|
|
11
|
+
let reader = new FileReader();
|
|
12
|
+
reader.onloadend = () => {
|
|
13
|
+
const img = document.createElement('img');
|
|
14
|
+
img.src = reader.result;
|
|
15
|
+
const di = DesignItem.createDesignItemFromInstance(img, designerView.serviceContainer, designerView.instanceServiceContainer);
|
|
16
|
+
let grp = di.openGroup("Insert");
|
|
17
|
+
di.setStyle('position', 'absolute');
|
|
18
|
+
const targetRect = event.target.getBoundingClientRect();
|
|
19
|
+
di.setStyle('top', event.offsetY + targetRect.top - designerView.containerBoundingRect.y + 'px');
|
|
20
|
+
di.setStyle('left', event.offsetX + targetRect.left - designerView.containerBoundingRect.x + 'px');
|
|
21
|
+
designerView.instanceServiceContainer.undoService.execute(new InsertAction(designerView.rootDesignItem, designerView.rootDesignItem.childCount, di));
|
|
22
|
+
grp.commit();
|
|
23
|
+
requestAnimationFrame(() => designerView.instanceServiceContainer.selectionService.setSelectedElements([di]));
|
|
24
|
+
};
|
|
25
|
+
reader.readAsDataURL(event.dataTransfer.files[0]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
+
import { IPrepareElementsForDesignerService } from "./IPrepareElementsForDesignerService.js";
|
|
3
|
+
export declare class PrepareElementsForDesignerService implements IPrepareElementsForDesignerService {
|
|
4
|
+
prepareElementsForDesigner(designItem: IDesignItem): void;
|
|
5
|
+
private _prepareElementsForDesigner;
|
|
6
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class PrepareElementsForDesignerService {
|
|
2
|
+
prepareElementsForDesigner(designItem) {
|
|
3
|
+
this._prepareElementsForDesigner([designItem.element]);
|
|
4
|
+
}
|
|
5
|
+
_prepareElementsForDesigner(elements) {
|
|
6
|
+
for (let el of elements) {
|
|
7
|
+
if (el.shadowRoot) {
|
|
8
|
+
this._prepareElementsForDesigner((el.shadowRoot).querySelectorAll('*'));
|
|
9
|
+
}
|
|
10
|
+
if (el instanceof HTMLImageElement) {
|
|
11
|
+
el.draggable = false;
|
|
12
|
+
}
|
|
13
|
+
else if (el instanceof HTMLInputElement) {
|
|
14
|
+
el.onmousedown = (e) => e.preventDefault();
|
|
15
|
+
//const ip = el;
|
|
16
|
+
//el.onclick = (e) => { if (ip.type == 'checkbox') ip.checked = !ip.checked };
|
|
17
|
+
}
|
|
18
|
+
else if (el instanceof HTMLSelectElement) {
|
|
19
|
+
el.onmousedown = (e) => e.preventDefault();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IService } from "../IService";
|
|
2
|
+
import { IDesignItem } from "../../item/IDesignItem";
|
|
3
|
+
export interface ISnaplinesProviderService extends IService {
|
|
4
|
+
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
|
+
outerRect: DOMRect;
|
|
6
|
+
positionsH: [number, DOMRect][];
|
|
7
|
+
positionsMiddleH: [number, DOMRect][];
|
|
8
|
+
positionsV: [number, DOMRect][];
|
|
9
|
+
positionsMiddleV: [number, DOMRect][];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDesignItem } from '../../item/IDesignItem.js';
|
|
2
|
+
import { ISnaplinesProviderService } from './ISnaplinesProviderService.js';
|
|
3
|
+
export declare class SnaplinesProviderService implements ISnaplinesProviderService {
|
|
4
|
+
provideSnaplines(containerItem: IDesignItem, ignoredItems: IDesignItem[]): {
|
|
5
|
+
outerRect: DOMRect;
|
|
6
|
+
positionsH: [number, DOMRect][];
|
|
7
|
+
positionsMiddleH: [number, DOMRect][];
|
|
8
|
+
positionsV: [number, DOMRect][];
|
|
9
|
+
positionsMiddleV: [number, DOMRect][];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DomHelper } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
export class SnaplinesProviderService {
|
|
3
|
+
provideSnaplines(containerItem, ignoredItems) {
|
|
4
|
+
{
|
|
5
|
+
const ignMap = new Map(ignoredItems.map(i => [i.element, i]));
|
|
6
|
+
const outerRect = containerItem.element.getBoundingClientRect();
|
|
7
|
+
const positionsH = [];
|
|
8
|
+
const positionsMiddleH = [];
|
|
9
|
+
const positionsV = [];
|
|
10
|
+
const positionsMiddleV = [];
|
|
11
|
+
let ignoreElements = ignoredItems.map(x => x.element);
|
|
12
|
+
for (let n of DomHelper.getAllChildNodes(containerItem.element, false, ignoreElements)) {
|
|
13
|
+
if (!ignMap.has(n)) {
|
|
14
|
+
let p = n.getBoundingClientRect();
|
|
15
|
+
let pLeft = p.x - outerRect.x;
|
|
16
|
+
let pMidH = p.x - outerRect.x + p.width / 2;
|
|
17
|
+
let pRight = p.x - outerRect.x + p.width;
|
|
18
|
+
positionsH.push([pLeft, p]);
|
|
19
|
+
positionsMiddleH.push([pMidH, p]);
|
|
20
|
+
positionsH.push([pRight, p]);
|
|
21
|
+
let pTop = p.y - outerRect.y;
|
|
22
|
+
let pMidV = p.y - outerRect.y + p.height / 2;
|
|
23
|
+
let pBottom = p.y - outerRect.y + p.height;
|
|
24
|
+
positionsV.push([pTop, p]);
|
|
25
|
+
positionsMiddleV.push([pMidV, p]);
|
|
26
|
+
positionsV.push([pBottom, p]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
positionsH.sort((a, b) => a[0] - b[0]);
|
|
30
|
+
positionsMiddleH.sort((a, b) => a[0] - b[0]);
|
|
31
|
+
positionsV.sort((a, b) => a[0] - b[0]);
|
|
32
|
+
positionsMiddleV.sort((a, b) => a[0] - b[0]);
|
|
33
|
+
return { outerRect, positionsH, positionsMiddleH, positionsV, positionsMiddleV };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -13,6 +13,9 @@ export class InsertAction {
|
|
|
13
13
|
}
|
|
14
14
|
do() {
|
|
15
15
|
this.designItem.insertChild(this.newItem, this.index);
|
|
16
|
+
const prepService = this.designItem.serviceContainer.prepareElementsForDesignerService;
|
|
17
|
+
if (prepService)
|
|
18
|
+
requestAnimationFrame(() => prepService.prepareElementsForDesigner(this.newItem));
|
|
16
19
|
}
|
|
17
20
|
mergeWith(other) {
|
|
18
21
|
return false;
|
|
@@ -20,6 +20,7 @@ export interface IDesignerView extends IPlacementView, IUiCommandHandler {
|
|
|
20
20
|
readonly shadowRoot: ShadowRoot;
|
|
21
21
|
readonly alignOnGrid: boolean;
|
|
22
22
|
readonly alignOnSnap: boolean;
|
|
23
|
+
eatEvents: Element;
|
|
23
24
|
initialize(serviceContainer: ServiceContainer): any;
|
|
24
25
|
getDesignerMousepoint(event: MouseEvent, target: Element, startPoint?: IDesignerMousePoint): IDesignerMousePoint;
|
|
25
26
|
getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): any;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DomHelper } from '@node-projects/base-custom-webcomponent';
|
|
2
1
|
import { OverlayLayer } from "./extensions/OverlayLayer.js";
|
|
3
2
|
const overlayLayer = OverlayLayer.Normal;
|
|
4
3
|
export class Snaplines {
|
|
@@ -24,30 +23,12 @@ export class Snaplines {
|
|
|
24
23
|
}
|
|
25
24
|
calculateSnaplines(ignoredItems) {
|
|
26
25
|
this.clearSnaplines();
|
|
27
|
-
|
|
28
|
-
this._outerRect =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let pLeft = p.x - this._outerRect.x;
|
|
34
|
-
let pMidH = p.x - this._outerRect.x + p.width / 2;
|
|
35
|
-
let pRight = p.x - this._outerRect.x + p.width;
|
|
36
|
-
this._positionsH.push([pLeft, p]);
|
|
37
|
-
this._positionsMiddleH.push([pMidH, p]);
|
|
38
|
-
this._positionsH.push([pRight, p]);
|
|
39
|
-
let pTop = p.y - this._outerRect.y;
|
|
40
|
-
let pMidV = p.y - this._outerRect.y + p.height / 2;
|
|
41
|
-
let pBottom = p.y - this._outerRect.y + p.height;
|
|
42
|
-
this._positionsV.push([pTop, p]);
|
|
43
|
-
this._positionsMiddleV.push([pMidV, p]);
|
|
44
|
-
this._positionsV.push([pBottom, p]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
this._positionsH.sort((a, b) => a[0] - b[0]);
|
|
48
|
-
this._positionsMiddleH.sort((a, b) => a[0] - b[0]);
|
|
49
|
-
this._positionsV.sort((a, b) => a[0] - b[0]);
|
|
50
|
-
this._positionsMiddleV.sort((a, b) => a[0] - b[0]);
|
|
26
|
+
const providedSnaplines = this._containerItem.serviceContainer.snaplinesProviderService.provideSnaplines(this._containerItem, ignoredItems);
|
|
27
|
+
this._outerRect = providedSnaplines.outerRect;
|
|
28
|
+
this._positionsH = providedSnaplines.positionsH;
|
|
29
|
+
this._positionsMiddleH = providedSnaplines.positionsMiddleH;
|
|
30
|
+
this._positionsV = providedSnaplines.positionsV;
|
|
31
|
+
this._positionsMiddleV = providedSnaplines.positionsMiddleV;
|
|
51
32
|
}
|
|
52
33
|
//return the snapped position
|
|
53
34
|
snapToPosition(position, size, moveDirection) {
|
|
@@ -25,6 +25,7 @@ export declare class DesignerView extends BaseCustomWebComponentLazyAppend imple
|
|
|
25
25
|
snapLines: Snaplines;
|
|
26
26
|
overlayLayer: OverlayLayerView;
|
|
27
27
|
rootDesignItem: IDesignItem;
|
|
28
|
+
eatEvents: Element;
|
|
28
29
|
private _zoomFactor;
|
|
29
30
|
private _canvas;
|
|
30
31
|
private _canvasContainer;
|
|
@@ -39,6 +40,7 @@ export declare class DesignerView extends BaseCustomWebComponentLazyAppend imple
|
|
|
39
40
|
static readonly style: CSSStyleSheet;
|
|
40
41
|
static readonly template: HTMLTemplateElement;
|
|
41
42
|
extensionManager: IExtensionManager;
|
|
43
|
+
private _onDblClickBound;
|
|
42
44
|
constructor();
|
|
43
45
|
get designerWidth(): string;
|
|
44
46
|
set designerWidth(value: string);
|
|
@@ -60,14 +62,14 @@ export declare class DesignerView extends BaseCustomWebComponentLazyAppend imple
|
|
|
60
62
|
parseHTML(html: string): Promise<void>;
|
|
61
63
|
setDesignItems(designItems: IDesignItem[]): void;
|
|
62
64
|
private _addDesignItems;
|
|
63
|
-
private _removeDraggableOnImages;
|
|
64
|
-
private _removeDraggableOnImagesInner;
|
|
65
65
|
private _onDragEnter;
|
|
66
|
+
private _onDragLeave;
|
|
66
67
|
private _onDragOver;
|
|
67
68
|
private _onDrop;
|
|
68
69
|
private _onWheel;
|
|
69
70
|
private _onContextMenu;
|
|
70
71
|
showDesignItemContextMenu(designItem: IDesignItem, event: MouseEvent): ContextMenuHelper;
|
|
72
|
+
private _onDblClick;
|
|
71
73
|
private onKeyUp;
|
|
72
74
|
private onKeyDown;
|
|
73
75
|
getDesignerMousepoint(event: MouseEvent, target: Element, startPoint?: IDesignerMousePoint): IDesignerMousePoint;
|