openapi-explorer 2.1.624 → 2.1.626

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.
@@ -87,16 +87,18 @@ class SyntaxHighlighter extends LitElement {
87
87
 
88
88
 
89
89
  renderHighlight() {
90
- var _this$content, _this$content2;
90
+ var _this$content;
91
91
 
92
92
  const lang = this.detectLanguage();
93
93
  const grammar = Prism.languages[lang];
94
94
 
95
- if (lang === 'json' && typeof this.content !== 'string') {
95
+ if (typeof this.content !== 'string') {
96
96
  return html`<json-tree .data="${this.content}">`;
97
97
  }
98
98
 
99
- return grammar ? html`<pre><code>${unsafeHTML(Prism.highlight((_this$content = this.content) === null || _this$content === void 0 ? void 0 : _this$content.toString(), grammar, lang))}</code></pre>` : html`<pre>${(_this$content2 = this.content) === null || _this$content2 === void 0 ? void 0 : _this$content2.toString()}</pre>`;
99
+ const stringContent = ((_this$content = this.content) === null || _this$content === void 0 ? void 0 : _this$content.toString()) || '';
100
+ const increasedSpaceContent = lang !== 'python' && lang !== 'yaml' && lang !== 'toml' ? stringContent.split('\n').map(line => line.replace(/^\s{2}/g, ' ')).join('\n') : stringContent;
101
+ return grammar ? html`<pre><code>${unsafeHTML(Prism.highlight(increasedSpaceContent, grammar, lang))}</code></pre>` : html`<pre>${increasedSpaceContent}</pre>`;
100
102
  }
101
103
  /**
102
104
  * Render a copy-to-clipboard button.
@@ -115,9 +117,9 @@ class SyntaxHighlighter extends LitElement {
115
117
 
116
118
 
117
119
  copyToClipboard(e) {
118
- var _this$content3;
120
+ var _this$content2;
119
121
 
120
- const data = this.detectLanguage() === 'json' && typeof this.content !== 'string' ? JSON.stringify(this.content, null, 2) : (_this$content3 = this.content) === null || _this$content3 === void 0 ? void 0 : _this$content3.toString();
122
+ const data = this.detectLanguage() === 'json' && typeof this.content !== 'string' ? JSON.stringify(this.content, null, 2) : (_this$content2 = this.content) === null || _this$content2 === void 0 ? void 0 : _this$content2.toString();
121
123
  copyToClipboard(data, e);
122
124
  }
123
125
 
@@ -15,10 +15,11 @@ export default function codeSamplesTemplate(xCodeSamples) {
15
15
  tabBodyEl.style.display = tabBodyEl.dataset.tab === clickedTab ? 'block' : 'none';
16
16
  });
17
17
  }}"> <div class="tab-buttons row" style="width:100"> ${xCodeSamples.map((v, i) => html`<button class="tab-btn ${i === 0 ? 'active' : ''}" data-tab="${v.lang}${i}"> ${v.label || v.lang} </button>`)} </div> ${xCodeSamples.map((v, i) => {
18
+ // We skip the first line because it could be there is no padding there, but padding on the next lines which needs to be removed
18
19
  const paddingToRemove = Math.min(...v.source.split('\n').slice(1).map(l => {
19
20
  var _l$match;
20
21
 
21
- return (_l$match = l.match(/^(\s+).*$/)) === null || _l$match === void 0 ? void 0 : _l$match[1].length;
22
+ return (_l$match = l.match(/^(\s*).*$/m)) === null || _l$match === void 0 ? void 0 : _l$match[1].length;
22
23
  }).filter(l => typeof l !== 'undefined'));
23
24
  const sanitizedSource = v.source.split('\n').map(s => s.substring(0, paddingToRemove).match(/^\s+$/) ? s.substring(paddingToRemove) : s);
24
25
  const fullSource = sanitizedSource.join('\n');
@@ -111,16 +111,18 @@ class SyntaxHighlighter extends _lit.LitElement {
111
111
 
112
112
 
113
113
  renderHighlight() {
114
- var _this$content, _this$content2;
114
+ var _this$content;
115
115
 
116
116
  const lang = this.detectLanguage();
117
117
  const grammar = _prismjs.default.languages[lang];
118
118
 
119
- if (lang === 'json' && typeof this.content !== 'string') {
119
+ if (typeof this.content !== 'string') {
120
120
  return (0, _lit.html)`<json-tree .data="${this.content}">`;
121
121
  }
122
122
 
123
- return grammar ? (0, _lit.html)`<pre><code>${(0, _unsafeHtml.unsafeHTML)(_prismjs.default.highlight((_this$content = this.content) === null || _this$content === void 0 ? void 0 : _this$content.toString(), grammar, lang))}</code></pre>` : (0, _lit.html)`<pre>${(_this$content2 = this.content) === null || _this$content2 === void 0 ? void 0 : _this$content2.toString()}</pre>`;
123
+ const stringContent = ((_this$content = this.content) === null || _this$content === void 0 ? void 0 : _this$content.toString()) || '';
124
+ const increasedSpaceContent = lang !== 'python' && lang !== 'yaml' && lang !== 'toml' ? stringContent.split('\n').map(line => line.replace(/^\s{2}/g, ' ')).join('\n') : stringContent;
125
+ return grammar ? (0, _lit.html)`<pre><code>${(0, _unsafeHtml.unsafeHTML)(_prismjs.default.highlight(increasedSpaceContent, grammar, lang))}</code></pre>` : (0, _lit.html)`<pre>${increasedSpaceContent}</pre>`;
124
126
  }
125
127
  /**
126
128
  * Render a copy-to-clipboard button.
@@ -139,9 +141,9 @@ class SyntaxHighlighter extends _lit.LitElement {
139
141
 
140
142
 
141
143
  copyToClipboard(e) {
142
- var _this$content3;
144
+ var _this$content2;
143
145
 
144
- const data = this.detectLanguage() === 'json' && typeof this.content !== 'string' ? JSON.stringify(this.content, null, 2) : (_this$content3 = this.content) === null || _this$content3 === void 0 ? void 0 : _this$content3.toString();
146
+ const data = this.detectLanguage() === 'json' && typeof this.content !== 'string' ? JSON.stringify(this.content, null, 2) : (_this$content2 = this.content) === null || _this$content2 === void 0 ? void 0 : _this$content2.toString();
145
147
  (0, _commonUtils.copyToClipboard)(data, e);
146
148
  }
147
149
 
@@ -20,10 +20,11 @@ function codeSamplesTemplate(xCodeSamples) {
20
20
  tabBodyEl.style.display = tabBodyEl.dataset.tab === clickedTab ? 'block' : 'none';
21
21
  });
22
22
  }}"> <div class="tab-buttons row" style="width:100"> ${xCodeSamples.map((v, i) => (0, _lit.html)`<button class="tab-btn ${i === 0 ? 'active' : ''}" data-tab="${v.lang}${i}"> ${v.label || v.lang} </button>`)} </div> ${xCodeSamples.map((v, i) => {
23
+ // We skip the first line because it could be there is no padding there, but padding on the next lines which needs to be removed
23
24
  const paddingToRemove = Math.min(...v.source.split('\n').slice(1).map(l => {
24
25
  var _l$match;
25
26
 
26
- return (_l$match = l.match(/^(\s+).*$/)) === null || _l$match === void 0 ? void 0 : _l$match[1].length;
27
+ return (_l$match = l.match(/^(\s*).*$/m)) === null || _l$match === void 0 ? void 0 : _l$match[1].length;
27
28
  }).filter(l => typeof l !== 'undefined'));
28
29
  const sanitizedSource = v.source.split('\n').map(s => s.substring(0, paddingToRemove).match(/^\s+$/) ? s.substring(paddingToRemove) : s);
29
30
  const fullSource = sanitizedSource.join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.1.624",
3
+ "version": "2.1.626",
4
4
  "description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
5
5
  "author": "Rhosys Developers <developers@rhosys.ch>",
6
6
  "type": "module",