jedison 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +174 -14
- package/dist/esm/jedison.js.map +1 -1
- package/dist/umd/jedison.umd.js +1 -1
- package/dist/umd/jedison.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/jedison.js
CHANGED
|
@@ -1930,6 +1930,7 @@ class Editor {
|
|
|
1930
1930
|
this.init();
|
|
1931
1931
|
this.build();
|
|
1932
1932
|
this.setAttributes();
|
|
1933
|
+
this.setReadOnlyAttribute();
|
|
1933
1934
|
this.addEventListeners();
|
|
1934
1935
|
this.setVisibility();
|
|
1935
1936
|
this.setContainerAttributes();
|
|
@@ -2009,6 +2010,14 @@ class Editor {
|
|
|
2009
2010
|
}
|
|
2010
2011
|
}
|
|
2011
2012
|
}
|
|
2013
|
+
setReadOnlyAttribute() {
|
|
2014
|
+
if (this.readOnly) {
|
|
2015
|
+
const inputElements = this.control.container.querySelectorAll("input, textarea, select");
|
|
2016
|
+
inputElements.forEach((element) => {
|
|
2017
|
+
element.setAttribute("always-disabled", "");
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2012
2021
|
getIdFromPath(path) {
|
|
2013
2022
|
const optionId = this.instance.jedison.options.id;
|
|
2014
2023
|
return optionId ? optionId + "-" + pathToAttribute(path) : pathToAttribute(path);
|
|
@@ -2901,7 +2910,9 @@ const glyphicons = {
|
|
|
2901
2910
|
// Expand set to plus
|
|
2902
2911
|
drag: "glyphicon glyphicon-th",
|
|
2903
2912
|
info: "glyphicon glyphicon-question-sign",
|
|
2904
|
-
close: "glyphicon glyphicon-remove"
|
|
2913
|
+
close: "glyphicon glyphicon-remove",
|
|
2914
|
+
edit: "glyphicon glyphicon-pencil",
|
|
2915
|
+
save: "glyphicon glyphicon-floppy-disk"
|
|
2905
2916
|
};
|
|
2906
2917
|
const bootstrapIcons = {
|
|
2907
2918
|
properties: "bi bi-card-list",
|
|
@@ -2913,7 +2924,9 @@ const bootstrapIcons = {
|
|
|
2913
2924
|
expand: "bi bi-plus",
|
|
2914
2925
|
drag: "bi bi-grip-vertical",
|
|
2915
2926
|
info: "bi bi-question-circle",
|
|
2916
|
-
close: "bi bi-x"
|
|
2927
|
+
close: "bi bi-x",
|
|
2928
|
+
edit: "bi bi-pencil",
|
|
2929
|
+
save: "bi bi-floppy"
|
|
2917
2930
|
};
|
|
2918
2931
|
const fontAwesome3 = {
|
|
2919
2932
|
properties: "icon-list",
|
|
@@ -2925,7 +2938,9 @@ const fontAwesome3 = {
|
|
|
2925
2938
|
expand: "icon-plus",
|
|
2926
2939
|
drag: "icon-th",
|
|
2927
2940
|
info: "icon-question-sign",
|
|
2928
|
-
close: "icon-remove"
|
|
2941
|
+
close: "icon-remove",
|
|
2942
|
+
edit: "icon-pencil",
|
|
2943
|
+
save: "icon-save"
|
|
2929
2944
|
};
|
|
2930
2945
|
const fontAwesome4 = {
|
|
2931
2946
|
properties: "fa fa-list",
|
|
@@ -2937,7 +2952,9 @@ const fontAwesome4 = {
|
|
|
2937
2952
|
expand: "fa fa-plus",
|
|
2938
2953
|
drag: "fa fa-th",
|
|
2939
2954
|
info: "fa fa-question-circle",
|
|
2940
|
-
close: "fa fa-times"
|
|
2955
|
+
close: "fa fa-times",
|
|
2956
|
+
edit: "fa fa-pencil",
|
|
2957
|
+
save: "fa fa-floppy-o"
|
|
2941
2958
|
};
|
|
2942
2959
|
const fontAwesome5 = {
|
|
2943
2960
|
properties: "fas fa-list",
|
|
@@ -2949,7 +2966,9 @@ const fontAwesome5 = {
|
|
|
2949
2966
|
expand: "fas fa-plus",
|
|
2950
2967
|
drag: "fas fa-grip-vertical",
|
|
2951
2968
|
info: "fas fa-question-circle",
|
|
2952
|
-
close: "fas fa-times"
|
|
2969
|
+
close: "fas fa-times",
|
|
2970
|
+
edit: "fas fa-pencil-alt",
|
|
2971
|
+
save: "fas fa-save"
|
|
2953
2972
|
};
|
|
2954
2973
|
const fontAwesome6 = {
|
|
2955
2974
|
properties: "fa-solid fa-list",
|
|
@@ -2961,7 +2980,9 @@ const fontAwesome6 = {
|
|
|
2961
2980
|
expand: "fa-solid fa-plus",
|
|
2962
2981
|
drag: "fa-solid fa-grip-vertical",
|
|
2963
2982
|
info: "fa-solid fa-circle-question",
|
|
2964
|
-
close: "fa-solid fa-xmark"
|
|
2983
|
+
close: "fa-solid fa-xmark",
|
|
2984
|
+
edit: "fa-solid fa-pencil",
|
|
2985
|
+
save: "fa-solid fa-floppy-disk"
|
|
2965
2986
|
};
|
|
2966
2987
|
class EditorBoolean extends Editor {
|
|
2967
2988
|
sanitize(value) {
|
|
@@ -3467,7 +3488,6 @@ class EditorObject extends Editor {
|
|
|
3467
3488
|
}
|
|
3468
3489
|
build() {
|
|
3469
3490
|
this.propertyActivators = {};
|
|
3470
|
-
const schemaOptions = this.instance.schema.options || {};
|
|
3471
3491
|
let addProperty = true;
|
|
3472
3492
|
const additionalProperties2 = getSchemaAdditionalProperties(this.instance.schema);
|
|
3473
3493
|
if (isSet(additionalProperties2) && additionalProperties2 === false) {
|
|
@@ -3477,8 +3497,9 @@ class EditorObject extends Editor {
|
|
|
3477
3497
|
if (isSet(this.instance.jedison.options.enablePropertiesToggle)) {
|
|
3478
3498
|
enablePropertiesToggle = this.instance.jedison.options.enablePropertiesToggle;
|
|
3479
3499
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3500
|
+
const schemaEnablePropertiesToggle = getSchemaXOption(this.instance.schema, "enablePropertiesToggle");
|
|
3501
|
+
if (isSet(schemaEnablePropertiesToggle)) {
|
|
3502
|
+
enablePropertiesToggle = schemaEnablePropertiesToggle;
|
|
3482
3503
|
}
|
|
3483
3504
|
this.control = this.theme.getObjectControl({
|
|
3484
3505
|
title: this.getTitle(),
|
|
@@ -3491,10 +3512,12 @@ class EditorObject extends Editor {
|
|
|
3491
3512
|
startCollapsed: getSchemaXOption(this.instance.schema, "startCollapsed") ?? this.instance.jedison.options.startCollapsed,
|
|
3492
3513
|
readOnly: this.instance.isReadOnly(),
|
|
3493
3514
|
info: this.getInfo(),
|
|
3515
|
+
editJsonData: getSchemaXOption(this.instance.schema, "editJsonData") ?? this.instance.jedison.options.editJsonData,
|
|
3494
3516
|
propertiesToggleContent: getSchemaXOption(this.instance.schema, "propertiesToggleContent") ?? this.instance.jedison.translator.translate("propertiesToggle"),
|
|
3495
3517
|
collapseToggleContent: getSchemaXOption(this.instance.schema, "collapseToggleContent") ?? this.instance.jedison.translator.translate("collapseToggle"),
|
|
3496
3518
|
addPropertyContent: getSchemaXOption(this.instance.schema, "addPropertyContent") ?? this.instance.jedison.translator.translate("objectAddProperty")
|
|
3497
3519
|
});
|
|
3520
|
+
this.control.jsonData.input.value = JSON.stringify(this.instance.getValue(), null, 2);
|
|
3498
3521
|
}
|
|
3499
3522
|
addEventListeners() {
|
|
3500
3523
|
this.control.addPropertyBtn.addEventListener("click", () => {
|
|
@@ -3521,6 +3544,18 @@ class EditorObject extends Editor {
|
|
|
3521
3544
|
this.control.propertiesContainer.close();
|
|
3522
3545
|
this.control.propertiesContainer.showModal();
|
|
3523
3546
|
});
|
|
3547
|
+
this.control.jsonData.saveBtn.addEventListener("click", () => {
|
|
3548
|
+
try {
|
|
3549
|
+
const inputValue = JSON.parse(this.control.jsonData.input.value);
|
|
3550
|
+
this.instance.setValue(inputValue, true, "user");
|
|
3551
|
+
this.control.jsonData.dialog.close();
|
|
3552
|
+
} catch (error) {
|
|
3553
|
+
alert("Invalid JSON");
|
|
3554
|
+
}
|
|
3555
|
+
});
|
|
3556
|
+
this.control.jsonData.toggle.addEventListener("click", () => {
|
|
3557
|
+
this.refreshJsonDataInputSize();
|
|
3558
|
+
});
|
|
3524
3559
|
}
|
|
3525
3560
|
sanitize(value) {
|
|
3526
3561
|
if (isObject(value)) {
|
|
@@ -3597,6 +3632,19 @@ class EditorObject extends Editor {
|
|
|
3597
3632
|
});
|
|
3598
3633
|
}
|
|
3599
3634
|
}
|
|
3635
|
+
refreshJsonDataInputSize() {
|
|
3636
|
+
const input = this.control.jsonData.input;
|
|
3637
|
+
input.style.height = "auto";
|
|
3638
|
+
input.style.height = input.scrollHeight + "px";
|
|
3639
|
+
setTimeout(() => {
|
|
3640
|
+
if (input) {
|
|
3641
|
+
input.scrollTop = 0;
|
|
3642
|
+
}
|
|
3643
|
+
});
|
|
3644
|
+
}
|
|
3645
|
+
refreshJsonData() {
|
|
3646
|
+
this.control.jsonData.input.value = JSON.stringify(this.instance.getValue(), null, 2);
|
|
3647
|
+
}
|
|
3600
3648
|
refreshEditors() {
|
|
3601
3649
|
while (this.control.childrenSlot.firstChild) {
|
|
3602
3650
|
this.control.childrenSlot.removeChild(this.control.childrenSlot.firstChild);
|
|
@@ -3638,6 +3686,7 @@ class EditorObject extends Editor {
|
|
|
3638
3686
|
super.refreshUI();
|
|
3639
3687
|
this.refreshPropertiesSlot();
|
|
3640
3688
|
this.refreshEditors();
|
|
3689
|
+
this.refreshJsonData();
|
|
3641
3690
|
}
|
|
3642
3691
|
}
|
|
3643
3692
|
class EditorObjectGrid extends EditorObject {
|
|
@@ -3699,8 +3748,8 @@ class EditorObjectNav extends EditorObject {
|
|
|
3699
3748
|
const columns = formatParts[2];
|
|
3700
3749
|
const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
|
|
3701
3750
|
const row = this.theme.getRow();
|
|
3702
|
-
const tabListCol = this.theme.getCol(12, navColumns);
|
|
3703
|
-
const tabContentCol = this.theme.getCol(12, 12 - navColumns);
|
|
3751
|
+
const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
|
|
3752
|
+
const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
|
|
3704
3753
|
const tabContent = this.theme.getTabContent();
|
|
3705
3754
|
const tabList = this.theme.getTabList({
|
|
3706
3755
|
variant
|
|
@@ -4214,8 +4263,8 @@ class EditorArrayNav extends EditorArray {
|
|
|
4214
4263
|
const columns = formatParts[2];
|
|
4215
4264
|
const navColumns = variant === "horizontal" ? 12 : columns ?? 4;
|
|
4216
4265
|
const row = this.theme.getRow();
|
|
4217
|
-
const tabListCol = this.theme.getCol(12, navColumns);
|
|
4218
|
-
const tabContentCol = this.theme.getCol(12, 12 - navColumns);
|
|
4266
|
+
const tabListCol = this.theme.getCol(12, 12, navColumns, navColumns);
|
|
4267
|
+
const tabContentCol = this.theme.getCol(12, 12, 12 - navColumns, 12 - navColumns);
|
|
4219
4268
|
const tabContent = this.theme.getTabContent();
|
|
4220
4269
|
const tabList = this.theme.getTabList({
|
|
4221
4270
|
variant
|
|
@@ -4463,7 +4512,29 @@ class EditorStringJodit extends EditorString {
|
|
|
4463
4512
|
info: this.getInfo()
|
|
4464
4513
|
});
|
|
4465
4514
|
try {
|
|
4466
|
-
const
|
|
4515
|
+
const joditDefaultOptions = {
|
|
4516
|
+
showCharsCounter: false,
|
|
4517
|
+
showWordsCounter: false,
|
|
4518
|
+
showXPathInStatusbar: false,
|
|
4519
|
+
toolbarAdaptive: false,
|
|
4520
|
+
buttons: [
|
|
4521
|
+
"bold",
|
|
4522
|
+
"italic",
|
|
4523
|
+
"underline",
|
|
4524
|
+
"strikethrough",
|
|
4525
|
+
"|",
|
|
4526
|
+
"ul",
|
|
4527
|
+
"ol",
|
|
4528
|
+
"|",
|
|
4529
|
+
"link",
|
|
4530
|
+
"|",
|
|
4531
|
+
"source",
|
|
4532
|
+
"preview"
|
|
4533
|
+
]
|
|
4534
|
+
};
|
|
4535
|
+
const joditSchemaOptions = getSchemaXOption(this.instance.schema, "jodit") ?? {};
|
|
4536
|
+
const joditOptions = Object.assign({}, joditDefaultOptions, joditSchemaOptions);
|
|
4537
|
+
console.log("joditOptions", joditOptions, getSchemaXOption(this.instance.schema, "jodit"));
|
|
4467
4538
|
this.jodit = window.Jodit.make(this.control.input, joditOptions);
|
|
4468
4539
|
} catch (e) {
|
|
4469
4540
|
console.error("Jodit is not available or not loaded correctly.", e);
|
|
@@ -5132,6 +5203,7 @@ class Jedison extends EventEmitter {
|
|
|
5132
5203
|
iconLib: null,
|
|
5133
5204
|
theme: null,
|
|
5134
5205
|
refParser: null,
|
|
5206
|
+
editJsonData: false,
|
|
5135
5207
|
enablePropertiesToggle: false,
|
|
5136
5208
|
enableCollapseToggle: false,
|
|
5137
5209
|
btnContents: true,
|
|
@@ -6063,6 +6135,60 @@ class Theme {
|
|
|
6063
6135
|
});
|
|
6064
6136
|
return html;
|
|
6065
6137
|
}
|
|
6138
|
+
/**
|
|
6139
|
+
* Container for properties editing elements like property activators
|
|
6140
|
+
*/
|
|
6141
|
+
getJsonData(config) {
|
|
6142
|
+
const dialog = document.createElement("dialog");
|
|
6143
|
+
dialog.classList.add("jedi-json-data");
|
|
6144
|
+
dialog.setAttribute("id", config.id);
|
|
6145
|
+
window.addEventListener("click", (event) => {
|
|
6146
|
+
if (event.target === dialog) {
|
|
6147
|
+
dialog.close();
|
|
6148
|
+
}
|
|
6149
|
+
});
|
|
6150
|
+
const toggle = this.getButton({
|
|
6151
|
+
// content: config.propertiesToggleContent, // todo: use text config or something
|
|
6152
|
+
id: "jedi-json-data-toggle-" + config.id,
|
|
6153
|
+
icon: "edit"
|
|
6154
|
+
});
|
|
6155
|
+
toggle.classList.add("jedi-json-data-toggle");
|
|
6156
|
+
toggle.addEventListener("click", () => {
|
|
6157
|
+
if (dialog.open) {
|
|
6158
|
+
dialog.close();
|
|
6159
|
+
} else {
|
|
6160
|
+
dialog.showModal();
|
|
6161
|
+
}
|
|
6162
|
+
});
|
|
6163
|
+
const control = document.createElement("div");
|
|
6164
|
+
const { label } = this.getLabel({
|
|
6165
|
+
for: "json-data-input-" + config.id,
|
|
6166
|
+
text: "JSON Data"
|
|
6167
|
+
});
|
|
6168
|
+
const input = document.createElement("textarea");
|
|
6169
|
+
input.setAttribute("id", "json-data-input-" + config.id);
|
|
6170
|
+
input.cols = 60;
|
|
6171
|
+
input.style.whiteSpace = "pre";
|
|
6172
|
+
input.style.overflowX = "auto";
|
|
6173
|
+
input.style.resize = "both";
|
|
6174
|
+
input.style.maxHeight = "60vh";
|
|
6175
|
+
const saveBtn = this.getButton({
|
|
6176
|
+
// content: config.propertiesToggleContent, // todo: use text config or something
|
|
6177
|
+
id: "jedi-json-data-save-" + config.id,
|
|
6178
|
+
icon: "save"
|
|
6179
|
+
});
|
|
6180
|
+
dialog.appendChild(control);
|
|
6181
|
+
control.appendChild(label);
|
|
6182
|
+
control.appendChild(input);
|
|
6183
|
+
dialog.appendChild(saveBtn);
|
|
6184
|
+
return {
|
|
6185
|
+
dialog,
|
|
6186
|
+
toggle,
|
|
6187
|
+
control,
|
|
6188
|
+
input,
|
|
6189
|
+
saveBtn
|
|
6190
|
+
};
|
|
6191
|
+
}
|
|
6066
6192
|
/**
|
|
6067
6193
|
* Container for screen reader announced messages
|
|
6068
6194
|
*/
|
|
@@ -6337,6 +6463,9 @@ class Theme {
|
|
|
6337
6463
|
const description = this.getDescription({
|
|
6338
6464
|
content: config.description
|
|
6339
6465
|
});
|
|
6466
|
+
const jsonData = this.getJsonData({
|
|
6467
|
+
id: "json-data-" + config.id
|
|
6468
|
+
});
|
|
6340
6469
|
const propertiesContainer = this.getPropertiesSlot({
|
|
6341
6470
|
id: "properties-slot-" + config.id
|
|
6342
6471
|
});
|
|
@@ -6379,6 +6508,9 @@ class Theme {
|
|
|
6379
6508
|
addPropertyBtn.classList.add("jedi-object-add");
|
|
6380
6509
|
container.appendChild(fieldset);
|
|
6381
6510
|
container.appendChild(propertiesContainer);
|
|
6511
|
+
if (config.editJsonData) {
|
|
6512
|
+
container.appendChild(jsonData.dialog);
|
|
6513
|
+
}
|
|
6382
6514
|
fieldset.appendChild(legend);
|
|
6383
6515
|
if (isObject(config.info)) {
|
|
6384
6516
|
infoContainer.appendChild(info.container);
|
|
@@ -6398,6 +6530,9 @@ class Theme {
|
|
|
6398
6530
|
propertiesContainer.appendChild(addPropertyBtn);
|
|
6399
6531
|
propertiesContainer.appendChild(document.createElement("hr"));
|
|
6400
6532
|
}
|
|
6533
|
+
if (config.editJsonData) {
|
|
6534
|
+
actions.appendChild(jsonData.toggle);
|
|
6535
|
+
}
|
|
6401
6536
|
if (config.enablePropertiesToggle) {
|
|
6402
6537
|
actions.appendChild(propertiesToggle);
|
|
6403
6538
|
propertiesContainer.appendChild(ariaLive);
|
|
@@ -6416,6 +6551,7 @@ class Theme {
|
|
|
6416
6551
|
messages,
|
|
6417
6552
|
childrenSlot,
|
|
6418
6553
|
propertiesToggle,
|
|
6554
|
+
jsonData,
|
|
6419
6555
|
propertiesContainer,
|
|
6420
6556
|
addPropertyControl,
|
|
6421
6557
|
addPropertyBtn,
|
|
@@ -7212,6 +7348,14 @@ class ThemeBootstrap3 extends Theme {
|
|
|
7212
7348
|
}
|
|
7213
7349
|
return collapse;
|
|
7214
7350
|
}
|
|
7351
|
+
getJsonData(config) {
|
|
7352
|
+
const jsonData = super.getJsonData(config);
|
|
7353
|
+
jsonData.control.classList.add("form-group");
|
|
7354
|
+
jsonData.input.classList.add("form-control");
|
|
7355
|
+
jsonData.saveBtn.classList.add("btn-primary");
|
|
7356
|
+
jsonData.saveBtn.classList.add("btn-block");
|
|
7357
|
+
return jsonData;
|
|
7358
|
+
}
|
|
7215
7359
|
getFieldset() {
|
|
7216
7360
|
const fieldset = super.getFieldset();
|
|
7217
7361
|
fieldset.classList.add("panel");
|
|
@@ -7547,6 +7691,14 @@ class ThemeBootstrap4 extends Theme {
|
|
|
7547
7691
|
}
|
|
7548
7692
|
return collapse;
|
|
7549
7693
|
}
|
|
7694
|
+
getJsonData(config) {
|
|
7695
|
+
const jsonData = super.getJsonData(config);
|
|
7696
|
+
jsonData.control.classList.add("form-group");
|
|
7697
|
+
jsonData.input.classList.add("form-control");
|
|
7698
|
+
jsonData.saveBtn.classList.add("btn-primary");
|
|
7699
|
+
jsonData.saveBtn.classList.add("btn-block");
|
|
7700
|
+
return jsonData;
|
|
7701
|
+
}
|
|
7550
7702
|
getFieldset() {
|
|
7551
7703
|
const fieldset = document.createElement("fieldset");
|
|
7552
7704
|
fieldset.setAttribute("role", "group");
|
|
@@ -7906,6 +8058,14 @@ class ThemeBootstrap5 extends Theme {
|
|
|
7906
8058
|
}
|
|
7907
8059
|
return collapse;
|
|
7908
8060
|
}
|
|
8061
|
+
getJsonData(config) {
|
|
8062
|
+
const jsonData = super.getJsonData(config);
|
|
8063
|
+
jsonData.control.classList.add("mb-3");
|
|
8064
|
+
jsonData.input.classList.add("form-control");
|
|
8065
|
+
jsonData.saveBtn.classList.add("btn-primary");
|
|
8066
|
+
jsonData.saveBtn.classList.add("w-100");
|
|
8067
|
+
return jsonData;
|
|
8068
|
+
}
|
|
7909
8069
|
getFieldset() {
|
|
7910
8070
|
const fieldset = document.createElement("fieldset");
|
|
7911
8071
|
fieldset.setAttribute("role", "group");
|