@record-evolution/widget-markdown 1.0.9 → 1.0.11

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.11",
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
  }
@@ -85,12 +85,9 @@ export class WidgetMarkdown extends LitElement {
85
85
  }
86
86
 
87
87
  registerTheme(theme?: Theme) {
88
- const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
89
- const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()
90
- this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
91
- this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
92
- this.themeSubtitleColor =
93
- cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
88
+ this.themeBgColor = `var(--re-tile-background-color, ${this.theme?.theme_object?.backgroundColor || 'transparent'})`
89
+ this.themeTitleColor = `var(--re-text-color, ${this.theme?.theme_object?.title?.textStyle?.color || 'inherit'})`
90
+ this.themeSubtitleColor = `var(--re-text-color, ${this.theme?.theme_object?.title?.subtextStyle?.color || this.theme?.theme_object?.title?.textStyle?.color || 'inherit'})`
94
91
  }
95
92
 
96
93
  /**
@@ -111,6 +108,14 @@ export class WidgetMarkdown extends LitElement {
111
108
  super.updated(changedProperties)
112
109
 
113
110
  if (changedProperties.has('inputData')) {
111
+ // A wrapper left scrolled down stays scrolled once scrolling is switched
112
+ // off — overflow: hidden only stops the *user* from scrolling back. Reset
113
+ // it so turning the setting off always shows the top of the document.
114
+ if (!this.inputData?.verticalScroll) {
115
+ const wrapper = this.shadowRoot?.querySelector('.wrapper')
116
+ if (wrapper) wrapper.scrollTop = 0
117
+ }
118
+
114
119
  // Update only the variable spans
115
120
  const varSpans = this.shadowRoot?.querySelectorAll('.md-var')
116
121
  varSpans?.forEach((span) => {
@@ -158,7 +163,10 @@ export class WidgetMarkdown extends LitElement {
158
163
  flex-direction: column;
159
164
  width: 100%;
160
165
  height: 100%;
161
- overflow: auto;
166
+ overflow-x: auto;
167
+ /* Vertical scrolling is opt-in via the verticalScroll setting; by
168
+ default overlong content is clipped rather than scrollable. */
169
+ overflow-y: hidden;
162
170
  padding: 1cqh 1cqw;
163
171
  box-sizing: border-box;
164
172
  /* Derive scrollbar colors from the (inherited) text color so they
@@ -186,6 +194,10 @@ export class WidgetMarkdown extends LitElement {
186
194
  background-color: color-mix(in srgb, currentColor 55%, transparent);
187
195
  }
188
196
 
197
+ .wrapper[scrollable] {
198
+ overflow-y: auto;
199
+ }
200
+
189
201
  h2 {
190
202
  margin: 0;
191
203
  padding: 0px;
@@ -222,7 +234,11 @@ export class WidgetMarkdown extends LitElement {
222
234
  }
223
235
 
224
236
  return html`
225
- <div class="wrapper" style="background-color: ${this.themeBgColor}">
237
+ <div
238
+ class="wrapper"
239
+ ?scrollable=${this.inputData?.verticalScroll}
240
+ style="background-color: ${this.themeBgColor}"
241
+ >
226
242
  <div class="paging markdown-body" ?active=${this.inputData?.markdown}>
227
243
  ${unsafeHTML(this.cachedHtmlTemplate ?? '')}
228
244
  </div>