dbm 1.2.9 → 1.3.0

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/css/admin.css ADDED
@@ -0,0 +1,99 @@
1
+ .dbm-admin {
2
+ background-color: #f6f7f9;
3
+ }
4
+
5
+ .dbm-admin-box {
6
+ box-sizing: border-box;
7
+ border-radius: 15px;
8
+ background-color: #FFFFFF;
9
+ box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
10
+ }
11
+
12
+ .dbm-admin-box-padding {
13
+ padding: 20px;
14
+ }
15
+
16
+ .dbm-admin-hero {
17
+ background: rgb(41,56,97);
18
+ background: linear-gradient(117deg, #4b4795 0%, #608be1 100%);
19
+ }
20
+
21
+ .dbm-admin-hero .on-hero-text {
22
+ color: #FFFFFF;
23
+ }
24
+
25
+ .dbm-admin-hero-overlap {
26
+ position: relative;
27
+ top: -40px;
28
+ }
29
+
30
+ .page-title-form-field {
31
+ font-weight: 700;
32
+ font-size: 24px;
33
+ }
34
+
35
+ .dbm-admin-logo {
36
+ height: 24px;
37
+ width: auto;
38
+ }
39
+
40
+ .ce-block__content,
41
+ .ce-toolbar__content {
42
+ max-width: none;
43
+ }
44
+
45
+ .editor-block-box {
46
+ border: 1px solid #1A1A1A;
47
+ border-radius: 5px;
48
+ box-sizing: border-box;
49
+ }
50
+ .editor-block-box-padding {
51
+ padding: 20px;
52
+ }
53
+
54
+ .image.editor-preview {
55
+ width: 120px;
56
+ height: 120px;
57
+ }
58
+
59
+ .dbm-admin .save-all-position {
60
+ position: fixed;
61
+ bottom: 10px;
62
+ right: 10px;
63
+ }
64
+
65
+ .image-library-preview {
66
+ width: 120px;
67
+ height: 120px;
68
+ }
69
+
70
+ .image-library-margins {
71
+ margin-right: 5px;
72
+ margin-bottom: 5px;
73
+ }
74
+
75
+ .action-button {
76
+ border: 1px solid #ADADAD;
77
+ color: #ADADAD;
78
+ font-size: 10px;
79
+ border-radius: 9999px;
80
+ cursor: pointer;
81
+ }
82
+
83
+ .action-button:hover {
84
+ background-color: #ADADAD;
85
+ color: #FFFFFF;
86
+ }
87
+
88
+ .action-button-padding {
89
+ padding: 3px 10px;
90
+ }
91
+
92
+ .language-circle {
93
+ width: 28px;
94
+ height: 28px;
95
+ border-radius: 9999px;
96
+ background-color: #ADADAD;
97
+ font-size: 10px;
98
+ font-weight: bold;
99
+ }
package/css/all.css ADDED
@@ -0,0 +1,8 @@
1
+ @import './variables.css';
2
+ @import './utils.css';
3
+ @import './ratio.css';
4
+ @import './admin.css';
5
+ @import './rows.css';
6
+ @import './icons.css';
7
+ @import './tags.css';
8
+ @import './elements.css';
@@ -0,0 +1,27 @@
1
+ .popover-holder {
2
+ border: none;
3
+ padding: 0;
4
+ margin: 0;
5
+ overflow: visible;
6
+ background-color: transparent;
7
+ color: inherit;
8
+ }
9
+
10
+ .dropdown-menu-min-width {
11
+ min-width: 300px;
12
+ }
13
+
14
+ .dropdown-menu-max-height {
15
+ max-height: 400px;
16
+ overflow: auto;
17
+ }
18
+
19
+ .standard-dropdown {
20
+ border: 1px solid #000000;
21
+ background-color: #FFFFFF;
22
+ box-sizing: border-box;
23
+ }
24
+
25
+ .standard-dropdown-row-padding {
26
+ padding: 8px 15px;
27
+ }
package/css/icons.css ADDED
@@ -0,0 +1,35 @@
1
+ .standard-icon {
2
+ width: var(--standard-icon-size, 24px);
3
+ height: var(--standard-icon-size, 24px);
4
+ }
5
+
6
+ .text-row-icon {
7
+ width: var(--standard-icon-size, 24px);
8
+ height: var(--standard-icon-size, 24px);
9
+ }
10
+
11
+ .standard-icon-color {
12
+ filter: url("#standard-icon-color");
13
+ }
14
+
15
+ .action-icon-color {
16
+ filter: url("#action-icon-color");
17
+ }
18
+
19
+ .text-icon-color {
20
+ filter: url("#text-icon-color");
21
+ }
22
+
23
+ .white-icon-color {
24
+ filter: url("#white-icon-color");
25
+ }
26
+
27
+ .hover-item:hover .remove-action-icon-color,
28
+ .hover-icon.remove-action-icon-color:hover {
29
+ filter: url("#remove-action-icon-hover-color");
30
+ }
31
+
32
+ .drag-handle-icon {
33
+ width: 8px;
34
+ height: 12px;
35
+ }
package/css/ratio.css ADDED
@@ -0,0 +1,11 @@
1
+ .ratio-1-1 {
2
+ aspect-ratio: 1;
3
+ }
4
+
5
+ .ratio-4-3 {
6
+ aspect-ratio: 1.33;
7
+ }
8
+
9
+ .ratio-16-9 {
10
+ aspect-ratio: 1.78;
11
+ }
package/css/rows.css ADDED
@@ -0,0 +1,28 @@
1
+ .standard-alternating-rows > .standard-row:nth-of-type(2n+1),
2
+ .standard-alternating-rows > *:nth-of-type(2n+1) .standard-row {
3
+ background-color: var(--alternating-rows-background, #F8F8F8);
4
+ }
5
+
6
+ .standard-row-padding {
7
+ padding: var(--standard-row-vertical-padding, 4px) var(--standard-row-horizonal-padding, 10px);
8
+ }
9
+
10
+ .standard-row-padding-horizontal-padding {
11
+ padding-left: var(--standard-row-horizonal-padding, 10px);
12
+ padding-right: var(--standard-row-horizonal-padding, 10px);
13
+ }
14
+
15
+ .standard-row-padding-vertival-padding {
16
+ padding-top: var(--standard-row-vertical-padding, 4px);
17
+ padding-bottom: var(--standard-row-vertical-padding, 4px);
18
+ }
19
+
20
+ .hierarchy-indent {
21
+ margin-left: var(--hierarchy-indent-margin-left, 40px);
22
+ }
23
+
24
+ .append-drop-position {
25
+ height: 12px;
26
+ border: 1px dashed rgba(0, 0, 0, 0.1);
27
+ border-radius: 4px;
28
+ }
package/css/tags.css ADDED
@@ -0,0 +1,114 @@
1
+ .standard-tag {
2
+ border-radius: var(--standard-tag-border-radius, 9999px);
3
+
4
+ border-style: solid;
5
+ border-width: var(--standard-tag-border-width, 1px);
6
+ }
7
+
8
+ .standard-tag,
9
+ .complex-standard-tag {
10
+ font-size: var(--standard-tag-font-size, 14px);
11
+ line-height: 1;
12
+ }
13
+
14
+ .complex-standard-tag.info-tag .standard-tag-part,
15
+ .standard-tag.info-tag {
16
+ background-color: #f1f4f9;
17
+ border-color: #d2dcec;
18
+ }
19
+
20
+ .complex-standard-tag.add-tag .standard-tag-part,
21
+ .standard-tag.add-tag {
22
+ background-color: #FFFFFF;
23
+ border-color: #ADADAD;
24
+ border-style: dashed;
25
+ }
26
+
27
+ .standard-tag-part {
28
+ border-top-style: solid;
29
+ border-top-width: var(--standard-tag-border-width, 1px);
30
+ border-bottom-style: solid;
31
+ border-bottom-width: var(--standard-tag-border-width, 1px);
32
+ }
33
+
34
+ .standard-tag-part.start {
35
+ border-top-left-radius: var(--standard-tag-border-radius, 9999px);
36
+ border-bottom-left-radius: var(--standard-tag-border-radius, 9999px);
37
+
38
+ border-left-style: solid;
39
+ border-left-width: var(--standard-tag-border-width, 1px);
40
+ }
41
+
42
+ .standard-tag-part.end {
43
+ border-top-right-radius: var(--standard-tag-border-radius, 9999px);
44
+ border-bottom-right-radius: var(--standard-tag-border-radius, 9999px);
45
+
46
+ border-right-style: solid;
47
+ border-right-width: var(--standard-tag-border-width, 1px);
48
+ }
49
+
50
+ .standard-tag-padding {
51
+ padding: var(--standard-tag-vertical-padding, 5px) var(--standard-tag-horizontal-padding, 12px);
52
+ }
53
+
54
+ .standard-tag-start-padding {
55
+ padding-left: var(--standard-tag-horizontal-padding, 12px);
56
+ padding-top: var(--standard-tag-vertical-padding, 5px);
57
+ padding-bottom: var(--standard-tag-vertical-padding, 5px);
58
+ }
59
+
60
+ .standard-tag-end-padding {
61
+ padding-right: var(--standard-tag-horizontal-padding, 12px);
62
+ padding-top: var(--standard-tag-vertical-padding, 5px);
63
+ padding-bottom: var(--standard-tag-vertical-padding, 5px);
64
+ }
65
+
66
+ .standard-tag-horizontal-padding {
67
+ padding-left: var(--standard-tag-horizontal-padding, 12px);
68
+ padding-right: var(--standard-tag-horizontal-padding, 12px);
69
+ }
70
+
71
+ .standard-tag-vertical-padding {
72
+ padding-top: var(--standard-tag-vertical-padding, 5px);
73
+ padding-bottom: var(--standard-tag-vertical-padding, 5px);
74
+ }
75
+
76
+ .standard-tag-part-padding {
77
+ padding-left: var(--standard-tag-part-horizontal-padding, 6px);
78
+ padding-right: var(--standard-tag-part-horizontal-padding, 6px);
79
+ }
80
+
81
+ .standard-tag-part-padding-left {
82
+ padding-left: var(--standard-tag-part-horizontal-padding, 6px);
83
+ }
84
+
85
+ .standard-tag-part-padding-right {
86
+ padding-right: var(--standard-tag-part-horizontal-padding, 6px);
87
+ }
88
+
89
+ .standard-tag-part-separator {
90
+ width: 1px;
91
+ height: 100%;
92
+ background-color: rgba(255,255,255,0.6);
93
+ }
94
+
95
+ .standard-tag-icon {
96
+ width: 12px;
97
+ aspect-ratio: 1;
98
+ }
99
+
100
+ .standard-tag-list {
101
+
102
+ }
103
+
104
+ .standard-tag-list-expand {
105
+ margin-right: calc(-1 * var(--standard-tag-list-horizontal-margin, 10px));
106
+ margin-bottom: calc(-1 * var(--standard-tag-list-vertical-margin, 5px));
107
+ overflow: hidden;
108
+ }
109
+
110
+ .standard-tag-list .standard-tag-list-item{
111
+ float: left;
112
+ margin-right: var(--standard-tag-list-horizontal-margin, 10px);
113
+ margin-bottom: var(--standard-tag-list-vertical-margin, 5px);
114
+ }
package/css/utils.css ADDED
@@ -0,0 +1,256 @@
1
+ .text-align-center {
2
+ text-align: center;
3
+ }
4
+
5
+ .text-align-left {
6
+ text-align: left;
7
+ }
8
+
9
+ .text-align-right {
10
+ text-align: right;
11
+ }
12
+
13
+ .bold-text {
14
+ font-weight: bold;
15
+ }
16
+
17
+ .paragraph-no-margins-around > p:first-of-type {
18
+ margin-top: 0;
19
+ }
20
+
21
+ .paragraph-no-margins-around > p:last-of-type {
22
+ margin-bottom: 0;
23
+ }
24
+
25
+ .no-margins {
26
+ margin: 0;
27
+ }
28
+
29
+ .flex-row.vertically-center-items {
30
+ align-items: center;
31
+ }
32
+
33
+ .flex-row.vertically-baseline-items {
34
+ align-items: baseline;
35
+ }
36
+
37
+ .flex-row.vertically-end-items,
38
+ .flex-row.vertically-bottom-items {
39
+ align-items: flex-end;
40
+ }
41
+
42
+
43
+ .flex-no-resize {
44
+ flex-grow: 0;
45
+ flex-shrink: 0;
46
+ }
47
+
48
+ .flex-resize {
49
+ flex-grow: 1;
50
+ flex-shrink: 1;
51
+ }
52
+
53
+ .flex-wrap {
54
+ flex-wrap: wrap;
55
+ }
56
+
57
+ .full-size {
58
+ width: 100%;
59
+ height: 100%;
60
+ }
61
+
62
+ .full-width {
63
+ width: 100%;
64
+ }
65
+
66
+ .full-height {
67
+ height: 100%;
68
+ }
69
+
70
+ .absolute-container {
71
+ position: relative;
72
+ }
73
+ .position-relative {
74
+ position: relative;
75
+ }
76
+ .position-absolute {
77
+ position: absolute;
78
+ }
79
+ .absolute-overlay {
80
+ position: absolute;
81
+ left: 0;
82
+ top: 0;
83
+ right: 0;
84
+ bottom: 0;
85
+ }
86
+
87
+ .absolute-for-transform {
88
+ position: absolute;
89
+ left: 0;
90
+ top: 0;
91
+ }
92
+
93
+ .top-left {
94
+ left: 0;
95
+ top: 0;
96
+ }
97
+
98
+ .top-right {
99
+ right: 0;
100
+ top: 0;
101
+ }
102
+
103
+ .bottom-left {
104
+ left: 0;
105
+ bottom: 0;
106
+ }
107
+
108
+ .bottom-right {
109
+ right: 0;
110
+ bottom: 0;
111
+ }
112
+
113
+ .transform-y50-percent-overlap {
114
+ transform: translateY(-50%);
115
+ }
116
+
117
+ .centered-tip-text {
118
+ position: absolute;
119
+ left: 50%;
120
+ transform: translate(-50%, 2px);
121
+ font-size: 10px;
122
+ width: 200px;
123
+ text-align: center;
124
+ }
125
+
126
+ .overflow-hidden {
127
+ overflow: hidden;
128
+ }
129
+
130
+ .flex-row {
131
+ display: flex;
132
+ }
133
+
134
+ .flex-column {
135
+ display: flex;
136
+ flex-direction: column;
137
+ }
138
+
139
+ .flex-row.justify-center {
140
+ justify-content: center;
141
+ }
142
+
143
+ .flex-row.justify-between {
144
+ justify-content: space-between;
145
+ }
146
+
147
+ .cursor-pointer {
148
+ cursor: pointer;
149
+ }
150
+
151
+ .cursor-grab {
152
+ cursor: grab;
153
+ }
154
+
155
+ .display-block {
156
+ display: block;
157
+ }
158
+
159
+ .display-none {
160
+ display: none;
161
+ }
162
+
163
+ .image.background-cover {
164
+ background-position: center center;
165
+ background-repeat: no-repeat;
166
+ background-size: cover;
167
+ }
168
+
169
+ .image.background-contain {
170
+ background-position: center center;
171
+ background-repeat: no-repeat;
172
+ background-size: contain;
173
+ }
174
+
175
+ .image.background-center {
176
+ background-position: center center;
177
+ background-repeat: no-repeat;
178
+ }
179
+
180
+ .image.background-top-left {
181
+ background-position: top left;
182
+ background-repeat: no-repeat;
183
+ }
184
+
185
+ .image.background-center-left {
186
+ background-position: center left;
187
+ background-repeat: no-repeat;
188
+ }
189
+
190
+ .border-box-sizing {
191
+ box-sizing: border-box;
192
+ }
193
+
194
+ @media (prefers-reduced-motion: no-preference) {
195
+ .color-fade {
196
+ transition: color 0.3s ease-out;
197
+ }
198
+ }
199
+
200
+ .no-pointer-events {
201
+ pointer-events: none;
202
+ }
203
+
204
+ .all-pointer-events {
205
+ pointer-events: all;
206
+ }
207
+
208
+ .integrated-field {
209
+ box-sizing: border-box;
210
+ border: none;
211
+ display: block;
212
+ }
213
+
214
+ .centered-cell-holder {
215
+ display: flex;
216
+ justify-content: center;
217
+ align-items: center;
218
+ }
219
+
220
+ button.skip-default {
221
+ appearance: none;
222
+ border: none;
223
+ padding: 0;
224
+ text-align: inherit;
225
+ background: none;
226
+ color: inherit;
227
+ display: block;
228
+ font-size: inherit;
229
+ line-height: inherit;
230
+ font-family: inherit;
231
+ }
232
+
233
+ .no-opacity {
234
+ opacity: 0;
235
+ }
236
+
237
+ .clear-both {
238
+ clear: both;
239
+ }
240
+
241
+ .custom-styled-link {
242
+ color: inherit;
243
+ text-decoration: none;
244
+ }
245
+
246
+ .no-line-height {
247
+ line-height: 1;
248
+ }
249
+
250
+ .object-fit-cover {
251
+ object-fit: cover;
252
+ }
253
+
254
+ .full-rounded {
255
+ border-radius: 9999px;
256
+ }
@@ -0,0 +1,3 @@
1
+ :root {
2
+
3
+ }
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
+ "exports": {
7
+ ".": "./index.js",
8
+ "./css/all.css": "./css/all.css"
9
+ },
6
10
  "scripts": {},
7
11
  "keywords": [],
8
12
  "author": "",
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import Dbm from "../../../../index.js";
3
+
4
+ export default class FormattedField extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ _renderMainElement() {
10
+
11
+ let label = this.getPropValue("label");
12
+ let fieldName = this.getPropValue("fieldName");
13
+
14
+ return React.createElement("div", {},
15
+ React.createElement(Dbm.react.form.LabelledArea, {label: label}),
16
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldName},
17
+ React.createElement(Dbm.react.thirdparty.tinymce.InlineEditor, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), className: "standard-field standard-field-padding full-width"})
18
+ )
19
+ )
20
+ }
21
+ }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import Dbm from "../../../../index.js";
3
+
4
+ export default class FormattedFieldWithTranslations extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ _renderMainElement() {
10
+
11
+ let label = this.getPropValue("label");
12
+ let fieldName = this.getPropValue("fieldName");
13
+
14
+ let fieldNameSource = Dbm.react.source.contextVariable("fieldName");
15
+ let editorValueSource = Dbm.react.source.contextVariable("valueEditor.editValue.value");
16
+
17
+ return React.createElement("div", {},
18
+ React.createElement("label", {className: "standard-field-label"}, label),
19
+ React.createElement(Dbm.react.context.AddContextVariables, {values: {"fieldName": fieldName}},
20
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
21
+ React.createElement(Dbm.react.thirdparty.tinymce.InlineEditor, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
22
+ ),
23
+ React.createElement(Dbm.react.area.List, {items: Dbm.getRepositoryItem("site").properties.availableLanguages, as: "language"},
24
+ React.createElement("div", {className: "flex-row small-item-spacing vertically-center-items"},
25
+ React.createElement("div", {className: "flex-row-item flex-no-resize"},
26
+ Dbm.react.text.text(Dbm.react.source.contextVariable("language.code"))
27
+ ),
28
+ React.createElement("div", {className: "flex-row-item flex-resize"},
29
+ React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": Dbm.react.source.contextVariable("language.code")},
30
+ React.createElement(Dbm.react.thirdparty.tinymce.InlineEditor, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
31
+ ),
32
+ )
33
+ )
34
+ )
35
+ )
36
+ )
37
+ }
38
+ }
@@ -0,0 +1,160 @@
1
+ import React from "react";
2
+ import Dbm from "../../../../index.js";
3
+
4
+ export default class MultipleRelations extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ let objectType = this.getPropValue("objectType");
9
+ let encodings = this.getPropValueWithDefault("encodings", ["name"]);
10
+ let visibility = this.getPropValueWithDefault("visibility", "private");
11
+
12
+ this.item.requireProperty("items", []);
13
+
14
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
15
+ {
16
+ let request = graphApi.requestRange(
17
+ [
18
+ {"type": "byObjectType", "objectType": objectType},
19
+ {"type": "includeDraft"},
20
+ {"type": "includePrivate"}
21
+ ],
22
+ encodings
23
+ );
24
+
25
+
26
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._itemsLoaded.bind(this), [request]));
27
+ }
28
+ }
29
+
30
+ _itemsLoaded(aRequest) {
31
+ let options = [];
32
+
33
+ let nameField = this.getPropValue("nameField");
34
+ if(!nameField) {
35
+ nameField = "name";
36
+ }
37
+
38
+ let currentArray = [].concat(aRequest.items);
39
+ Dbm.utils.ArrayFunctions.sortOnField(currentArray, nameField);
40
+
41
+ this.item.items = currentArray;
42
+ }
43
+
44
+ _add(aItem) {
45
+ console.log("_add");
46
+ console.log(aItem);
47
+
48
+ let itemEditor = this.context.itemEditor;
49
+
50
+ let direction = this.getPropValue("direction");
51
+ let relationType = this.getPropValue("relationType");
52
+ let objectType = this.getPropValue("objectType");
53
+
54
+ let editor;
55
+ if(direction === "in") {
56
+ editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
57
+ }
58
+ else if(direction === "out") {
59
+ editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
60
+ }
61
+ else {
62
+ console.error("Unknown direction", direction, this);
63
+ }
64
+
65
+ let newValues = [].concat(editor.value);
66
+ newValues.push(aItem.id);
67
+ editor.value = newValues;
68
+ }
69
+
70
+ _remove(aId) {
71
+ console.log("_remove");
72
+ console.log(aId);
73
+
74
+ let itemEditor = this.context.itemEditor;
75
+
76
+ let direction = this.getPropValue("direction");
77
+ let relationType = this.getPropValue("relationType");
78
+ let objectType = this.getPropValue("objectType");
79
+
80
+ let editor;
81
+ if(direction === "in") {
82
+ editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
83
+ }
84
+ else if(direction === "out") {
85
+ editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
86
+ }
87
+ else {
88
+ console.error("Unknown direction", direction, this);
89
+ }
90
+
91
+ let newValues = [].concat(editor.value);
92
+
93
+ let index = newValues.indexOf(aId);
94
+ if(index >= 0) {
95
+ newValues.splice(index, 1);
96
+ }
97
+
98
+ editor.value = newValues;
99
+ }
100
+
101
+ _renderMainElement() {
102
+
103
+ let id = this.context.item.id;
104
+
105
+ let label = this.getPropValue("label");
106
+ let direction = this.getPropValue("direction");
107
+ let relationType = this.getPropValue("relationType");
108
+ let objectType = this.getPropValue("objectType");
109
+ let children = this.getPropValue("children");
110
+
111
+ return React.createElement("div", {},
112
+ React.createElement(Dbm.react.form.LabelledArea, {label: label}),
113
+ React.createElement(Dbm.react.area.HasData, {check: this.item.properties.items, checkType: "notEmpty"},
114
+ React.createElement("div")
115
+ ),
116
+ React.createElement("div", {"className": "standard-alternating-rows"},
117
+ React.createElement(Dbm.react.admin.editorsgroup.EditMultipleRelations, {"direction": direction, "relationType": relationType, "objectType": objectType},
118
+ React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("valueEditor.editValue.value")},
119
+ React.createElement("div", {"className": "flex-row small-item-spacing justify-between"},
120
+ React.createElement("div", {"className": "flex-row"},
121
+ React.createElement(Dbm.react.context.AddItemByIdToContext, {id: Dbm.react.source.contextVariable("item")},
122
+ Dbm.react.text.text(Dbm.react.source.item("name"))
123
+ )
124
+ ),
125
+ React.createElement("div", {"className": "flex-row"},
126
+ React.createElement(Dbm.react.interaction.CommandButton, {"commands": [Dbm.commands.callFunction(this._remove.bind(this), [Dbm.react.source.contextVariable("item")])]},
127
+ React.createElement("div", {},
128
+
129
+ "Remove"
130
+ )
131
+ )
132
+ )
133
+ )
134
+ )
135
+ )
136
+ ),
137
+ React.createElement("div", {"className": "spacing small"}),
138
+ React.createElement("div", {"className": "flex-row"},
139
+ React.createElement(Dbm.react.form.Dropdown, {"position": "right"},
140
+ React.createElement("div", {"data-slot": "button", "className": "action-button action-button-padding"},
141
+ "Add"
142
+ ),
143
+ React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
144
+ React.createElement(Dbm.react.area.List, {items: this.item.properties.items, "as": "relatedItem"},
145
+ React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
146
+ Dbm.commands.callFunction(this._add.bind(this), [Dbm.react.source.contextVariable("relatedItem")]),
147
+ Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
148
+ ]},
149
+ React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
150
+ Dbm.react.text.text(Dbm.react.source.contextVariable("relatedItem.name"))
151
+ )
152
+ ),
153
+ )
154
+ )
155
+ )
156
+
157
+ )
158
+ )
159
+ }
160
+ }
@@ -0,0 +1,21 @@
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
+
9
+ _renderMainElement() {
10
+
11
+ let label = this.getPropValue("label");
12
+ let fieldName = this.getPropValue("fieldName");
13
+
14
+ return React.createElement("div", {},
15
+ React.createElement(Dbm.react.form.LabelledArea, {label: label}),
16
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldName},
17
+ React.createElement(Dbm.react.thirdparty.tinymce.Editor, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), className: "standard-field standard-field-padding full-width"})
18
+ )
19
+ )
20
+ }
21
+ }
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import Dbm from "../../../../index.js";
3
+
4
+ export default class RichTextFieldWithTranslations extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ _renderMainElement() {
10
+
11
+ let label = this.getPropValue("label");
12
+ let fieldName = this.getPropValue("fieldName");
13
+
14
+ let fieldNameSource = Dbm.react.source.contextVariable("fieldName");
15
+ let editorValueSource = Dbm.react.source.contextVariable("valueEditor.editValue.value");
16
+
17
+ return React.createElement("div", {},
18
+ React.createElement("label", {className: "standard-field-label"}, label),
19
+ React.createElement(Dbm.react.context.AddContextVariables, {values: {"fieldName": fieldName}},
20
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
21
+ React.createElement(Dbm.react.thirdparty.tinymce.Editor, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
22
+ ),
23
+ React.createElement(Dbm.react.area.List, {items: Dbm.getRepositoryItem("site").properties.availableLanguages, as: "language"},
24
+ React.createElement("div", {className: "flex-row small-item-spacing vertically-center-items"},
25
+ React.createElement("div", {className: "flex-row-item flex-no-resize"},
26
+ Dbm.react.text.text(Dbm.react.source.contextVariable("language.code"))
27
+ ),
28
+ React.createElement("div", {className: "flex-row-item flex-resize"},
29
+ React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": Dbm.react.source.contextVariable("language.code")},
30
+ React.createElement(Dbm.react.thirdparty.tinymce.Editor, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
31
+ ),
32
+ )
33
+ )
34
+ )
35
+ )
36
+ )
37
+ }
38
+ }
@@ -15,3 +15,8 @@ export {default as Url} from "./Url.js";
15
15
  export {default as RelationsList} from "./RelationsList.js";
16
16
  export {default as HierarchyOrderedRelationsList} from "./HierarchyOrderedRelationsList.js";
17
17
  export {default as DraggableHierarchyDisplay} from "./DraggableHierarchyDisplay.js";
18
+ export {default as MultipleRelations} from "./MultipleRelations.js";
19
+ export {default as RichTextField} from "./RichTextField.js";
20
+ export {default as RichTextFieldWithTranslations} from "./RichTextFieldWithTranslations.js";
21
+ export {default as FormattedField} from "./FormattedField.js";
22
+ export {default as FormattedFieldWithTranslations} from "./FormattedFieldWithTranslations.js";
package/react/index.js CHANGED
@@ -16,3 +16,4 @@ export * as login from "./login/index.js";
16
16
  export * as image from "./image/index.js";
17
17
  export * as animation from "./animation/index.js";
18
18
  export * as interaction from "./interaction/index.js";
19
+ export * as thirdparty from "./thirdparty/index.js";
@@ -0,0 +1,2 @@
1
+ export * as tinymce from "./tinymce/index.js";
2
+ export * as vimeo from "./vimeo/index.js";
@@ -0,0 +1,106 @@
1
+ import React from "react";
2
+ import Dbm from "../../../index.js";
3
+
4
+ export default class Editor extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this._element = document.createElement("div");
9
+ this._editor = null;
10
+
11
+ let valueProperty = this.getDynamicPropWithoutState("value", "");
12
+ Dbm.flow.addUpdateCommand(valueProperty, Dbm.commands.callFunction(this._valueUpdated.bind(this)));
13
+
14
+ this._callback_changeBound = this._callback_change.bind(this);
15
+
16
+ let tinymce = Dbm.getRepositoryItem("tinymce");
17
+ let version = tinymce.version ? tinymce.version : "8";
18
+
19
+ let scriptLoader = Dbm.loading.loadScript("https://cdn.tiny.cloud/1/" + tinymce.key + "/tinymce/" + version + "/tinymce.min.js");
20
+ Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
21
+ }
22
+
23
+ getSettings() {
24
+ let settings = {
25
+ menubar: false,
26
+ statusbar: false,
27
+
28
+ convert_urls: false,
29
+ relative_urls: false,
30
+ remove_script_host: false,
31
+ verify_url: false,
32
+
33
+ plugins: "link image code autoresize advlist lists",
34
+ toolbar: "undo redo | styleselect | bold italic | link | alignleft aligncenter alignright | numlist bullist | code removeformat | fontsizeselect"
35
+ };
36
+
37
+ return settings;
38
+ }
39
+
40
+ _scriptLoaded() {
41
+
42
+ let settings = this.getSettings();
43
+
44
+ settings["target"] = this._element;
45
+ settings["setup"] = this._callback_setup.bind(this);
46
+
47
+ window.tinymce.init(settings);
48
+ }
49
+
50
+ _callback_setup(aEditor) {
51
+ this._editor = aEditor;
52
+
53
+ this._editor.on('change', this._callback_change.bind(this));
54
+ this._editor.on('input', this._callback_change.bind(this));
55
+ this._editor.on('init', this._callback_init.bind(this));
56
+ }
57
+
58
+ _callback_init() {
59
+ let value = this.getDynamicProp("value").value;
60
+ if(value) {
61
+ this._editor.setContent(value);
62
+ }
63
+
64
+ }
65
+
66
+ _callback_change() {
67
+ //console.log("_callback_change");
68
+
69
+ let value = this._editor.getContent();
70
+
71
+ this.getDynamicProp("value").getMostUpstreamProperty().setValue(value);
72
+ }
73
+
74
+ _valueUpdated() {
75
+ //console.log("_valueUpdated");
76
+ let value = this.getPropValue("value");
77
+
78
+ if(this._editor) {
79
+ let currentValue = this._editor.getContent();
80
+
81
+ if(value !== currentValue && value !== undefined && value !== null) {
82
+ this._editor.setContent(value);
83
+ }
84
+ }
85
+ }
86
+
87
+ componentDidMount() {
88
+ //console.log("componentDidMount");
89
+ let parentElement = this.item.holder;
90
+ parentElement.appendChild(this._element);
91
+ }
92
+
93
+ componentDidUpdate() {
94
+ //console.log("componentDidUpdate");
95
+ let parentElement = this.item.holder;
96
+ parentElement.appendChild(this._element);
97
+ }
98
+
99
+ _renderMainElement() {
100
+
101
+ return this._createMainElement("div", {},
102
+ React.createElement("div", {"ref": this.createRef("holder")})
103
+ );
104
+ }
105
+ }
106
+
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import Dbm from "../../../index.js";
3
+
4
+ export default class InlineEditor extends Dbm.react.thirdparty.tinymce.Editor {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ getSettings() {
10
+ let settings = super.getSettings();
11
+
12
+ let additionalSettings = {
13
+ inline: true,
14
+ toolbar: false,
15
+ plugins: 'link quickbars',
16
+ quickbars_selection_toolbar: 'bold italic | link',
17
+ quickbars_insert_toolbar: false,
18
+ };
19
+
20
+ settings = {
21
+ ...settings,
22
+ ...additionalSettings
23
+ }
24
+
25
+ return settings;
26
+ }
27
+ }
28
+
@@ -0,0 +1,2 @@
1
+ export {default as Editor} from "./Editor.js";
2
+ export {default as InlineEditor} from "./InlineEditor.js";
@@ -0,0 +1,65 @@
1
+ import React from "react";
2
+ import Dbm from "../../../index.js";
3
+
4
+ export default class Player extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this._element = document.createElement("div");
9
+ this._element.classList.add("vimeo-player");
10
+
11
+ let scriptLoader = Dbm.loading.loadScript("https://player.vimeo.com/api/player.js");
12
+ Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
13
+ }
14
+
15
+ _removedUsedProps(aProps) {
16
+ delete aProps["video"];
17
+ delete aProps["responsive"];
18
+ }
19
+
20
+ getSettings() {
21
+
22
+ let data = {
23
+ responsive: this.getPropValueWithDefault("responsive", false),
24
+ title: false,
25
+ byline: false,
26
+ portrait: false,
27
+ color: "000000"
28
+ };
29
+
30
+ return data;
31
+ }
32
+
33
+ _scriptLoaded() {
34
+
35
+ let video = this.getPropValue("video");
36
+
37
+ let data = this.getSettings();
38
+
39
+ if(typeof video === "number" || (typeof video === "string" && video.trim() !== "" && !isNaN(video))) {
40
+ data["id"] = video;
41
+ }
42
+ else {
43
+ data["url"] = video;
44
+ }
45
+
46
+ let player = new window.Vimeo.Player(this._element, data);
47
+ }
48
+
49
+ componentDidMount() {
50
+ //console.log("componentDidMount");
51
+ let parentElement = this.item.holder;
52
+ parentElement.appendChild(this._element);
53
+ }
54
+
55
+ componentDidUpdate() {
56
+ //console.log("componentDidUpdate");
57
+ let parentElement = this.item.holder;
58
+ parentElement.appendChild(this._element);
59
+ }
60
+
61
+ _renderMainElement() {
62
+ return this._createMainElement("div", {"className": "vimeo-player-holder", "ref": this.createRef("holder")});
63
+ }
64
+ }
65
+
@@ -0,0 +1 @@
1
+ export {default as Player} from "./Player.js";
@@ -391,5 +391,74 @@ export const scoreItems = function(aArray, aScoreFunction) {
391
391
 
392
392
  sortOnField(returnArray, "value");
393
393
 
394
+ return returnArray;
395
+ }
396
+
397
+ export const splitArray = function(aArray, aGroupSize) {
398
+ let returnArray = [];
399
+ let currentGroup = null;
400
+
401
+ let currentArray = aArray;
402
+ let currentArrayLength = currentArray.length;
403
+ for(let i = 0; i < currentArrayLength; i++) {
404
+ if(i % aGroupSize === 0) {
405
+ currentGroup = [];
406
+ returnArray.push(currentGroup);
407
+ }
408
+ currentGroup.push(currentArray[i]);
409
+ }
410
+
411
+ return returnArray;
412
+ }
413
+
414
+ export const mapArrayToObject = function(aArray, aKeyField, aDataField = null, aKeyPrefix = "") {
415
+
416
+ let returnObject = {};
417
+
418
+ let currentArray = aArray;
419
+ let currentArrayLength = currentArray.length;
420
+ for(let i = 0; i < currentArrayLength; i++) {
421
+ let currentArrayEntry = currentArray[i];
422
+ let key = aKeyPrefix + Dbm.objectPath(currentArrayEntry, aKeyField);
423
+ let data = aDataField ? Dbm.objectPath(currentArrayEntry, aDataField) : currentArrayEntry;
424
+
425
+ returnObject[key] = data;
426
+ }
427
+
428
+ return returnObject;
429
+ }
430
+
431
+ export const mapObjectToArray = function(aObject, aKeyField, aDataField = null, aKeyPrefix = "") {
432
+ let returnArray = [];
433
+
434
+ for(let objectName in aObject) {
435
+ let currentEntry = aObject[objectName];
436
+ let newObject = {};
437
+
438
+ if(aDataField !== null) {
439
+ newObject[aDataField] = currentEntry;
440
+ }
441
+ else {
442
+ for(let objectName2 in currentEntry) {
443
+ newObject[objectName2] = currentEntry[objectName2];
444
+ }
445
+ }
446
+ if(aKeyField) {
447
+ newObject[aKeyField] = objectName.substring(aKeyPrefix.length, objectName.length);
448
+ }
449
+
450
+ returnArray.push(newObject);
451
+ }
452
+
453
+ return returnArray;
454
+ }
455
+
456
+ export const mapObjectToArrayWithoutKey = function(aObject) {
457
+ let returnArray = [];
458
+
459
+ for(let objectName in aObject) {
460
+ returnArray.push(aObject[objectName]);
461
+ }
462
+
394
463
  return returnArray;
395
464
  }
@@ -37,4 +37,15 @@ export const convertToCamelCase = function(aText) {
37
37
  }
38
38
 
39
39
  return returnText;
40
- };
40
+ };
41
+
42
+ export const getMatchingPrefix = function(aString1, aString2) {
43
+ let maxLength = Math.min(aString1.length, aString2.length);
44
+ let i = 0;
45
+
46
+ while(i < maxLength && aString1[i] === aString2[i]) {
47
+ i++;
48
+ }
49
+
50
+ return aString1.slice(0, i);
51
+ }