jedison 1.21.1 → 1.22.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/CHANGELOG.md +10 -0
- package/README.md +20 -9
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +45 -9
- 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 +8 -6
package/dist/esm/jedison.js
CHANGED
|
@@ -2213,6 +2213,7 @@ class Editor {
|
|
|
2213
2213
|
this.title = null;
|
|
2214
2214
|
this.description = null;
|
|
2215
2215
|
this.storedEventListeners = [];
|
|
2216
|
+
this.schemaButtonListeners = [];
|
|
2216
2217
|
this.init();
|
|
2217
2218
|
this.build();
|
|
2218
2219
|
this.setAttributes();
|
|
@@ -2314,8 +2315,9 @@ class Editor {
|
|
|
2314
2315
|
* `jedison.on('jedison:<name>', ({ jedison, editor, path }) => ...)`. The
|
|
2315
2316
|
* listener map is private to the instance, so the payload is not exposed to
|
|
2316
2317
|
* unrelated scripts on the page (F3 contained).
|
|
2317
|
-
* - Click listeners are registered through
|
|
2318
|
-
* cleans them up
|
|
2318
|
+
* - Click listeners are registered through schemaButtonListeners so
|
|
2319
|
+
* destroy() cleans them up, without being cleared by an editor's
|
|
2320
|
+
* refreshUI() in the meantime (issue #79).
|
|
2319
2321
|
*/
|
|
2320
2322
|
appendSchemaButtons() {
|
|
2321
2323
|
const buttons = getSchemaXOption(this.instance.schema, "buttons");
|
|
@@ -2345,7 +2347,7 @@ class Editor {
|
|
|
2345
2347
|
});
|
|
2346
2348
|
};
|
|
2347
2349
|
button.addEventListener("click", handler);
|
|
2348
|
-
this.
|
|
2350
|
+
this.schemaButtonListeners.push({
|
|
2349
2351
|
element: button,
|
|
2350
2352
|
eventType: "click",
|
|
2351
2353
|
handler
|
|
@@ -2426,6 +2428,22 @@ class Editor {
|
|
|
2426
2428
|
}
|
|
2427
2429
|
this.storedEventListeners = [];
|
|
2428
2430
|
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Clears the click listeners registered by appendSchemaButtons(). Separate
|
|
2433
|
+
* from clearStoredEventListeners() so editors that clear the latter on
|
|
2434
|
+
* every refreshUI() (e.g. EditorArrayNav) don't also detach the schema
|
|
2435
|
+
* buttons, which are only ever appended once and never rebuilt (issue #79).
|
|
2436
|
+
*/
|
|
2437
|
+
clearSchemaButtonListeners() {
|
|
2438
|
+
if (this.schemaButtonListeners) {
|
|
2439
|
+
this.schemaButtonListeners.forEach((listener) => {
|
|
2440
|
+
if (listener.element && listener.handler) {
|
|
2441
|
+
listener.element.removeEventListener(listener.eventType || "click", listener.handler);
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
this.schemaButtonListeners = [];
|
|
2446
|
+
}
|
|
2429
2447
|
/**
|
|
2430
2448
|
* Shows validation error messages in the editor container.
|
|
2431
2449
|
*/
|
|
@@ -2671,6 +2689,7 @@ class Editor {
|
|
|
2671
2689
|
*/
|
|
2672
2690
|
destroy() {
|
|
2673
2691
|
this.clearStoredEventListeners();
|
|
2692
|
+
this.clearSchemaButtonListeners();
|
|
2674
2693
|
if (this.control.container && this.control.container.parentNode) {
|
|
2675
2694
|
this.control.container.parentNode.removeChild(this.control.container);
|
|
2676
2695
|
}
|
|
@@ -3110,8 +3129,19 @@ class InstanceObject extends Instance {
|
|
|
3110
3129
|
if (!isReq && isRecursive) {
|
|
3111
3130
|
musstCreateChild = false;
|
|
3112
3131
|
}
|
|
3132
|
+
const defaultProperties = getSchemaXOption(this.schema, "defaultProperties");
|
|
3133
|
+
const hasDefaultProperties = isArray(defaultProperties);
|
|
3134
|
+
const propertyDefaultProperty = getSchemaXOption(schema, "defaultProperty");
|
|
3135
|
+
const hasPropertyDefaultProperty = isSet(propertyDefaultProperty);
|
|
3136
|
+
const isDefaultProperty = hasPropertyDefaultProperty ? propertyDefaultProperty === true : hasDefaultProperties && defaultProperties.includes(key);
|
|
3137
|
+
if (!isReq && (hasDefaultProperties || hasPropertyDefaultProperty) && !isDefaultProperty) {
|
|
3138
|
+
musstCreateChild = false;
|
|
3139
|
+
}
|
|
3140
|
+
if (!isReq && !isRecursive && isDefaultProperty) {
|
|
3141
|
+
musstCreateChild = true;
|
|
3142
|
+
}
|
|
3113
3143
|
if (musstCreateChild) {
|
|
3114
|
-
this.createChild(schema, key, hasOwn(initialValue, key) ? initialValue[key] : void 0);
|
|
3144
|
+
this.createChild(schema, key, hasOwn(initialValue, key) ? initialValue[key] : void 0, isDefaultProperty);
|
|
3115
3145
|
}
|
|
3116
3146
|
});
|
|
3117
3147
|
}
|
|
@@ -3466,6 +3496,7 @@ const glyphicons = {
|
|
|
3466
3496
|
properties: "glyphicon glyphicon-list",
|
|
3467
3497
|
delete: "glyphicon glyphicon-trash",
|
|
3468
3498
|
add: "glyphicon glyphicon-plus",
|
|
3499
|
+
addProperty: "glyphicon glyphicon-plus-sign",
|
|
3469
3500
|
moveUp: "glyphicon glyphicon-arrow-up",
|
|
3470
3501
|
moveDown: "glyphicon glyphicon-arrow-down",
|
|
3471
3502
|
collapse: "glyphicon glyphicon-chevron-down",
|
|
@@ -3483,6 +3514,7 @@ const bootstrapIcons = {
|
|
|
3483
3514
|
properties: "bi bi-card-list",
|
|
3484
3515
|
delete: "bi bi-trash2",
|
|
3485
3516
|
add: "bi bi-plus",
|
|
3517
|
+
addProperty: "bi bi-plus-circle",
|
|
3486
3518
|
moveUp: "bi bi-arrow-up",
|
|
3487
3519
|
moveDown: "bi bi-arrow-down",
|
|
3488
3520
|
collapse: "bi bi-chevron-down",
|
|
@@ -3499,6 +3531,7 @@ const fontAwesome3 = {
|
|
|
3499
3531
|
properties: "icon-list",
|
|
3500
3532
|
delete: "icon-trash",
|
|
3501
3533
|
add: "icon-plus",
|
|
3534
|
+
addProperty: "icon-plus-sign",
|
|
3502
3535
|
moveUp: "icon-arrow-up",
|
|
3503
3536
|
moveDown: "icon-arrow-down",
|
|
3504
3537
|
collapse: "icon-chevron-down",
|
|
@@ -3515,6 +3548,7 @@ const fontAwesome4 = {
|
|
|
3515
3548
|
properties: "fa fa-list",
|
|
3516
3549
|
delete: "fa fa-trash-o",
|
|
3517
3550
|
add: "fa fa-plus",
|
|
3551
|
+
addProperty: "fa fa-plus-circle",
|
|
3518
3552
|
moveUp: "fa fa-arrow-up",
|
|
3519
3553
|
moveDown: "fa fa-arrow-down",
|
|
3520
3554
|
collapse: "fa fa-chevron-down",
|
|
@@ -3531,6 +3565,7 @@ const fontAwesome5 = {
|
|
|
3531
3565
|
properties: "fas fa-list",
|
|
3532
3566
|
delete: "fas fa-trash",
|
|
3533
3567
|
add: "fas fa-plus",
|
|
3568
|
+
addProperty: "fas fa-plus-circle",
|
|
3534
3569
|
moveUp: "fas fa-arrow-up",
|
|
3535
3570
|
moveDown: "fas fa-arrow-down",
|
|
3536
3571
|
collapse: "fas fa-chevron-down",
|
|
@@ -3547,6 +3582,7 @@ const fontAwesome6 = {
|
|
|
3547
3582
|
properties: "fa-solid fa-list",
|
|
3548
3583
|
delete: "fa-solid fa-trash",
|
|
3549
3584
|
add: "fa-solid fa-plus",
|
|
3585
|
+
addProperty: "fa-solid fa-circle-plus",
|
|
3550
3586
|
moveUp: "fa-solid fa-arrow-up",
|
|
3551
3587
|
moveDown: "fa-solid fa-arrow-down",
|
|
3552
3588
|
collapse: "fa-solid fa-chevron-down",
|
|
@@ -7462,7 +7498,7 @@ class JsonWalker {
|
|
|
7462
7498
|
}
|
|
7463
7499
|
}
|
|
7464
7500
|
}
|
|
7465
|
-
const version = "1.
|
|
7501
|
+
const version = "1.22.1";
|
|
7466
7502
|
class Jedison extends EventEmitter {
|
|
7467
7503
|
/**
|
|
7468
7504
|
* Creates a Jedison instance.
|
|
@@ -9007,11 +9043,11 @@ class Theme {
|
|
|
9007
9043
|
});
|
|
9008
9044
|
const quickAddPropertyBtn = this.getAddPropertyButton({
|
|
9009
9045
|
content: config.addPropertyContent,
|
|
9010
|
-
icon: "
|
|
9046
|
+
icon: "addProperty"
|
|
9011
9047
|
});
|
|
9012
9048
|
const quickAddPropertyToggle = this.getQuickAddPropertyToggle({
|
|
9013
9049
|
content: config.addPropertyContent,
|
|
9014
|
-
icon: "
|
|
9050
|
+
icon: "addProperty",
|
|
9015
9051
|
propertiesContainer: quickAddPropertyContainer
|
|
9016
9052
|
});
|
|
9017
9053
|
const fieldset = this.getFieldset();
|
|
@@ -9124,10 +9160,10 @@ class Theme {
|
|
|
9124
9160
|
id: "jedi-quick-add-property-input-" + config.id,
|
|
9125
9161
|
title: config.addPropertyContent
|
|
9126
9162
|
});
|
|
9127
|
-
const quickAddPropertyBtn = this.getAddPropertyButton({ content: config.addPropertyContent, icon: "
|
|
9163
|
+
const quickAddPropertyBtn = this.getAddPropertyButton({ content: config.addPropertyContent, icon: "addProperty" });
|
|
9128
9164
|
const quickAddPropertyToggle = this.getQuickAddPropertyToggle({
|
|
9129
9165
|
content: config.addPropertyContent,
|
|
9130
|
-
icon: "
|
|
9166
|
+
icon: "addProperty",
|
|
9131
9167
|
propertiesContainer: quickAddPropertyContainer
|
|
9132
9168
|
});
|
|
9133
9169
|
const collapse = document.createElement("div");
|