jedison 0.3.8 → 0.3.9

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.
@@ -1660,6 +1660,7 @@ class Instance extends EventEmitter {
1660
1660
  this.isDirty = false;
1661
1661
  this.watched = {};
1662
1662
  this.key = this.path.split(this.jedison.pathSeparator).pop();
1663
+ this.arrayTemplateData = config.arrayTemplateData || {};
1663
1664
  this.init();
1664
1665
  }
1665
1666
  /**
@@ -1798,6 +1799,16 @@ class Instance extends EventEmitter {
1798
1799
  getValue() {
1799
1800
  return clone(this.value);
1800
1801
  }
1802
+ /**
1803
+ * Returns the data that will replace placeholders in titles, descriptions (e.g. "{{ i1 }} {{ value.title }}")
1804
+ */
1805
+ getTemplateData() {
1806
+ return {
1807
+ ...this.arrayTemplateData,
1808
+ value: this.getValue(),
1809
+ settings: this.jedison.options.settings
1810
+ };
1811
+ }
1801
1812
  /**
1802
1813
  * Sets the instance value
1803
1814
  */
@@ -2063,16 +2074,15 @@ class Editor {
2063
2074
  return content;
2064
2075
  }
2065
2076
  getTitle() {
2066
- if (this.title) {
2067
- return this.title;
2068
- }
2077
+ let titleFromSchema = false;
2069
2078
  this.title = this.instance.getKey();
2070
2079
  const schemaTitle = getSchemaTitle(this.instance.schema);
2071
2080
  if (isSet(schemaTitle)) {
2072
- this.title = compileTemplate(schemaTitle, {
2073
- value: this.instance.getValue(),
2074
- settings: this.instance.jedison.options.settings
2075
- });
2081
+ this.title = schemaTitle;
2082
+ titleFromSchema = true;
2083
+ }
2084
+ if (titleFromSchema) {
2085
+ this.title = compileTemplate(this.title, this.instance.getTemplateData());
2076
2086
  this.title = this.getHtmlFromMarkdown(this.title);
2077
2087
  const domPurifyOptions = combineDeep({}, this.instance.jedison.options.domPurifyOptions, {
2078
2088
  FORBID_TAGS: ["p"]
@@ -2087,10 +2097,7 @@ class Editor {
2087
2097
  }
2088
2098
  const schemaDescription = getSchemaDescription(this.instance.schema);
2089
2099
  if (isSet(schemaDescription)) {
2090
- this.description = compileTemplate(schemaDescription, {
2091
- value: this.instance.getValue(),
2092
- settings: this.instance.jedison.options.settings
2093
- });
2100
+ this.description = compileTemplate(schemaDescription, this.instance.getTemplateData());
2094
2101
  this.description = this.getHtmlFromMarkdown(this.description);
2095
2102
  const domPurifyOptions = this.instance.jedison.options.domPurifyOptions;
2096
2103
  this.purifyContent(this.description, domPurifyOptions);
@@ -2742,7 +2749,7 @@ class InstanceArray extends Instance {
2742
2749
  this.refreshChildren();
2743
2750
  });
2744
2751
  }
2745
- createItemInstance() {
2752
+ createItemInstance(index2) {
2746
2753
  let schema;
2747
2754
  const itemsCount = this.children.length;
2748
2755
  const schemaItems = getSchemaItems(this.schema);
@@ -2756,7 +2763,11 @@ class InstanceArray extends Instance {
2756
2763
  jedison: this.jedison,
2757
2764
  schema,
2758
2765
  path: this.path + this.jedison.pathSeparator + itemsCount,
2759
- parent: this
2766
+ parent: this,
2767
+ arrayTemplateData: {
2768
+ i0: index2,
2769
+ i1: index2 + 1
2770
+ }
2760
2771
  });
2761
2772
  }
2762
2773
  setDefaultValue() {
@@ -2807,8 +2818,8 @@ class InstanceArray extends Instance {
2807
2818
  if (!isArray(value)) {
2808
2819
  return;
2809
2820
  }
2810
- value.forEach((itemValue) => {
2811
- const child = this.createItemInstance(itemValue);
2821
+ value.forEach((itemValue, index2) => {
2822
+ const child = this.createItemInstance(index2);
2812
2823
  this.children.push(child);
2813
2824
  child.setValue(itemValue, false);
2814
2825
  });
@@ -6067,7 +6078,7 @@ class Theme {
6067
6078
  icon: "add"
6068
6079
  });
6069
6080
  const fieldset = this.getFieldset();
6070
- const { legend, infoContainer } = this.getLegend({
6081
+ const { legend, infoContainer, legendText } = this.getLegend({
6071
6082
  content: config.title,
6072
6083
  id: config.id,
6073
6084
  titleHidden: config.titleHidden
@@ -6121,6 +6132,7 @@ class Theme {
6121
6132
  ariaLive,
6122
6133
  propertiesActivators,
6123
6134
  legend,
6135
+ legendText,
6124
6136
  infoContainer
6125
6137
  };
6126
6138
  }