dbm 1.0.6 → 1.1.1
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/flow/controllers/index.js +1 -0
- package/flow/controllers/select/SingleSelection.js +65 -0
- package/flow/controllers/select/index.js +1 -0
- package/flow/index.js +1 -0
- package/flow/updatefunctions/basic/Length.js +20 -0
- package/flow/updatefunctions/basic/PropertyOf.js +21 -0
- package/flow/updatefunctions/basic/index.js +17 -0
- package/flow/updatefunctions/dom/ElementPosition.js +1 -1
- package/flow/updatefunctions/dom/HorizontalFlip.js +5 -6
- package/flow/updatefunctions/dom/StyleObject.js +1 -1
- package/flow/updatefunctions/logic/Condition.js +12 -1
- package/flow/updatefunctions/logic/Invert.js +18 -0
- package/flow/updatefunctions/logic/Switch.js +6 -0
- package/flow/updatefunctions/logic/index.js +8 -0
- package/graphapi/webclient/GraphApi.js +4 -0
- package/graphapi/webclient/WebSocketConnection.js +23 -8
- package/graphapi/webclient/decode/index.js +16 -0
- package/package.json +1 -1
- package/react/BaseObject.js +18 -7
- package/react/ChildFunctions.js +27 -0
- package/react/admin/EditPage.js +41 -1
- package/react/admin/{Editor.js → editor/Editor.js} +27 -11
- package/react/admin/{EditorBlock.js → editor/EditorBlock.js} +15 -4
- package/react/admin/editor/EditorBlockFields.js +23 -0
- package/react/admin/editor/EditorBlockName.js +28 -0
- package/react/admin/editor/fields/CheckboxField.js +54 -0
- package/react/admin/editor/fields/ImageField.js +137 -0
- package/react/admin/editor/fields/RichTextField.js +75 -0
- package/react/admin/editor/fields/TextField.js +53 -0
- package/react/admin/editor/fields/index.js +4 -0
- package/react/admin/editor/index.js +6 -0
- package/react/admin/index.js +3 -4
- package/react/animation/AnimatedElement.js +22 -0
- package/react/animation/AnimationController.js +53 -0
- package/react/animation/index.js +22 -0
- package/react/area/HasData.js +5 -0
- package/react/area/InsertElement.js +1 -1
- package/react/area/List.js +46 -0
- package/react/area/OpenCloseExpandableArea.js +14 -5
- package/react/area/ResponsiveLayout.js +48 -0
- package/react/area/index.js +12 -1
- package/react/blocks/Image.js +17 -0
- package/react/blocks/index.js +69 -55
- package/react/cookies/CookieSettings.js +1 -1
- package/react/form/Checkbox.js +2 -1
- package/react/form/FileDropArea.js +92 -0
- package/react/form/FormField.js +1 -0
- package/react/form/LabelledArea.js +22 -0
- package/react/form/index.js +3 -1
- package/react/image/CoverScaledImage.js +32 -0
- package/react/image/Image.js +37 -0
- package/react/image/LocalImage.js +42 -0
- package/react/image/WidthScaledImage.js +30 -0
- package/react/image/index.js +4 -0
- package/react/index.js +6 -1
- package/react/interaction/CommandButton.js +97 -0
- package/react/interaction/index.js +3 -0
- package/react/login/LoginForm.js +1 -1
- package/react/source/index.js +15 -1
- package/react/text/Link.js +18 -0
- package/react/text/index.js +1 -0
- package/site/SiteDataLoader.js +1 -1
- package/tracking/Controller.js +1 -1
- package/utils/ArrayFunctions.js +128 -2
- package/utils/UrlFunctions.js +77 -0
- package/utils/index.js +2 -1
- package/react/admin/EditorBlockName.js +0 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import Dbm from "
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
3
|
|
|
4
4
|
import EditorBlock from "./EditorBlock.js";
|
|
5
5
|
|
|
@@ -7,6 +7,9 @@ export default class Editor extends Dbm.react.BaseObject {
|
|
|
7
7
|
_construct() {
|
|
8
8
|
super._construct();
|
|
9
9
|
|
|
10
|
+
let editorId = "editor/instance" + Dbm.getInstance().getNextId();
|
|
11
|
+
this.item.register(editorId);
|
|
12
|
+
|
|
10
13
|
let all = Dbm.flow.updatefunctions.logic.allAtValue(1);
|
|
11
14
|
|
|
12
15
|
all.addCheck(Dbm.loading.loadScript("https://cdn.jsdelivr.net/npm/@editorjs/image@latest").item.properties.status);
|
|
@@ -51,32 +54,38 @@ export default class Editor extends Dbm.react.BaseObject {
|
|
|
51
54
|
|
|
52
55
|
if(aPreSign.status === 1) {
|
|
53
56
|
let url = aPreSign.data.url;
|
|
54
|
-
console.log(url);
|
|
57
|
+
console.log(url, aPreSign.data);
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
let headers = {
|
|
57
60
|
'Content-Type': aFile.type,
|
|
58
|
-
'
|
|
59
|
-
}
|
|
61
|
+
'Cache-Control': 'no-cache',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let additionalHeaders = aPreSign.data.additionalHeaders;
|
|
65
|
+
for(let objectName in additionalHeaders) {
|
|
66
|
+
headers[objectName] = additionalHeaders[objectName];
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
fetch(url, {
|
|
61
70
|
method: 'PUT',
|
|
62
|
-
headers:
|
|
71
|
+
headers: new Headers(headers),
|
|
63
72
|
body: aFile
|
|
64
73
|
}).then(() => {
|
|
65
|
-
resolve({success: true, file: {url: aPreSign.data.publicUrl}});
|
|
74
|
+
resolve({success: true, file: {url: aPreSign.data.publicUrl, resizeUrl: aPreSign.data.publicResizeUrl, identifier: aPreSign.data.identifier}});
|
|
66
75
|
})
|
|
67
76
|
|
|
68
|
-
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
_callback_saveDataUpdated(aData) {
|
|
73
|
-
console.log("_callback_saveDataUpdated");
|
|
74
|
-
console.log(aData);
|
|
81
|
+
//console.log("_callback_saveDataUpdated");
|
|
82
|
+
//console.log(aData);
|
|
75
83
|
|
|
76
84
|
this.getDynamicProp("value").getMostUpstreamProperty().setValue(aData);
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
_callback_editorChange(aApi, aEvent) {
|
|
88
|
+
console.log("_callback_editorChange");
|
|
80
89
|
this.item.editor.save().then(this._callback_saveDataUpdatedBound);
|
|
81
90
|
}
|
|
82
91
|
|
|
@@ -119,7 +128,14 @@ export default class Editor extends Dbm.react.BaseObject {
|
|
|
119
128
|
|
|
120
129
|
|
|
121
130
|
let editorConfigItem = Dbm.getInstance().repository.getItem("editorjs");
|
|
122
|
-
let toolsFromConfig = editorConfigItem.tools;
|
|
131
|
+
let toolsFromConfig = {...editorConfigItem.tools};
|
|
132
|
+
|
|
133
|
+
let editorId = this.item.id;
|
|
134
|
+
for(let objectName in toolsFromConfig) {
|
|
135
|
+
let currentTool = {...toolsFromConfig[objectName]};
|
|
136
|
+
currentTool["config"] = {...currentTool["config"], "editorId": editorId};
|
|
137
|
+
toolsFromConfig[objectName] = currentTool;
|
|
138
|
+
}
|
|
123
139
|
|
|
124
140
|
tools = {...tools, ...toolsFromConfig};
|
|
125
141
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Dbm from "
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
2
|
|
|
3
3
|
export default class EditorBlock extends Dbm.core.BaseObject {
|
|
4
4
|
|
|
@@ -6,11 +6,18 @@ export default class EditorBlock extends Dbm.core.BaseObject {
|
|
|
6
6
|
super();
|
|
7
7
|
|
|
8
8
|
this._settings = aSettings;
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
this.item.setValue("data", aSettings.data ? aSettings.data : {});
|
|
11
11
|
this.item.setValue("name", aSettings.config ? aSettings.config.name : "Unnamed block");
|
|
12
|
+
this.item.setValue("editor", aSettings.config ? Dbm.getInstance().repository.getItem(aSettings.config.editorId) : null);
|
|
12
13
|
this.item.setValue("module", Dbm.getInstance().repository.getItem("moduleCreators/blocks/editor/" + aSettings.config.module));
|
|
14
|
+
this.item.setValue("editorBlock", this);
|
|
15
|
+
|
|
16
|
+
}
|
|
13
17
|
|
|
18
|
+
dataUpdated() {
|
|
19
|
+
//console.log("dataUpdated")
|
|
20
|
+
this._settings.block.dispatchChange();
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
render(){
|
|
@@ -35,12 +42,16 @@ export default class EditorBlock extends Dbm.core.BaseObject {
|
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
save(aHolderElement){
|
|
38
|
-
console.log("save");
|
|
39
|
-
console.log(aHolderElement);
|
|
45
|
+
//console.log("save");
|
|
46
|
+
//console.log(aHolderElement);
|
|
40
47
|
|
|
41
48
|
return this.item.data;
|
|
42
49
|
}
|
|
43
50
|
|
|
51
|
+
static get sanitize() {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
|
|
44
55
|
static get toolbox() {
|
|
45
56
|
|
|
46
57
|
//'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" id="Module--Streamline-Streamline-3.0" height="16" width="16"><desc>Module Streamline Icon: https://streamlinehq.com</desc><g><path d="M14.21875 2.65625a0.625 0.625 0 0 1 0.46875 0.625v8.4375a0.625 0.625 0 0 1 -0.42500000000000004 0.59375l-6.55625 2.34375a0.625 0.625 0 0 1 -0.41250000000000003 0L0.725 12.318750000000001a0.625 0.625 0 0 1 -0.41250000000000003 -0.5874999999999999V3.2624999999999997a0.625 0.625 0 0 1 0.46875 -0.625L7.34375 0.33125000000000004a0.6625000000000001 0.6625000000000001 0 0 1 0.3125 0Z" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"></path><path d="m7.5 5.29375 0 9.393749999999999" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"></path><path d="M14.51875 2.8375 7.5 5.29375 0.48125 2.8375" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"></path></g></svg>'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditorBlockFields extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let textSource = new Dbm.react.source.ContextVariableSource();
|
|
12
|
+
textSource.item.path = "moduleData.editorData.name";
|
|
13
|
+
|
|
14
|
+
return React.createElement(Dbm.react.admin.editor.EditorBlockName, {},
|
|
15
|
+
React.createElement(Dbm.react.form.LabelledArea, {label: "fieldName", for: "test"},
|
|
16
|
+
React.createElement(Dbm.react.admin.editor.fields.TextField, {name: "fieldName", id: "test"})
|
|
17
|
+
),
|
|
18
|
+
React.createElement(Dbm.react.admin.editor.fields.RichTextField, {name: "fieldName"}),
|
|
19
|
+
React.createElement(Dbm.react.admin.editor.fields.ImageField, {name: "image"})
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditorBlockName extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let childrenAndSpacing = null;
|
|
12
|
+
let children = this.getPropValue("children");
|
|
13
|
+
if(children) {
|
|
14
|
+
childrenAndSpacing = React.createElement(React.Fragment, {},
|
|
15
|
+
React.createElement("div", {"className": "spacing standard"}),
|
|
16
|
+
children
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return React.createElement("div", {"className": "editor-block-box editor-block-box-padding"},
|
|
21
|
+
React.createElement("div", {"className": "text-align-center"},
|
|
22
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("moduleData.editorData.name"))
|
|
23
|
+
),
|
|
24
|
+
childrenAndSpacing
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class CheckboxField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._valueChangedBound = this._valueChanged.bind(this);
|
|
9
|
+
this._objectChangedBound = this._objectChanged.bind(this);
|
|
10
|
+
|
|
11
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("value", this._getObjectData()), Dbm.commands.callFunction(this._valueChangedBound));
|
|
12
|
+
|
|
13
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
14
|
+
Dbm.flow.addUpdateCommand(editorData.properties.data, Dbm.commands.callFunction(this._objectChangedBound));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_getObjectData() {
|
|
18
|
+
let fieldName = this.getPropValue("name");
|
|
19
|
+
|
|
20
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
21
|
+
|
|
22
|
+
let returnData = editorData.data[fieldName];
|
|
23
|
+
if(!returnData) {
|
|
24
|
+
returnData = false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return returnData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
_valueChanged() {
|
|
32
|
+
//console.log("_valueChanged");
|
|
33
|
+
|
|
34
|
+
let fieldName = this.getPropValue("name");
|
|
35
|
+
let newValue = this.item.value;
|
|
36
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
37
|
+
|
|
38
|
+
let newData = {...editorData.data};
|
|
39
|
+
newData[fieldName] = newValue;
|
|
40
|
+
|
|
41
|
+
editorData.data = newData;
|
|
42
|
+
this.context.moduleData.editorData.editorBlock.dataUpdated();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_objectChanged() {
|
|
46
|
+
//console.log("_objectChanged");
|
|
47
|
+
|
|
48
|
+
this.item.value = this._getObjectData();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_renderMainElement() {
|
|
52
|
+
return this._createMainElement(Dbm.react.form.Checkbox, {checked: this.item.properties.value});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class ImageField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._valueChangedBound = this._valueChanged.bind(this);
|
|
9
|
+
this._objectChangedBound = this._objectChanged.bind(this);
|
|
10
|
+
this._callback_fileChangedBound = this._callback_fileChanged.bind(this);
|
|
11
|
+
|
|
12
|
+
let fieldName = this.getPropValue("name");
|
|
13
|
+
|
|
14
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
15
|
+
|
|
16
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("value", this._getObjectData()), Dbm.commands.callFunction(this._valueChangedBound));
|
|
17
|
+
|
|
18
|
+
Dbm.flow.addUpdateCommand(editorData.properties.data, Dbm.commands.callFunction(this._objectChangedBound));
|
|
19
|
+
|
|
20
|
+
let imageElement = React.createElement("div", {className: "flex-row small-item-spacing"},
|
|
21
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
22
|
+
React.createElement(Dbm.react.image.WidthScaledImage, {"image": Dbm.react.source.contextVariable("moduleData.editorData.data." + fieldName), targetWidth: 120, className: "editor-preview background-contain"}),
|
|
23
|
+
),
|
|
24
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
25
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("moduleData.editorData.data." + fieldName + ".url"))
|
|
26
|
+
),
|
|
27
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
28
|
+
React.createElement("div", {onClick: () => {this.removeImage()}}, "Remove")
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
let uploadElement = React.createElement("input", {"type": "file", onChange: this._callback_fileChangedBound, className: "full-width"});
|
|
33
|
+
|
|
34
|
+
let elementSwitch =Dbm.flow.updatefunctions.logic.switchValue(this.item.properties.value).setDefaultValue(imageElement).addCase(null, uploadElement);
|
|
35
|
+
|
|
36
|
+
this.item.requireProperty("element", null).connectInput(elementSwitch.output.properties.value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_getObjectData() {
|
|
40
|
+
let fieldName = this.getPropValue("name");
|
|
41
|
+
|
|
42
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
43
|
+
|
|
44
|
+
let returnData = editorData.data[fieldName];
|
|
45
|
+
if(!returnData) {
|
|
46
|
+
returnData = null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return returnData;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_valueChanged() {
|
|
53
|
+
//console.log("_valueChanged");
|
|
54
|
+
|
|
55
|
+
let fieldName = this.getPropValue("name");
|
|
56
|
+
let newValue = this.item.value;
|
|
57
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
58
|
+
|
|
59
|
+
let newData = {...editorData.data};
|
|
60
|
+
newData[fieldName] = newValue;
|
|
61
|
+
|
|
62
|
+
editorData.data = newData;
|
|
63
|
+
this.context.moduleData.editorData.editorBlock.dataUpdated();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_objectChanged() {
|
|
67
|
+
//console.log("_objectChanged");
|
|
68
|
+
|
|
69
|
+
let fieldName = this.getPropValue("name");
|
|
70
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
71
|
+
|
|
72
|
+
this.item.value = this._getObjectData();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_callback_fileChanged(aEvent) {
|
|
76
|
+
console.log("_callback_fileChanged");
|
|
77
|
+
console.log(aEvent, aEvent.target.files);
|
|
78
|
+
|
|
79
|
+
let files = aEvent.target.files;
|
|
80
|
+
if(files.length > 0) {
|
|
81
|
+
this.uploadImage(files[0]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
removeImage() {
|
|
86
|
+
this.item.value = null;
|
|
87
|
+
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
uploadImage(aFile) {
|
|
92
|
+
|
|
93
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
94
|
+
|
|
95
|
+
let preSign = graphApi.requestData("fileUpload", {"fileName": aFile.name, "mimeType": aFile.type});
|
|
96
|
+
|
|
97
|
+
Dbm.flow.addDirectUpdateCommand(preSign.getProperty("status"), Dbm.commands.callFunction(this._statusChanged.bind(this), [preSign, aFile]));
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_statusChanged(aPreSign, aFile) {
|
|
102
|
+
console.log("_statusChanged");
|
|
103
|
+
console.log(aPreSign, aFile);
|
|
104
|
+
|
|
105
|
+
if(aPreSign.status === 1) {
|
|
106
|
+
let url = aPreSign.data.url;
|
|
107
|
+
console.log(url, aPreSign.data);
|
|
108
|
+
|
|
109
|
+
let headers = {
|
|
110
|
+
'Content-Type': aFile.type,
|
|
111
|
+
'Cache-Control': 'no-cache',
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
let additionalHeaders = aPreSign.data.additionalHeaders;
|
|
115
|
+
for(let objectName in additionalHeaders) {
|
|
116
|
+
headers[objectName] = additionalHeaders[objectName];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fetch(url, {
|
|
120
|
+
method: 'PUT',
|
|
121
|
+
headers: new Headers(headers),
|
|
122
|
+
body: aFile
|
|
123
|
+
}).then(() => {
|
|
124
|
+
this.item.value = {url: aPreSign.data.publicUrl, resizeUrl: aPreSign.data.publicResizeUrl, identifier: aPreSign.data.identifier};
|
|
125
|
+
console.log("Uploaded", this.item.value);
|
|
126
|
+
//METODO: send update to editor
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_renderMainElement() {
|
|
133
|
+
return this._createMainElement("div", {},
|
|
134
|
+
React.createElement(Dbm.react.area.InsertElement, {element: this.item.properties.element})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class RichTextField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._valueChangedBound = this._valueChanged.bind(this);
|
|
9
|
+
this._objectChangedBound = this._objectChanged.bind(this);
|
|
10
|
+
this._elementChangedBound = this._elementChanged.bind(this);
|
|
11
|
+
this._callback_inputBound = this._callback_input.bind(this);
|
|
12
|
+
|
|
13
|
+
this.createRef("contentElement");
|
|
14
|
+
Dbm.flow.addUpdateCommand(this.item.properties.contentElement, Dbm.commands.callFunction(this._elementChangedBound));
|
|
15
|
+
|
|
16
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("value", this._getObjectData()), Dbm.commands.callFunction(this._valueChangedBound));
|
|
17
|
+
|
|
18
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
19
|
+
Dbm.flow.addUpdateCommand(editorData.properties.data, Dbm.commands.callFunction(this._objectChangedBound));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_getObjectData() {
|
|
23
|
+
let fieldName = this.getPropValue("name");
|
|
24
|
+
|
|
25
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
26
|
+
|
|
27
|
+
let returnData = editorData.data[fieldName];
|
|
28
|
+
if(!returnData) {
|
|
29
|
+
returnData = "";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return returnData;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_valueChanged() {
|
|
36
|
+
//console.log("_valueChanged");
|
|
37
|
+
|
|
38
|
+
let fieldName = this.getPropValue("name");
|
|
39
|
+
let newValue = this.item.value;
|
|
40
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
41
|
+
|
|
42
|
+
let newData = {...editorData.data};
|
|
43
|
+
newData[fieldName] = newValue;
|
|
44
|
+
|
|
45
|
+
editorData.data = newData;
|
|
46
|
+
|
|
47
|
+
if(this.item.contentElement && newValue !== this.item.contentElement.innerHTML) {
|
|
48
|
+
this.item.contentElement.innerHTML = newValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_objectChanged() {
|
|
53
|
+
//console.log("_objectChanged");
|
|
54
|
+
|
|
55
|
+
this.item.value = this._getObjectData();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_elementChanged() {
|
|
59
|
+
//console.log("_elementChanged");
|
|
60
|
+
|
|
61
|
+
this.item.contentElement.innerHTML = this.item.value;
|
|
62
|
+
this.item.contentElement.addEventListener("input", this._callback_inputBound, false);
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_callback_input(aEvent) {
|
|
67
|
+
//console.log("_callback_input");
|
|
68
|
+
|
|
69
|
+
this.item.value = "" + this.item.contentElement.innerHTML;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_renderMainElement() {
|
|
73
|
+
return this._createMainElement("div", {contentEditable: true, ref: this.createRef("contentElement"), className: "standard-field standard-field-padding"});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class TextField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._valueChangedBound = this._valueChanged.bind(this);
|
|
9
|
+
this._objectChangedBound = this._objectChanged.bind(this);
|
|
10
|
+
|
|
11
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("value", this._getObjectData()), Dbm.commands.callFunction(this._valueChangedBound));
|
|
12
|
+
|
|
13
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
14
|
+
Dbm.flow.addUpdateCommand(editorData.properties.data, Dbm.commands.callFunction(this._objectChangedBound));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_getObjectData() {
|
|
18
|
+
let fieldName = this.getPropValue("name");
|
|
19
|
+
|
|
20
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
21
|
+
|
|
22
|
+
let returnData = editorData.data[fieldName];
|
|
23
|
+
if(!returnData) {
|
|
24
|
+
returnData = "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return returnData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
_valueChanged() {
|
|
32
|
+
//console.log("_valueChanged");
|
|
33
|
+
|
|
34
|
+
let fieldName = this.getPropValue("name");
|
|
35
|
+
let newValue = this.item.value;
|
|
36
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
37
|
+
|
|
38
|
+
let newData = {...editorData.data};
|
|
39
|
+
newData[fieldName] = newValue;
|
|
40
|
+
|
|
41
|
+
editorData.data = newData;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_objectChanged() {
|
|
45
|
+
//console.log("_objectChanged");
|
|
46
|
+
|
|
47
|
+
this.item.value = this._getObjectData();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_renderMainElement() {
|
|
51
|
+
return this._createMainElement(Dbm.react.form.FormField, {value: this.item.properties.value, className: "standard-field standard-field-padding full-width"});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export {default as Editor} from "./Editor.js";
|
|
2
|
+
export {default as EditorBlock} from "./EditorBlock.js";
|
|
3
|
+
export {default as EditorBlockName} from "./EditorBlockName.js";
|
|
4
|
+
export {default as EditorBlockFields} from "./EditorBlockFields.js";
|
|
5
|
+
|
|
6
|
+
export * as fields from "./fields/index.js";
|
package/react/admin/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {default as Editor} from "./Editor.js";
|
|
2
|
-
export {default as EditorBlock} from "./EditorBlock.js";
|
|
3
|
-
export {default as EditorBlockName} from "./EditorBlockName.js";
|
|
4
1
|
export {default as CreatePage} from "./CreatePage.js";
|
|
5
|
-
export {default as EditPage} from "./EditPage.js";
|
|
2
|
+
export {default as EditPage} from "./EditPage.js";
|
|
3
|
+
|
|
4
|
+
export * as editor from "./editor/index.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class AnimatedElement extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let controller = this.getPropValue("controller");
|
|
9
|
+
|
|
10
|
+
controller.propertyInput("element", this.item.requireProperty("animationElement", null));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_renderMainElement() {
|
|
14
|
+
//console.log("AnimatedElement::_renderMainElement");
|
|
15
|
+
//console.log(this);
|
|
16
|
+
|
|
17
|
+
let controller = this.getPropValue("controller");
|
|
18
|
+
let children = this.getPropValue("children");
|
|
19
|
+
|
|
20
|
+
return this._createMainElement("div", {"ref": this.createRef("animationElement"), "style": controller.jsxStyle}, children);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class AnimationController extends Dbm.core.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let updateStyleCommand = Dbm.commands.callFunction(this._updateStyle.bind(this));
|
|
9
|
+
|
|
10
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("element", null), updateStyleCommand);
|
|
11
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("style", {}), updateStyleCommand);
|
|
12
|
+
|
|
13
|
+
//METODO: add conversion to jsx
|
|
14
|
+
|
|
15
|
+
this.item.requireProperty("jsxStyle", {});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_updateStyle() {
|
|
19
|
+
//console.log("_updateStyle");
|
|
20
|
+
let element = this.item.element;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if(element) {
|
|
25
|
+
|
|
26
|
+
let styleArray = [];
|
|
27
|
+
|
|
28
|
+
let styleObject = this.item.style;
|
|
29
|
+
for(let objectName in styleObject) {
|
|
30
|
+
styleArray.push(objectName + ": " + styleObject[objectName]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
element.style = styleArray.join("; ");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_convertStyleToJsx() {
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
insertElement(aChildren) {
|
|
44
|
+
|
|
45
|
+
let reactElement = this.item.reactElement;
|
|
46
|
+
if(!reactElement) {
|
|
47
|
+
reactElement = React.createElement(Dbm.react.animation.AnimatedElement, {controller: this.item}, aChildren);
|
|
48
|
+
this.item.setValue("reactElement", reactElement);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return reactElement;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export {default as AnimatedElement} from "./AnimatedElement.js";
|
|
4
|
+
export {default as AnimationController} from "./AnimationController.js";
|
|
5
|
+
|
|
6
|
+
export const freeStyleAnimation = function() {
|
|
7
|
+
let newAnimationController = new Dbm.react.animation.AnimationController();
|
|
8
|
+
|
|
9
|
+
let styleObject = new Dbm.flow.updatefunctions.dom.StyleObject();
|
|
10
|
+
newAnimationController.item.propertyInput("style", styleObject.output.properties.style);
|
|
11
|
+
newAnimationController.item.setValue("styleProperties", styleObject);
|
|
12
|
+
|
|
13
|
+
return newAnimationController;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const connectedAnimation = function(aStyleProperty) {
|
|
17
|
+
let newAnimationController = new Dbm.react.animation.AnimationController();
|
|
18
|
+
|
|
19
|
+
newAnimationController.item.propertyInput("style", aStyleProperty);
|
|
20
|
+
|
|
21
|
+
return newAnimationController;
|
|
22
|
+
}
|
package/react/area/HasData.js
CHANGED
|
@@ -11,6 +11,11 @@ export default class HasData extends Dbm.react.BaseObject {
|
|
|
11
11
|
//console.log(this);
|
|
12
12
|
|
|
13
13
|
let data = this.getPropValue("check");
|
|
14
|
+
let checkType = this.getPropValue("checkType");
|
|
15
|
+
|
|
16
|
+
if(checkType === "invert/default") {
|
|
17
|
+
data = !data;
|
|
18
|
+
}
|
|
14
19
|
|
|
15
20
|
if(data) {
|
|
16
21
|
return React.createElement(React.Fragment, {}, this.getPropValue("children"));
|
|
@@ -10,7 +10,7 @@ export default class InsertElement extends Dbm.react.BaseObject {
|
|
|
10
10
|
//console.log("InsertElement::render");
|
|
11
11
|
//console.log(this);
|
|
12
12
|
|
|
13
|
-
let element = this.
|
|
13
|
+
let element = this.getPropValue("element");
|
|
14
14
|
|
|
15
15
|
if(!element) {
|
|
16
16
|
return React.createElement("div", {}, "No element set");
|