canvas-editor-engine 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/web-component.d.ts +19 -3
- package/dist/web-component.js +54 -17
- package/package.json +1 -1
package/dist/web-component.d.ts
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
import { TComponent } from "./types/general";
|
2
2
|
export declare class WebComponentWrapper {
|
3
|
-
|
3
|
+
baseElement: HTMLDivElement;
|
4
|
+
editorWrapElement: HTMLDivElement;
|
5
|
+
stylesWrapElement: HTMLDivElement;
|
6
|
+
toolsWrapElement: HTMLDivElement;
|
4
7
|
constructor();
|
5
|
-
|
6
|
-
|
8
|
+
get base(): {
|
9
|
+
add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
|
10
|
+
};
|
11
|
+
get editorWrap(): {
|
12
|
+
add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
|
13
|
+
};
|
14
|
+
get stylesWrap(): {
|
15
|
+
add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
|
16
|
+
};
|
17
|
+
get toolsWrap(): {
|
18
|
+
add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
|
19
|
+
};
|
20
|
+
private _methods;
|
21
|
+
private _add;
|
22
|
+
private _baseStyle;
|
7
23
|
}
|
8
24
|
export default class WebComponent extends HTMLElement {
|
9
25
|
constructor();
|
package/dist/web-component.js
CHANGED
@@ -7,28 +7,65 @@ const pipette_component_1 = require("./components/pipette.component");
|
|
7
7
|
const slot_component_1 = require("./components/slot.component");
|
8
8
|
class WebComponentWrapper {
|
9
9
|
constructor() {
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
const base = document.createElement('div');
|
11
|
+
base.className = 'wc-editor';
|
12
|
+
base.style.position = 'relative';
|
13
|
+
base.style.display = 'flex';
|
14
|
+
const stylesWrap = document.createElement('div');
|
15
|
+
stylesWrap.className = 'styles-wrap';
|
16
|
+
const editorWrap = document.createElement('div');
|
17
|
+
editorWrap.className = 'editor-wrap';
|
18
|
+
editorWrap.style.position = 'relative';
|
19
|
+
editorWrap.style.display = 'flex';
|
20
|
+
const toolsWrap = document.createElement('div');
|
21
|
+
editorWrap.className = 'tools-wrap';
|
22
|
+
editorWrap.style.position = 'relative';
|
23
|
+
editorWrap.style.display = 'flex';
|
24
|
+
base.appendChild(stylesWrap);
|
25
|
+
base.appendChild(editorWrap);
|
26
|
+
base.appendChild(toolsWrap);
|
27
|
+
this.baseElement = base;
|
28
|
+
this.stylesWrapElement = stylesWrap;
|
29
|
+
this.editorWrapElement = editorWrap;
|
30
|
+
this.toolsWrapElement = toolsWrap;
|
31
|
+
this._baseStyle();
|
32
|
+
}
|
33
|
+
get base() {
|
34
|
+
return this._methods(this.baseElement);
|
35
|
+
}
|
36
|
+
;
|
37
|
+
get editorWrap() {
|
38
|
+
return this._methods(this.editorWrapElement);
|
39
|
+
}
|
40
|
+
;
|
41
|
+
get stylesWrap() {
|
42
|
+
return this._methods(this.stylesWrapElement);
|
43
|
+
}
|
44
|
+
;
|
45
|
+
get toolsWrap() {
|
46
|
+
return this._methods(this.toolsWrapElement);
|
47
|
+
}
|
48
|
+
;
|
49
|
+
_methods(elementWrapper) {
|
50
|
+
return {
|
51
|
+
add: (component, style) => this._add(elementWrapper, component, style),
|
52
|
+
};
|
53
|
+
}
|
54
|
+
_add(elementWrapper, component, style) {
|
55
|
+
const componentElement = elementWrapper.appendChild(component);
|
19
56
|
if (!!style) {
|
20
|
-
this.
|
57
|
+
this.stylesWrapElement.appendChild(style);
|
21
58
|
}
|
22
59
|
return componentElement;
|
23
60
|
}
|
24
|
-
|
61
|
+
_baseStyle() {
|
25
62
|
const style = document.createElement('style');
|
26
63
|
style.innerHTML = `
|
27
64
|
* {
|
28
65
|
user-select: none;
|
29
66
|
}
|
30
67
|
`;
|
31
|
-
this.
|
68
|
+
this.stylesWrapElement.appendChild(style);
|
32
69
|
}
|
33
70
|
}
|
34
71
|
exports.WebComponentWrapper = WebComponentWrapper;
|
@@ -38,14 +75,14 @@ class WebComponent extends HTMLElement {
|
|
38
75
|
const shadowRoot = this.attachShadow({ mode: "open" });
|
39
76
|
const webComponentWrapper = new WebComponentWrapper();
|
40
77
|
const { canvasTemplate, canvasStyle } = canvas_component_1.default.getComponent();
|
41
|
-
const canvasElement = webComponentWrapper.add(canvasTemplate, canvasStyle);
|
78
|
+
const canvasElement = webComponentWrapper.editorWrap.add(canvasTemplate, canvasStyle);
|
42
79
|
const { pipetteTemplate, pipetteStyle } = pipette_component_1.default.getComponent();
|
43
|
-
webComponentWrapper.add(pipetteTemplate, pipetteStyle);
|
80
|
+
webComponentWrapper.editorWrap.add(pipetteTemplate, pipetteStyle);
|
44
81
|
const { slotTemplate, slotStyle } = slot_component_1.default.getComponent('tools');
|
45
|
-
webComponentWrapper.add(slotTemplate, slotStyle);
|
82
|
+
webComponentWrapper.toolsWrap.add(slotTemplate, slotStyle);
|
46
83
|
const { excretionsTemplate, excretionsStyle } = excretions_component_1.default.getComponent();
|
47
|
-
webComponentWrapper.add(excretionsTemplate, excretionsStyle);
|
48
|
-
shadowRoot.appendChild(webComponentWrapper.
|
84
|
+
webComponentWrapper.editorWrap.add(excretionsTemplate, excretionsStyle);
|
85
|
+
shadowRoot.appendChild(webComponentWrapper.baseElement);
|
49
86
|
canvas_component_1.default.simulateSubscriptions();
|
50
87
|
this.addEventListener('initial', () => {
|
51
88
|
this.dispatchEvent(new CustomEvent('get-editor-element', {
|