@wirenboard/json-editor 2.5.3-wb13
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/.env-dist +2 -0
- package/.eslintrc +7 -0
- package/.gitattributes +1 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/.github/issue_template +25 -0
- package/.github/workflows/build.yml +58 -0
- package/.travis.yml +70 -0
- package/CHANGELOG.md +915 -0
- package/CONTRIBUTING.md +92 -0
- package/LICENSE +20 -0
- package/Makefile +26 -0
- package/README.md +1646 -0
- package/README_ADDON.md +573 -0
- package/UPGRADING.md +46 -0
- package/build/CssToJson.js +55 -0
- package/codecept.conf.js +35 -0
- package/config/.eslintrc +7 -0
- package/config/codeceptjs_helpers.js +139 -0
- package/config/helpers.js +10 -0
- package/config/karma.conf.js +93 -0
- package/config/readme.md +31 -0
- package/config/webpack.common.js +75 -0
- package/config/webpack.dev.js +15 -0
- package/config/webpack.nonmin.js +19 -0
- package/config/webpack.prod.js +25 -0
- package/dist/jsoneditor.js +14 -0
- package/dist/nonmin/jsoneditor.js +29097 -0
- package/dist/nonmin/jsoneditor.js.map +1 -0
- package/docs/ace_editor.html +56 -0
- package/docs/advanced.html +136 -0
- package/docs/basic.html +63 -0
- package/docs/basic_person.json +26 -0
- package/docs/choices.html +86 -0
- package/docs/cleave.html +132 -0
- package/docs/colorpicker.html +194 -0
- package/docs/css_integration.html +135 -0
- package/docs/datetime.html +305 -0
- package/docs/describedby.html +161 -0
- package/docs/enumsource.html +67 -0
- package/docs/images/categoriesDemo.png +0 -0
- package/docs/images/inheritance_tree.png +0 -0
- package/docs/images/jsoneditor.png +0 -0
- package/docs/imask.html +192 -0
- package/docs/index.html +579 -0
- package/docs/materialize_css.html +164 -0
- package/docs/meta_schema.json +705 -0
- package/docs/multiple_upload_base64.html +65 -0
- package/docs/person.json +73 -0
- package/docs/polyfills/assign.js +29 -0
- package/docs/radio.html +156 -0
- package/docs/recursive.html +170 -0
- package/docs/select2.html +99 -0
- package/docs/selectize.html +100 -0
- package/docs/signature.html +42 -0
- package/docs/starrating.html +137 -0
- package/docs/upload.html +131 -0
- package/docs/uuid.html +70 -0
- package/docs/wysiwyg.html +56 -0
- package/jasmine.json +11 -0
- package/json-editor-json-editor-2.5.3-wb13.tgz +0 -0
- package/package.json +100 -0
- package/release-notes.md +88 -0
- package/src/core.js +412 -0
- package/src/defaults.js +402 -0
- package/src/editor.js +707 -0
- package/src/editors/ace.js +89 -0
- package/src/editors/array/choices.js +103 -0
- package/src/editors/array/select2.js +110 -0
- package/src/editors/array/selectize.js +103 -0
- package/src/editors/array.css +9 -0
- package/src/editors/array.css.js +3 -0
- package/src/editors/array.js +818 -0
- package/src/editors/autocomplete.js +58 -0
- package/src/editors/base64.js +157 -0
- package/src/editors/button.js +97 -0
- package/src/editors/checkbox.js +95 -0
- package/src/editors/choices.css +3 -0
- package/src/editors/choices.css.js +3 -0
- package/src/editors/choices.js +69 -0
- package/src/editors/colorpicker.js +103 -0
- package/src/editors/datetime.js +141 -0
- package/src/editors/describedby.js +188 -0
- package/src/editors/enum.js +136 -0
- package/src/editors/hidden.js +127 -0
- package/src/editors/index.js +81 -0
- package/src/editors/info.js +20 -0
- package/src/editors/integer.js +19 -0
- package/src/editors/ip.js +36 -0
- package/src/editors/jodit.js +64 -0
- package/src/editors/multiple.js +409 -0
- package/src/editors/multiselect.js +218 -0
- package/src/editors/null.js +18 -0
- package/src/editors/number.js +51 -0
- package/src/editors/object.css +41 -0
- package/src/editors/object.css.js +3 -0
- package/src/editors/object.js +1290 -0
- package/src/editors/radio.js +111 -0
- package/src/editors/sceditor.js +72 -0
- package/src/editors/select.js +370 -0
- package/src/editors/select2.js +110 -0
- package/src/editors/selectize.js +112 -0
- package/src/editors/signature.js +113 -0
- package/src/editors/simplemde.js +100 -0
- package/src/editors/starrating.css +52 -0
- package/src/editors/starrating.css.js +3 -0
- package/src/editors/starrating.js +135 -0
- package/src/editors/stepper.js +27 -0
- package/src/editors/string.js +372 -0
- package/src/editors/table.js +516 -0
- package/src/editors/upload.js +321 -0
- package/src/editors/uuid.js +56 -0
- package/src/iconlib.js +24 -0
- package/src/iconlibs/bootstrap2.js +28 -0
- package/src/iconlibs/bootstrap3.js +28 -0
- package/src/iconlibs/fontawesome3.js +28 -0
- package/src/iconlibs/fontawesome4.js +28 -0
- package/src/iconlibs/fontawesome5.js +28 -0
- package/src/iconlibs/foundation2.js +24 -0
- package/src/iconlibs/foundation3.js +28 -0
- package/src/iconlibs/index.js +25 -0
- package/src/iconlibs/jqueryui.js +28 -0
- package/src/iconlibs/materialicons.js +49 -0
- package/src/iconlibs/openiconic.js +28 -0
- package/src/iconlibs/spectre.js +28 -0
- package/src/resolvers.js +128 -0
- package/src/schemaloader.js +408 -0
- package/src/style.css +150 -0
- package/src/style.css.js +3 -0
- package/src/templates/default.js +52 -0
- package/src/templates/ejs.js +13 -0
- package/src/templates/handlebars.js +1 -0
- package/src/templates/hogan.js +10 -0
- package/src/templates/index.js +21 -0
- package/src/templates/lodash.js +9 -0
- package/src/templates/markup.js +9 -0
- package/src/templates/mustache.js +9 -0
- package/src/templates/swig.js +1 -0
- package/src/templates/underscore.js +9 -0
- package/src/theme.js +659 -0
- package/src/themes/barebones.css +35 -0
- package/src/themes/barebones.css.js +3 -0
- package/src/themes/barebones.js +28 -0
- package/src/themes/bootstrap2.js +319 -0
- package/src/themes/bootstrap3.css +0 -0
- package/src/themes/bootstrap3.css.js +3 -0
- package/src/themes/bootstrap3.js +315 -0
- package/src/themes/bootstrap4.css +89 -0
- package/src/themes/bootstrap4.css.js +3 -0
- package/src/themes/bootstrap4.js +690 -0
- package/src/themes/bootstrap5.css.js +3 -0
- package/src/themes/foundation.js +569 -0
- package/src/themes/html.css +60 -0
- package/src/themes/html.css.js +3 -0
- package/src/themes/html.js +71 -0
- package/src/themes/index.js +28 -0
- package/src/themes/jqueryui.js +198 -0
- package/src/themes/materialize.js +426 -0
- package/src/themes/spectre.css +208 -0
- package/src/themes/spectre.css.js +3 -0
- package/src/themes/spectre.js +406 -0
- package/src/themes/tailwind.css +249 -0
- package/src/themes/tailwind.css.js +3 -0
- package/src/themes/tailwind.js +443 -0
- package/src/utilities.js +138 -0
- package/src/validator.js +877 -0
- package/src/validators/ip-validator.js +51 -0
- package/tests/Dockerfile +3 -0
- package/tests/README.md +48 -0
- package/tests/codeceptjs/codecept.json +42 -0
- package/tests/codeceptjs/constrains/if-then-else_test.js +143 -0
- package/tests/codeceptjs/core_test.js +217 -0
- package/tests/codeceptjs/editors/advanced_test.js +13 -0
- package/tests/codeceptjs/editors/array_any_of_test.js +50 -0
- package/tests/codeceptjs/editors/array_test.js +900 -0
- package/tests/codeceptjs/editors/button_test.js +35 -0
- package/tests/codeceptjs/editors/checkbox_test.js +21 -0
- package/tests/codeceptjs/editors/colorpicker_test.js +27 -0
- package/tests/codeceptjs/editors/datetime_test.js +33 -0
- package/tests/codeceptjs/editors/inheritance_test.js +11 -0
- package/tests/codeceptjs/editors/integer_test.js +84 -0
- package/tests/codeceptjs/editors/issues/issue-gh-812_test.js +32 -0
- package/tests/codeceptjs/editors/jodit_test.js +24 -0
- package/tests/codeceptjs/editors/multiselect_test.js +8 -0
- package/tests/codeceptjs/editors/number_test.js +82 -0
- package/tests/codeceptjs/editors/object_test.js +204 -0
- package/tests/codeceptjs/editors/option-no_default_values_test.js +42 -0
- package/tests/codeceptjs/editors/programmatic-changes_test.js +20 -0
- package/tests/codeceptjs/editors/radio_test.js +10 -0
- package/tests/codeceptjs/editors/rating_test.js +13 -0
- package/tests/codeceptjs/editors/select_test.js +22 -0
- package/tests/codeceptjs/editors/stepper_test.js +27 -0
- package/tests/codeceptjs/editors/string_test.js +118 -0
- package/tests/codeceptjs/editors/table-confirm-delete_test.js +67 -0
- package/tests/codeceptjs/editors/tabs_test.js +14 -0
- package/tests/codeceptjs/editors/uuid_test.js +21 -0
- package/tests/codeceptjs/editors/validation_test.js +14 -0
- package/tests/codeceptjs/meta-schema_test.js +17 -0
- package/tests/codeceptjs/schemaloader_test.js +13 -0
- package/tests/codeceptjs/steps.d.ts +13 -0
- package/tests/codeceptjs/steps_file.js +12 -0
- package/tests/codeceptjs/themes_test.js +519 -0
- package/tests/docker-compose.yml +34 -0
- package/tests/fixtures/basic_person.json +26 -0
- package/tests/fixtures/nested_object.json +26 -0
- package/tests/fixtures/person.json +55 -0
- package/tests/fixtures/recursive.json +8 -0
- package/tests/fixtures/some_types.json +32 -0
- package/tests/fixtures/string.json +3 -0
- package/tests/fixtures/validation.json +1140 -0
- package/tests/pages/_demo.html +475 -0
- package/tests/pages/advanced.html +137 -0
- package/tests/pages/anyof.html +80 -0
- package/tests/pages/array-anyof.html +142 -0
- package/tests/pages/array-checkboxes.html +41 -0
- package/tests/pages/array-choices.html +45 -0
- package/tests/pages/array-integers.html +37 -0
- package/tests/pages/array-move-events.html +61 -0
- package/tests/pages/array-multiselects.html +42 -0
- package/tests/pages/array-nested-arrays.html +40 -0
- package/tests/pages/array-numbers.html +37 -0
- package/tests/pages/array-objects.html +42 -0
- package/tests/pages/array-ratings.html +40 -0
- package/tests/pages/array-selectize.html +51 -0
- package/tests/pages/array-selects.html +36 -0
- package/tests/pages/array-strings.html +36 -0
- package/tests/pages/array.html +42 -0
- package/tests/pages/assets/pages.css +130 -0
- package/tests/pages/button-callbacks.html +77 -0
- package/tests/pages/checkbox-labels.html +114 -0
- package/tests/pages/colorpicker-no-3rd-party.html +43 -0
- package/tests/pages/colorpicker-use-vanilla-picker.html +50 -0
- package/tests/pages/core.html +118 -0
- package/tests/pages/datetime.html +76 -0
- package/tests/pages/form-name.html +108 -0
- package/tests/pages/grid-strict.html +311 -0
- package/tests/pages/grid.html +284 -0
- package/tests/pages/if-then-else-allOf.html +117 -0
- package/tests/pages/inheritance.html +76 -0
- package/tests/pages/integer.html +68 -0
- package/tests/pages/issues/_template.html +50 -0
- package/tests/pages/issues/issue-gh-812.html +110 -0
- package/tests/pages/issues/issue-gh-823-meta-schema.html +35 -0
- package/tests/pages/issues/issue-gh-848.html +81 -0
- package/tests/pages/meta_schema.json +705 -0
- package/tests/pages/number.html +89 -0
- package/tests/pages/object-no-additional-properties.html +65 -0
- package/tests/pages/object-no-duplicated-id.html +68 -0
- package/tests/pages/object-required-properties.html +236 -0
- package/tests/pages/object-with-dependencies-array.html +46 -0
- package/tests/pages/object-with-dependencies.html +60 -0
- package/tests/pages/object.html +79 -0
- package/tests/pages/oneof.html +103 -0
- package/tests/pages/option-no_default_values.html +58 -0
- package/tests/pages/programmatic-changes.html +120 -0
- package/tests/pages/read-only.html +105 -0
- package/tests/pages/select.html +41 -0
- package/tests/pages/stepper.html +59 -0
- package/tests/pages/string-ace-editor.html +52 -0
- package/tests/pages/string-cleave.html +46 -0
- package/tests/pages/string-custom-attributes.html +62 -0
- package/tests/pages/string-formats.html +52 -0
- package/tests/pages/string-formats2.html +57 -0
- package/tests/pages/string-jodit-editor.html +49 -0
- package/tests/pages/string-sceditor.html +62 -0
- package/tests/pages/table-move-events.html +56 -0
- package/tests/pages/table.html +46 -0
- package/tests/pages/tabs.html +131 -0
- package/tests/pages/themes.html +527 -0
- package/tests/pages/translate-property.html +247 -0
- package/tests/pages/urn.html +93 -0
- package/tests/pages/uuid.html +72 -0
- package/tests/pages/validation.html +99 -0
- package/tests/unit/.eslintrc +8 -0
- package/tests/unit/core.spec.js +309 -0
- package/tests/unit/defaults.spec.js +40 -0
- package/tests/unit/editor.spec.js +160 -0
- package/tests/unit/editors/array.spec.js +86 -0
- package/tests/unit/editors/object.spec.js +79 -0
- package/tests/unit/editors/table.spec.js +91 -0
- package/tests/unit/readme.md +35 -0
- package/tests/unit/schemaloader.spec.js +498 -0
- package/tests/unit/validator.spec.js +94 -0
- package/tests/unit/validators/ip-validator.spec.js +62 -0
package/src/theme.js
ADDED
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import { trigger } from './utilities'
|
|
2
|
+
|
|
3
|
+
const matchKey = [
|
|
4
|
+
'matches',
|
|
5
|
+
'webkitMatchesSelector',
|
|
6
|
+
'mozMatchesSelector',
|
|
7
|
+
'msMatchesSelector',
|
|
8
|
+
'oMatchesSelector'].find(key => key in document.documentElement)
|
|
9
|
+
|
|
10
|
+
export class AbstractTheme {
|
|
11
|
+
constructor (jsoneditor, options = { disable_theme_rules: false }) {
|
|
12
|
+
this.jsoneditor = jsoneditor
|
|
13
|
+
Object.keys(options).forEach(key => {
|
|
14
|
+
if (typeof jsoneditor.options[key] !== 'undefined') {
|
|
15
|
+
options[key] = jsoneditor.options[key]
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
/* Theme config options that allows changing various aspects of the output */
|
|
19
|
+
this.options = options
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getContainer () {
|
|
23
|
+
return document.createElement('div')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getFloatRightLinkHolder () {
|
|
27
|
+
const el = document.createElement('div')
|
|
28
|
+
el.classList.add('je-float-right-linkholder')
|
|
29
|
+
return el
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getModal () {
|
|
33
|
+
const el = document.createElement('div')
|
|
34
|
+
el.style.display = 'none'
|
|
35
|
+
el.classList.add('je-modal')
|
|
36
|
+
return el
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getGridContainer () {
|
|
40
|
+
const el = document.createElement('div')
|
|
41
|
+
return el
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getGridRow () {
|
|
45
|
+
const el = document.createElement('div')
|
|
46
|
+
el.classList.add('row')
|
|
47
|
+
return el
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getGridColumn () {
|
|
51
|
+
const el = document.createElement('div')
|
|
52
|
+
return el
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setGridColumnSize (el, size) {
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getLink (text) {
|
|
59
|
+
const el = document.createElement('a')
|
|
60
|
+
el.setAttribute('href', '#')
|
|
61
|
+
el.appendChild(document.createTextNode(text))
|
|
62
|
+
return el
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
disableHeader (header) {
|
|
66
|
+
header.style.color = '#ccc'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
disableLabel (label) {
|
|
70
|
+
label.style.color = '#ccc'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
enableHeader (header) {
|
|
74
|
+
header.style.color = ''
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
enableLabel (label) {
|
|
78
|
+
label.style.color = ''
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getInfoButton (text) {
|
|
82
|
+
const icon = document.createElement('span')
|
|
83
|
+
icon.innerText = 'ⓘ'
|
|
84
|
+
icon.classList.add('je-infobutton-icon')
|
|
85
|
+
|
|
86
|
+
const tooltip = document.createElement('span')
|
|
87
|
+
tooltip.classList.add('je-infobutton-tooltip')
|
|
88
|
+
tooltip.innerText = text
|
|
89
|
+
icon.onmouseover = () => {
|
|
90
|
+
tooltip.style.visibility = 'visible'
|
|
91
|
+
}
|
|
92
|
+
icon.onmouseleave = () => {
|
|
93
|
+
tooltip.style.visibility = 'hidden'
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
icon.appendChild(tooltip)
|
|
97
|
+
|
|
98
|
+
return icon
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
getFormInputLabel (text, req) {
|
|
102
|
+
const el = document.createElement('label')
|
|
103
|
+
el.appendChild(document.createTextNode(text))
|
|
104
|
+
if (req) el.classList.add('required')
|
|
105
|
+
return el
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getHeader (text, pathDepth) {
|
|
109
|
+
const el = document.createElement('h3')
|
|
110
|
+
if (typeof text === 'string') {
|
|
111
|
+
el.textContent = text
|
|
112
|
+
} else {
|
|
113
|
+
el.appendChild(text)
|
|
114
|
+
}
|
|
115
|
+
el.classList.add('je-header')
|
|
116
|
+
|
|
117
|
+
return el
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getCheckbox () {
|
|
121
|
+
const el = this.getFormInputField('checkbox')
|
|
122
|
+
el.classList.add('je-checkbox')
|
|
123
|
+
return el
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getCheckboxLabel (text, req) {
|
|
127
|
+
const el = document.createElement('label')
|
|
128
|
+
el.appendChild(document.createTextNode(`\u00A0${text}`))
|
|
129
|
+
if (req) el.classList.add('required')
|
|
130
|
+
return el
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getMultiCheckboxHolder (controls, label, description, infoText) {
|
|
134
|
+
const el = document.createElement('div')
|
|
135
|
+
el.classList.add('control-group')
|
|
136
|
+
|
|
137
|
+
if (label) {
|
|
138
|
+
label.style.display = 'block'
|
|
139
|
+
el.appendChild(label)
|
|
140
|
+
if (infoText) label.appendChild(infoText)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
Object.values(controls).forEach(control => {
|
|
144
|
+
control.style.display = 'inline-block'
|
|
145
|
+
control.style.marginRight = '20px'
|
|
146
|
+
el.appendChild(control)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
if (description) el.appendChild(description)
|
|
150
|
+
|
|
151
|
+
return el
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getFormCheckboxControl (label, input, compact) {
|
|
155
|
+
const el = document.createElement('div')
|
|
156
|
+
el.appendChild(label)
|
|
157
|
+
input.style.width = 'auto'
|
|
158
|
+
label.insertBefore(input, label.firstChild)
|
|
159
|
+
if (compact) {
|
|
160
|
+
el.classList.add('je-checkbox-control--compact')
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return el
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
getFormRadio (attributes) {
|
|
167
|
+
const el = this.getFormInputField('radio')
|
|
168
|
+
Object.keys(attributes).forEach(key => el.setAttribute(key, attributes[key]))
|
|
169
|
+
el.classList.add('je-radio')
|
|
170
|
+
return el
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getFormRadioLabel (text, req) {
|
|
174
|
+
const el = document.createElement('label')
|
|
175
|
+
el.appendChild(document.createTextNode(`\u00A0${text}`))
|
|
176
|
+
if (req) el.classList.add('required')
|
|
177
|
+
return el
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
getFormRadioControl (label, input, compact) {
|
|
181
|
+
const el = document.createElement('div')
|
|
182
|
+
el.appendChild(label)
|
|
183
|
+
input.style.width = 'auto'
|
|
184
|
+
label.insertBefore(input, label.firstChild)
|
|
185
|
+
if (compact) {
|
|
186
|
+
el.classList.add('je-radio-control--compact')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return el
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
getSelectInput (options, multiple) {
|
|
193
|
+
const select = document.createElement('select')
|
|
194
|
+
if (options) this.setSelectOptions(select, options)
|
|
195
|
+
return select
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
getSwitcher (options) {
|
|
199
|
+
const switcher = this.getSelectInput(options, false)
|
|
200
|
+
switcher.classList.add('je-switcher')
|
|
201
|
+
return switcher
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
getSwitcherOptions (switcher) {
|
|
205
|
+
return switcher.getElementsByTagName('option')
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
setSwitcherOptions (switcher, options, titles) {
|
|
209
|
+
this.setSelectOptions(switcher, options, titles)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
setSelectOptions (select, options, titles = []) {
|
|
213
|
+
select.innerHTML = ''
|
|
214
|
+
for (let i = 0; i < options.length; i++) {
|
|
215
|
+
const option = document.createElement('option')
|
|
216
|
+
option.setAttribute('value', options[i])
|
|
217
|
+
option.textContent = titles[i] || options[i]
|
|
218
|
+
select.appendChild(option)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
getTextareaInput () {
|
|
223
|
+
const el = document.createElement('textarea')
|
|
224
|
+
el.classList.add('je-textarea')
|
|
225
|
+
return el
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
getRangeInput (min, max, step) {
|
|
229
|
+
const el = this.getFormInputField('range')
|
|
230
|
+
el.setAttribute('min', min)
|
|
231
|
+
el.setAttribute('max', max)
|
|
232
|
+
el.setAttribute('step', step)
|
|
233
|
+
return el
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
getStepperButtons (input) {
|
|
237
|
+
const div = document.createElement('div')
|
|
238
|
+
|
|
239
|
+
const minusBtn = document.createElement('button')
|
|
240
|
+
minusBtn.setAttribute('type', 'button')
|
|
241
|
+
minusBtn.classList.add('stepper-down')
|
|
242
|
+
|
|
243
|
+
const plusBtn = document.createElement('button')
|
|
244
|
+
plusBtn.setAttribute('type', 'button')
|
|
245
|
+
plusBtn.classList.add('stepper-up')
|
|
246
|
+
|
|
247
|
+
const readonly = input.getAttribute('readonly')
|
|
248
|
+
|
|
249
|
+
if (readonly) {
|
|
250
|
+
minusBtn.setAttribute('disabled', true)
|
|
251
|
+
plusBtn.setAttribute('disabled', true)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
minusBtn.textContent = '-'
|
|
255
|
+
plusBtn.textContent = '+'
|
|
256
|
+
|
|
257
|
+
const initialize = (input, min) => {
|
|
258
|
+
if (min) {
|
|
259
|
+
input.value = Number(min)
|
|
260
|
+
} else {
|
|
261
|
+
input.value = Number(input.value)
|
|
262
|
+
}
|
|
263
|
+
input.setAttribute('initialized', '1')
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const min = input.getAttribute('min')
|
|
267
|
+
const max = input.getAttribute('max')
|
|
268
|
+
|
|
269
|
+
minusBtn.addEventListener('click', () => {
|
|
270
|
+
if (!input.getAttribute('initialized')) {
|
|
271
|
+
initialize(input, min)
|
|
272
|
+
} else if (min) {
|
|
273
|
+
if (Number(input.value) > Number(min)) {
|
|
274
|
+
input.stepDown()
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
input.stepDown()
|
|
278
|
+
}
|
|
279
|
+
trigger(input, 'change')
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
plusBtn.addEventListener('click', () => {
|
|
283
|
+
if (!input.getAttribute('initialized')) {
|
|
284
|
+
initialize(input, min)
|
|
285
|
+
} else if (max) {
|
|
286
|
+
if (Number(input.value) < Number(max)) {
|
|
287
|
+
input.stepUp()
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
input.stepUp()
|
|
291
|
+
}
|
|
292
|
+
trigger(input, 'change')
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
div.appendChild(minusBtn)
|
|
296
|
+
div.appendChild(plusBtn)
|
|
297
|
+
return div
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
getRangeOutput (input, startvalue) {
|
|
301
|
+
const output = document.createElement('output')
|
|
302
|
+
output.value = startvalue || 0
|
|
303
|
+
|
|
304
|
+
const updateOutput = e => { output.value = e.currentTarget.value }
|
|
305
|
+
input.addEventListener('change', updateOutput, false)
|
|
306
|
+
input.addEventListener('input', updateOutput, false)
|
|
307
|
+
return output
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
getRangeControl (input, output) {
|
|
311
|
+
const el = document.createElement('div')
|
|
312
|
+
el.classList.add('je-range-control')
|
|
313
|
+
if (output) el.appendChild(output)
|
|
314
|
+
el.appendChild(input)
|
|
315
|
+
return el
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
getFormInputField (type) {
|
|
319
|
+
const el = document.createElement('input')
|
|
320
|
+
el.setAttribute('type', type)
|
|
321
|
+
return el
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
afterInputReady (input) {
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
getFormControl (label, input, description, infoText) {
|
|
329
|
+
const el = document.createElement('div')
|
|
330
|
+
el.classList.add('form-control')
|
|
331
|
+
if (label) el.appendChild(label)
|
|
332
|
+
if ((input.type === 'checkbox' || input.type === 'radio') && label) {
|
|
333
|
+
input.style.width = 'auto'
|
|
334
|
+
label.insertBefore(input, label.firstChild)
|
|
335
|
+
if (infoText) label.appendChild(infoText)
|
|
336
|
+
} else {
|
|
337
|
+
if (infoText && label) label.appendChild(infoText)
|
|
338
|
+
el.appendChild(input)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (description) el.appendChild(description)
|
|
342
|
+
return el
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
getIndentedPanel () {
|
|
346
|
+
const el = document.createElement('div')
|
|
347
|
+
el.classList.add('je-indented-panel')
|
|
348
|
+
return el
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
getTopIndentedPanel () {
|
|
352
|
+
const el = document.createElement('div')
|
|
353
|
+
el.classList.add('je-indented-panel--top')
|
|
354
|
+
return el
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
getChildEditorHolder () {
|
|
358
|
+
return document.createElement('div')
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
getDescription (text) {
|
|
362
|
+
const el = document.createElement('p')
|
|
363
|
+
if (window.DOMPurify) el.innerHTML = window.DOMPurify.sanitize(text)
|
|
364
|
+
else el.textContent = this.cleanText(text)
|
|
365
|
+
return el
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
getCheckboxDescription (text) {
|
|
369
|
+
return this.getDescription(text)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
getFormInputDescription (text) {
|
|
373
|
+
return this.getDescription(text)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
getButtonHolder () {
|
|
377
|
+
return document.createElement('span')
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
getHeaderButtonHolder () {
|
|
381
|
+
return this.getButtonHolder()
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
getFormButtonHolder (buttonAlign) {
|
|
385
|
+
return this.getButtonHolder()
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
getButton (text, icon, title) {
|
|
389
|
+
const el = document.createElement('button')
|
|
390
|
+
el.type = 'button'
|
|
391
|
+
this.setButtonText(el, text, icon, title)
|
|
392
|
+
return el
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
getFormButton (text, icon, title) {
|
|
396
|
+
return this.getButton(text, icon, title)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
setButtonText (button, text, icon, title) {
|
|
400
|
+
/* Clear previous contents. https://jsperf.com/innerhtml-vs-removechild/37 */
|
|
401
|
+
while (button.firstChild) {
|
|
402
|
+
button.removeChild(button.firstChild)
|
|
403
|
+
}
|
|
404
|
+
if (icon) {
|
|
405
|
+
button.appendChild(icon)
|
|
406
|
+
text = ` ${text}`
|
|
407
|
+
}
|
|
408
|
+
if (!this.jsoneditor.options.iconlib || !this.jsoneditor.options.remove_button_labels || !icon) {
|
|
409
|
+
const spanEl = document.createElement('span')
|
|
410
|
+
spanEl.appendChild(document.createTextNode(text))
|
|
411
|
+
button.appendChild(spanEl)
|
|
412
|
+
}
|
|
413
|
+
if (title) button.setAttribute('title', title)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
getTableContainer () {
|
|
417
|
+
return document.createElement('div')
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* Table functions */
|
|
421
|
+
getTable () {
|
|
422
|
+
return document.createElement('table')
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
getTableRow () {
|
|
426
|
+
return document.createElement('tr')
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
getTableHead () {
|
|
430
|
+
return document.createElement('thead')
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
getTableBody () {
|
|
434
|
+
return document.createElement('tbody')
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
getTableHeaderCell (text) {
|
|
438
|
+
const el = document.createElement('th')
|
|
439
|
+
el.textContent = text
|
|
440
|
+
return el
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
getTableCell () {
|
|
444
|
+
const el = document.createElement('td')
|
|
445
|
+
return el
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
getErrorMessage (text) {
|
|
449
|
+
const el = document.createElement('p')
|
|
450
|
+
el.style = el.style || {}
|
|
451
|
+
el.style.color = 'red'
|
|
452
|
+
el.appendChild(document.createTextNode(text))
|
|
453
|
+
return el
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
addInputError (input, text) {
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
removeInputError (input) {
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
addTableRowError (row) {
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
removeTableRowError (row) {
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
getTabHolder (propertyName) {
|
|
469
|
+
const pName = (typeof propertyName === 'undefined') ? '' : propertyName
|
|
470
|
+
const el = document.createElement('div')
|
|
471
|
+
el.innerHTML = `<div class='je-tabholder tabs'></div><div class='content' id='${pName}'></div><div class='je-tabholder--clear'></div>`
|
|
472
|
+
return el
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
getTopTabHolder (propertyName) {
|
|
476
|
+
const pName = (typeof propertyName === 'undefined') ? '' : propertyName
|
|
477
|
+
const el = document.createElement('div')
|
|
478
|
+
el.innerHTML = `<div class='tabs je-tabholder--top'></div><div class='je-tabholder--clear'></div><div class='content' id='${pName}'></div>`
|
|
479
|
+
return el
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
applyStyles (el, styles) {
|
|
483
|
+
Object.keys(styles).forEach(i => (el.style[i] = styles[i]))
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
closest (elem, selector) {
|
|
487
|
+
while (elem && elem !== document) {
|
|
488
|
+
if (elem[matchKey]) {
|
|
489
|
+
if (elem[matchKey](selector)) {
|
|
490
|
+
return elem
|
|
491
|
+
} else {
|
|
492
|
+
elem = elem.parentNode
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
return false
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return false
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
insertBasicTopTab (tab, newTabsHolder) {
|
|
502
|
+
newTabsHolder.firstChild.insertBefore(tab, newTabsHolder.firstChild.firstChild)
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
getTab (span, tabId) {
|
|
506
|
+
const el = document.createElement('div')
|
|
507
|
+
el.appendChild(span)
|
|
508
|
+
el.id = tabId
|
|
509
|
+
el.classList.add('je-tab')
|
|
510
|
+
return el
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
getTopTab (span, tabId) {
|
|
514
|
+
const el = document.createElement('div')
|
|
515
|
+
el.appendChild(span)
|
|
516
|
+
el.id = tabId
|
|
517
|
+
el.classList.add('je-tab--top')
|
|
518
|
+
return el
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
getTabContentHolder (tabHolder) {
|
|
522
|
+
return tabHolder.children[1]
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
getTopTabContentHolder (tabHolder) {
|
|
526
|
+
return tabHolder.children[1]
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
getTabContent () {
|
|
530
|
+
return this.getIndentedPanel()
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
getTopTabContent () {
|
|
534
|
+
return this.getTopIndentedPanel()
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
markTabActive (row) {
|
|
538
|
+
this.applyStyles(row.tab, {
|
|
539
|
+
opacity: 1,
|
|
540
|
+
background: 'white'
|
|
541
|
+
})
|
|
542
|
+
if (typeof row.rowPane !== 'undefined') {
|
|
543
|
+
row.rowPane.style.display = ''
|
|
544
|
+
} else {
|
|
545
|
+
row.container.style.display = ''
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
markTabInactive (row) {
|
|
550
|
+
this.applyStyles(row.tab, {
|
|
551
|
+
opacity: 0.5,
|
|
552
|
+
background: ''
|
|
553
|
+
})
|
|
554
|
+
if (typeof row.rowPane !== 'undefined') {
|
|
555
|
+
row.rowPane.style.display = 'none'
|
|
556
|
+
} else {
|
|
557
|
+
row.container.style.display = 'none'
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
addTab (holder, tab) {
|
|
562
|
+
holder.children[0].appendChild(tab)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
addTopTab (holder, tab) {
|
|
566
|
+
holder.children[0].appendChild(tab)
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
getBlockLink () {
|
|
570
|
+
const link = document.createElement('a')
|
|
571
|
+
link.classList.add('je-block-link')
|
|
572
|
+
return link
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
getBlockLinkHolder () {
|
|
576
|
+
const el = document.createElement('div')
|
|
577
|
+
return el
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
getLinksHolder () {
|
|
581
|
+
const el = document.createElement('div')
|
|
582
|
+
return el
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
createMediaLink (holder, link, media) {
|
|
586
|
+
holder.appendChild(link)
|
|
587
|
+
media.classList.add('je-media')
|
|
588
|
+
holder.appendChild(media)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
createImageLink (holder, link, image) {
|
|
592
|
+
holder.appendChild(link)
|
|
593
|
+
link.appendChild(image)
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
getFirstTab (holder) {
|
|
597
|
+
return holder.firstChild.firstChild
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
getInputGroup (input, buttons) {
|
|
601
|
+
return undefined
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
cleanText (txt) {
|
|
605
|
+
/* Clean out HTML tags from txt */
|
|
606
|
+
const tmp = document.createElement('div')
|
|
607
|
+
tmp.innerHTML = txt
|
|
608
|
+
return (tmp.textContent || tmp.innerText)
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
getDropZone (text) {
|
|
612
|
+
const el = document.createElement('div')
|
|
613
|
+
el.setAttribute('data-text', text)
|
|
614
|
+
el.classList.add('je-dropzone')
|
|
615
|
+
return el
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/* file is an object with properties: name, type, mimeType, size amd formattedSize */
|
|
619
|
+
getUploadPreview (file, uploadButton, data) {
|
|
620
|
+
const preview = document.createElement('div')
|
|
621
|
+
preview.classList.add('je-upload-preview')
|
|
622
|
+
|
|
623
|
+
if (file.mimeType.substr(0, 5) === 'image') {
|
|
624
|
+
const img = document.createElement('img')
|
|
625
|
+
img.src = data
|
|
626
|
+
preview.appendChild(img)
|
|
627
|
+
}
|
|
628
|
+
const info = document.createElement('div')
|
|
629
|
+
info.innerHTML += `<strong>Name:</strong> ${file.name}<br><strong>Type:</strong> ${file.type}<br><strong>Size:</strong> ${file.formattedSize}`
|
|
630
|
+
preview.appendChild(info)
|
|
631
|
+
|
|
632
|
+
preview.appendChild(uploadButton)
|
|
633
|
+
|
|
634
|
+
const clear = document.createElement('div')
|
|
635
|
+
clear.style.clear = 'left'
|
|
636
|
+
preview.appendChild(clear)
|
|
637
|
+
|
|
638
|
+
return preview
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
getProgressBar () {
|
|
642
|
+
const max = 100; const start = 0
|
|
643
|
+
|
|
644
|
+
const progressBar = document.createElement('progress')
|
|
645
|
+
progressBar.setAttribute('max', max)
|
|
646
|
+
progressBar.setAttribute('value', start)
|
|
647
|
+
return progressBar
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
updateProgressBar (progressBar, progress) {
|
|
651
|
+
if (!progressBar) return
|
|
652
|
+
progressBar.setAttribute('value', progress)
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
updateProgressBarUnknown (progressBar) {
|
|
656
|
+
if (!progressBar) return
|
|
657
|
+
progressBar.removeAttribute('value')
|
|
658
|
+
}
|
|
659
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* Upload Editor preview image */
|
|
2
|
+
|
|
3
|
+
.je-upload-preview img {
|
|
4
|
+
float: left;
|
|
5
|
+
margin: 0 0.5rem 0.5rem 0;
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
max-height: 5rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.je-dropzone {
|
|
11
|
+
position: relative;
|
|
12
|
+
margin: 0.5rem 0;
|
|
13
|
+
border: 2px dashed black;
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 60px;
|
|
16
|
+
background: teal;
|
|
17
|
+
transition: all 0.5s;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.je-dropzone:before {
|
|
21
|
+
position: absolute;
|
|
22
|
+
content: attr(data-text);
|
|
23
|
+
color: rgba(0, 0, 0, 0.6);
|
|
24
|
+
left: 50%;
|
|
25
|
+
top: 50%;
|
|
26
|
+
transform: translate(-50%, -50%);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.je-dropzone.valid-dropzone {
|
|
30
|
+
background: green;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.je-dropzone.invalid-dropzone {
|
|
34
|
+
background: red;
|
|
35
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {".je-upload-preview img":"float:left;margin:0%200.5rem%200.5rem%200;max-width:100%25;max-height:5rem",".je-dropzone":"position:relative;margin:0.5rem%200;border:2px%20dashed%20black;width:100%25;height:60px;background:teal;transition:all%200.5s",".je-dropzone:before":"position:absolute;content:attr(data-text);color:rgba(0%2C%200%2C%200%2C%200.6);left:50%25;top:50%25;transform:translate(-50%25%2C%20-50%25)",".je-dropzone.valid-dropzone":"background:green",".je-dropzone.invalid-dropzone":"background:red"}
|
|
3
|
+
/* eslint-enable */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AbstractTheme } from '../theme.js'
|
|
2
|
+
import rules from './barebones.css.js'
|
|
3
|
+
|
|
4
|
+
export class barebonesTheme extends AbstractTheme {
|
|
5
|
+
addInputError (input, text) {
|
|
6
|
+
if (!input.errmsg) {
|
|
7
|
+
const group = this.closest(input, '.form-control')
|
|
8
|
+
input.errmsg = document.createElement('div')
|
|
9
|
+
input.errmsg.setAttribute('class', 'errmsg')
|
|
10
|
+
group.appendChild(input.errmsg)
|
|
11
|
+
} else {
|
|
12
|
+
input.errmsg.style.display = 'block'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
input.errmsg.innerHTML = ''
|
|
16
|
+
input.errmsg.appendChild(document.createTextNode(text))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
removeInputError (input) {
|
|
20
|
+
if (input.style) {
|
|
21
|
+
input.style.borderColor = ''
|
|
22
|
+
}
|
|
23
|
+
if (input.errmsg) input.errmsg.style.display = 'none'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Custom stylesheet rules. format: "selector" : "CSS rules" */
|
|
28
|
+
barebonesTheme.rules = rules
|