@record-evolution/widget-markdown 1.0.9 → 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.9",
6
+ "version": "1.0.10",
7
7
  "engines": {
8
8
  "node": ">=24.9.0",
9
9
  "npm": ">=10.0.2"
@@ -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) => {
@@ -158,7 +166,10 @@ export class WidgetMarkdown extends LitElement {
158
166
  flex-direction: column;
159
167
  width: 100%;
160
168
  height: 100%;
161
- 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;
162
173
  padding: 1cqh 1cqw;
163
174
  box-sizing: border-box;
164
175
  /* Derive scrollbar colors from the (inherited) text color so they
@@ -186,6 +197,10 @@ export class WidgetMarkdown extends LitElement {
186
197
  background-color: color-mix(in srgb, currentColor 55%, transparent);
187
198
  }
188
199
 
200
+ .wrapper[scrollable] {
201
+ overflow-y: auto;
202
+ }
203
+
189
204
  h2 {
190
205
  margin: 0;
191
206
  padding: 0px;
@@ -222,7 +237,11 @@ export class WidgetMarkdown extends LitElement {
222
237
  }
223
238
 
224
239
  return html`
225
- <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
+ >
226
245
  <div class="paging markdown-body" ?active=${this.inputData?.markdown}>
227
246
  ${unsafeHTML(this.cachedHtmlTemplate ?? '')}
228
247
  </div>