jedison 1.20.0 → 1.20.2
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 +8 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +39 -7
- 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 +1 -1
package/dist/esm/jedison.js
CHANGED
|
@@ -1721,6 +1721,10 @@ class Validator {
|
|
|
1721
1721
|
constructor(config = {}) {
|
|
1722
1722
|
this.refParser = config.refParser;
|
|
1723
1723
|
this.constraints = config.constraints ?? {};
|
|
1724
|
+
if (isArray(this.constraints)) {
|
|
1725
|
+
console.warn('Jedison: option "constraints" must be an object keyed by constraint name, not an array. Ignoring the value.');
|
|
1726
|
+
this.constraints = {};
|
|
1727
|
+
}
|
|
1724
1728
|
this.assertFormat = config.assertFormat ? config.assertFormat : false;
|
|
1725
1729
|
this.translator = config.translator ? config.translator : false;
|
|
1726
1730
|
this.subErrors = config.subErrors ?? false;
|
|
@@ -1906,6 +1910,10 @@ class Instance extends EventEmitter {
|
|
|
1906
1910
|
setUI() {
|
|
1907
1911
|
if (this.jedison.isEditor) {
|
|
1908
1912
|
const EditorClass = this.jedison.uiResolver.getClass(this.schema);
|
|
1913
|
+
if (!EditorClass) {
|
|
1914
|
+
console.error(`Jedison: no editor could be resolved for the schema at "${this.path}". The field will not be rendered.`, this.schema);
|
|
1915
|
+
return;
|
|
1916
|
+
}
|
|
1909
1917
|
this.ui = new EditorClass(this);
|
|
1910
1918
|
}
|
|
1911
1919
|
}
|
|
@@ -2228,6 +2236,8 @@ class Editor {
|
|
|
2228
2236
|
this.theme = this.instance.jedison.theme;
|
|
2229
2237
|
this.markdownEnabled = getSchemaXOption(this.instance.schema, "parseMarkdown") ?? this.instance.jedison.getOption("parseMarkdown");
|
|
2230
2238
|
this.purifyEnabled = getSchemaXOption(this.instance.schema, "purifyHtml") ?? this.instance.jedison.getOption("purifyHtml");
|
|
2239
|
+
this.markdownCache = /* @__PURE__ */ new Map();
|
|
2240
|
+
this.purifyCache = /* @__PURE__ */ new Map();
|
|
2231
2241
|
}
|
|
2232
2242
|
/**
|
|
2233
2243
|
* Gets the JSON Pointer level by counting how many "/" it has
|
|
@@ -2462,7 +2472,13 @@ class Editor {
|
|
|
2462
2472
|
*/
|
|
2463
2473
|
purifyContent(content, domPurifyOptions) {
|
|
2464
2474
|
if (this.instance.jedison.getOption("purifyHtml") && typeof window !== "undefined" && window.DOMPurify) {
|
|
2465
|
-
|
|
2475
|
+
const cacheKey = JSON.stringify([content, domPurifyOptions]);
|
|
2476
|
+
if (this.purifyCache.has(cacheKey)) {
|
|
2477
|
+
return this.purifyCache.get(cacheKey);
|
|
2478
|
+
}
|
|
2479
|
+
const clean = window.DOMPurify.sanitize(content, domPurifyOptions);
|
|
2480
|
+
this.purifyCache.set(cacheKey, clean);
|
|
2481
|
+
return clean;
|
|
2466
2482
|
} else {
|
|
2467
2483
|
const tmp = document.createElement("div");
|
|
2468
2484
|
tmp.innerHTML = content;
|
|
@@ -2470,7 +2486,12 @@ class Editor {
|
|
|
2470
2486
|
}
|
|
2471
2487
|
}
|
|
2472
2488
|
getHtmlFromMarkdown(content) {
|
|
2473
|
-
|
|
2489
|
+
if (this.markdownCache.has(content)) {
|
|
2490
|
+
return this.markdownCache.get(content);
|
|
2491
|
+
}
|
|
2492
|
+
const html = window.marked.parse(content);
|
|
2493
|
+
this.markdownCache.set(content, html);
|
|
2494
|
+
return html;
|
|
2474
2495
|
}
|
|
2475
2496
|
getTitle() {
|
|
2476
2497
|
let titleFromSchema = false;
|
|
@@ -7104,13 +7125,21 @@ class UiResolver {
|
|
|
7104
7125
|
}
|
|
7105
7126
|
getClass(schema) {
|
|
7106
7127
|
for (const editor of this.customEditors) {
|
|
7107
|
-
|
|
7108
|
-
|
|
7128
|
+
try {
|
|
7129
|
+
if (editor.resolves(schema, this.refParser)) {
|
|
7130
|
+
return editor;
|
|
7131
|
+
}
|
|
7132
|
+
} catch (e) {
|
|
7133
|
+
console.error(`Editor "${editor.name || "custom editor"}" threw while resolving the schema and will be skipped.`, e);
|
|
7109
7134
|
}
|
|
7110
7135
|
}
|
|
7111
7136
|
for (const editor of this.editors) {
|
|
7112
|
-
|
|
7113
|
-
|
|
7137
|
+
try {
|
|
7138
|
+
if (editor.resolves(schema, this.refParser)) {
|
|
7139
|
+
return editor;
|
|
7140
|
+
}
|
|
7141
|
+
} catch (e) {
|
|
7142
|
+
console.error(`Editor "${editor.name || "built-in editor"}" threw while resolving the schema and will be skipped.`, e);
|
|
7114
7143
|
}
|
|
7115
7144
|
}
|
|
7116
7145
|
return null;
|
|
@@ -7396,6 +7425,7 @@ class JsonWalker {
|
|
|
7396
7425
|
}
|
|
7397
7426
|
}
|
|
7398
7427
|
}
|
|
7428
|
+
const version = "1.20.1";
|
|
7399
7429
|
class Jedison extends EventEmitter {
|
|
7400
7430
|
/**
|
|
7401
7431
|
* Creates a Jedison instance.
|
|
@@ -7436,7 +7466,7 @@ class Jedison extends EventEmitter {
|
|
|
7436
7466
|
data: void 0,
|
|
7437
7467
|
assertFormat: false,
|
|
7438
7468
|
customEditors: [],
|
|
7439
|
-
constraints:
|
|
7469
|
+
constraints: {},
|
|
7440
7470
|
hiddenInputAttributes: {},
|
|
7441
7471
|
id: "",
|
|
7442
7472
|
radiosInline: false,
|
|
@@ -7915,6 +7945,7 @@ class Jedison extends EventEmitter {
|
|
|
7915
7945
|
});
|
|
7916
7946
|
}
|
|
7917
7947
|
}
|
|
7948
|
+
Jedison.version = version;
|
|
7918
7949
|
class RefParser {
|
|
7919
7950
|
constructor(options = {}) {
|
|
7920
7951
|
this.options = Object.assign({
|
|
@@ -12132,6 +12163,7 @@ const index = {
|
|
|
12132
12163
|
ThemeBootstrap5,
|
|
12133
12164
|
RefParser,
|
|
12134
12165
|
Create: Jedison,
|
|
12166
|
+
version,
|
|
12135
12167
|
SchemaGenerator,
|
|
12136
12168
|
applyOverlay
|
|
12137
12169
|
};
|