jedison 0.3.24 → 0.3.25
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 +4 -0
- package/dist/cjs/jedison.cjs +1 -1
- package/dist/cjs/jedison.cjs.map +1 -1
- package/dist/esm/jedison.js +15 -4
- 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 +4 -3
package/dist/esm/jedison.js
CHANGED
|
@@ -1809,17 +1809,28 @@ class Instance extends EventEmitter {
|
|
|
1809
1809
|
/**
|
|
1810
1810
|
* Returns the data that will replace placeholders in titles, descriptions (e.g. "{{ i1 }} {{ value.title }}")
|
|
1811
1811
|
*/
|
|
1812
|
-
getTemplateData() {
|
|
1812
|
+
getTemplateData(template) {
|
|
1813
1813
|
const templateData = {
|
|
1814
1814
|
...this.arrayTemplateData,
|
|
1815
1815
|
value: this.getValue(),
|
|
1816
1816
|
settings: this.jedison.options.settings
|
|
1817
1817
|
};
|
|
1818
|
+
if (template == null ? void 0 : template.includes("{{ functions.")) {
|
|
1819
|
+
templateData.functions = this.resolveTemplateFunctions(
|
|
1820
|
+
this.jedison.options.functions
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1818
1823
|
if (this.parent) {
|
|
1819
1824
|
templateData.parent = this.parent.getTemplateData();
|
|
1820
1825
|
}
|
|
1821
1826
|
return templateData;
|
|
1822
1827
|
}
|
|
1828
|
+
resolveTemplateFunctions(functionsObject = {}) {
|
|
1829
|
+
const context = {
|
|
1830
|
+
instance: this
|
|
1831
|
+
};
|
|
1832
|
+
return Object.fromEntries(Object.entries(functionsObject).map(([functionName, functionValue]) => [functionName, functionValue(context)]));
|
|
1833
|
+
}
|
|
1823
1834
|
/**
|
|
1824
1835
|
* Sets the instance value
|
|
1825
1836
|
* @returns {*} The final value after constraint enforcement
|
|
@@ -2137,7 +2148,7 @@ class Editor {
|
|
|
2137
2148
|
titleFromSchema = true;
|
|
2138
2149
|
}
|
|
2139
2150
|
if (titleFromSchema) {
|
|
2140
|
-
this.title = compileTemplate(this.title, this.instance.getTemplateData());
|
|
2151
|
+
this.title = compileTemplate(this.title, this.instance.getTemplateData(this.title));
|
|
2141
2152
|
this.title = this.markdownEnabled ? this.getHtmlFromMarkdown(this.title) : this.title;
|
|
2142
2153
|
const domPurifyOptions = combineDeep({}, this.instance.jedison.options.domPurifyOptions, {
|
|
2143
2154
|
FORBID_TAGS: ["p"]
|
|
@@ -2149,7 +2160,7 @@ class Editor {
|
|
|
2149
2160
|
getDescription() {
|
|
2150
2161
|
const schemaDescription = getSchemaDescription(this.instance.schema);
|
|
2151
2162
|
if (isSet(schemaDescription)) {
|
|
2152
|
-
this.description = compileTemplate(schemaDescription, this.instance.getTemplateData());
|
|
2163
|
+
this.description = compileTemplate(schemaDescription, this.instance.getTemplateData(this.description));
|
|
2153
2164
|
this.description = this.markdownEnabled ? this.getHtmlFromMarkdown(this.description) : this.description;
|
|
2154
2165
|
const domPurifyOptions = this.instance.jedison.options.domPurifyOptions;
|
|
2155
2166
|
this.description = this.purifyEnabled ? this.purifyContent(this.description, domPurifyOptions) : this.description;
|
|
@@ -4345,7 +4356,7 @@ class EditorArrayNav extends EditorArray {
|
|
|
4345
4356
|
const schemaOptionTitleTemplate = getSchemaXOption(this.instance.schema, "titleTemplate");
|
|
4346
4357
|
if (schemaOptionTitleTemplate) {
|
|
4347
4358
|
const template = schemaOptionTitleTemplate;
|
|
4348
|
-
const data = child.getTemplateData();
|
|
4359
|
+
const data = child.getTemplateData(template);
|
|
4349
4360
|
titleTemplate = compileTemplate(template, data) ?? childTitle;
|
|
4350
4361
|
}
|
|
4351
4362
|
const active = index2 === this.activeItemIndex;
|