@record-evolution/widget-markdown 1.0.8 → 1.0.10

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent widget-markdown following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "widget-markdown",
6
- "version": "1.0.8",
6
+ "version": "1.0.10",
7
7
  "engines": {
8
8
  "node": ">=24.9.0",
9
9
  "npm": ">=10.0.2"
@@ -25,7 +25,11 @@
25
25
  "link": "npm run build && npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-markdown",
26
26
  "unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-markdown && npm i @record-evolution/widget-markdown",
27
27
  "types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
28
- "release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag && npm run build"
28
+ "preversion": "sh scripts/release-preflight.sh",
29
+ "postversion": "git push --follow-tags && sh scripts/release-verify.sh",
30
+ "release": "npm version patch",
31
+ "release:minor": "npm version minor",
32
+ "release:major": "npm version major"
29
33
  },
30
34
  "dependencies": {
31
35
  "github-markdown-css": "^5.8.1",
@@ -21,6 +21,10 @@ export type Variables = {
21
21
  value?: Value;
22
22
  [k: string]: unknown;
23
23
  }[];
24
+ /**
25
+ * When enabled, content taller than the widget can be scrolled vertically and a scrollbar appears. When disabled (the default), the content is clipped at the bottom edge and cannot be scrolled — keep it off for short text that should always be fully visible, turn it on for long documents.
26
+ */
27
+ export type EnableVerticalScrolling = boolean;
24
28
 
25
29
  /**
26
30
  * A markdown rendering widget for displaying formatted text with dynamic variable substitution. Use this widget for documentation, instructions, dynamic reports, or any rich text content on dashboards. Supports full Markdown syntax including headers, lists, tables, links, and code blocks. Variables can be embedded using {{variableName}} notation and bound to data sources for real-time updates. Ideal for creating contextual help, status summaries, or narrative text that incorporates live data values.
@@ -28,6 +32,7 @@ export type Variables = {
28
32
  export interface MarkdownConfiguration {
29
33
  markdown?: Markdown;
30
34
  data?: Variables;
35
+ verticalScroll?: EnableVerticalScrolling;
31
36
  [k: string]: unknown;
32
37
  }
33
38
  /**
@@ -45,6 +45,13 @@
45
45
  }
46
46
  }
47
47
  }
48
+ },
49
+ "verticalScroll": {
50
+ "title": "Enable Vertical Scrolling",
51
+ "description": "When enabled, content taller than the widget can be scrolled vertically and a scrollbar appears. When disabled (the default), the content is clipped at the bottom edge and cannot be scrolled — keep it off for short text that should always be fully visible, turn it on for long documents.",
52
+ "order": 3,
53
+ "dataDrivenDisabled": true,
54
+ "type": "boolean"
48
55
  }
49
56
  }
50
57
  }
@@ -111,6 +111,14 @@ export class WidgetMarkdown extends LitElement {
111
111
  super.updated(changedProperties)
112
112
 
113
113
  if (changedProperties.has('inputData')) {
114
+ // A wrapper left scrolled down stays scrolled once scrolling is switched
115
+ // off — overflow: hidden only stops the *user* from scrolling back. Reset
116
+ // it so turning the setting off always shows the top of the document.
117
+ if (!this.inputData?.verticalScroll) {
118
+ const wrapper = this.shadowRoot?.querySelector('.wrapper')
119
+ if (wrapper) wrapper.scrollTop = 0
120
+ }
121
+
114
122
  // Update only the variable spans
115
123
  const varSpans = this.shadowRoot?.querySelectorAll('.md-var')
116
124
  varSpans?.forEach((span) => {
@@ -119,13 +127,15 @@ export class WidgetMarkdown extends LitElement {
119
127
  const dataItem = this.inputData?.data?.find((item) => item.label === varName)
120
128
  const value = dataItem?.value
121
129
 
130
+ // An unbound variable, or one whose bound value is empty, renders as
131
+ // nothing — never as the raw {{placeholder}}.
122
132
  if (value === null || value === undefined) {
123
- span.textContent = `{{${varName}}}`
133
+ span.textContent = ''
124
134
  } else if (typeof value === 'object') {
125
135
  try {
126
136
  span.textContent = JSON.stringify(value)
127
137
  } catch {
128
- span.textContent = `{{${varName}}}`
138
+ span.textContent = ''
129
139
  }
130
140
  } else {
131
141
  span.textContent = String(value)
@@ -156,7 +166,10 @@ export class WidgetMarkdown extends LitElement {
156
166
  flex-direction: column;
157
167
  width: 100%;
158
168
  height: 100%;
159
- overflow: auto;
169
+ overflow-x: auto;
170
+ /* Vertical scrolling is opt-in via the verticalScroll setting; by
171
+ default overlong content is clipped rather than scrollable. */
172
+ overflow-y: hidden;
160
173
  padding: 1cqh 1cqw;
161
174
  box-sizing: border-box;
162
175
  /* Derive scrollbar colors from the (inherited) text color so they
@@ -184,6 +197,10 @@ export class WidgetMarkdown extends LitElement {
184
197
  background-color: color-mix(in srgb, currentColor 55%, transparent);
185
198
  }
186
199
 
200
+ .wrapper[scrollable] {
201
+ overflow-y: auto;
202
+ }
203
+
187
204
  h2 {
188
205
  margin: 0;
189
206
  padding: 0px;
@@ -220,7 +237,11 @@ export class WidgetMarkdown extends LitElement {
220
237
  }
221
238
 
222
239
  return html`
223
- <div class="wrapper" style="background-color: ${this.themeBgColor}">
240
+ <div
241
+ class="wrapper"
242
+ ?scrollable=${this.inputData?.verticalScroll}
243
+ style="background-color: ${this.themeBgColor}"
244
+ >
224
245
  <div class="paging markdown-body" ?active=${this.inputData?.markdown}>
225
246
  ${unsafeHTML(this.cachedHtmlTemplate ?? '')}
226
247
  </div>