@record-evolution/widget-markdown 1.0.7 → 1.0.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.
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.7",
6
+ "version": "1.0.9",
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",
@@ -25,7 +25,7 @@ export type Variables = {
25
25
  /**
26
26
  * 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.
27
27
  */
28
- export interface InputData {
28
+ export interface MarkdownConfiguration {
29
29
  markdown?: Markdown;
30
30
  data?: Variables;
31
31
  [k: string]: unknown;
@@ -1,6 +1,20 @@
1
1
  {
2
- "title": "InputData",
2
+ "title": "Markdown Configuration",
3
3
  "description": "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.",
4
+ "aiSelection": {
5
+ "dataShape": "A Markdown document, with {{variableName}} placeholders substituted from data[] entries that each bind a label to a live value.",
6
+ "useWhen": [
7
+ "Prose, documentation, instructions or a written summary belongs on the dashboard.",
8
+ "The text needs structure or markup — headings, lists, links, tables, code blocks.",
9
+ "A narrative should incorporate live numbers, e.g. 'Line 3 produced {{units}} units today'."
10
+ ],
11
+ "notFor": [
12
+ "A single styled string with no markup — use widget-label; a Markdown renderer is overkill.",
13
+ "Fixed title / subtitle / body sections with per-section typography — use widget-textbox.",
14
+ "Tabular data coming from a query rather than written by hand — use widget-table.",
15
+ "Numbers that should be read as figures rather than embedded in a sentence — use widget-value."
16
+ ]
17
+ },
4
18
  "type": "object",
5
19
  "properties": {
6
20
  "markdown": {
@@ -16,7 +16,7 @@ import cssLang from 'highlight.js/lib/languages/css'
16
16
  import highlightCSS from 'highlight.js/styles/github.css?inline'
17
17
  import githubCss from 'github-markdown-css/github-markdown.css?inline'
18
18
  import { customElement, property, state } from 'lit/decorators.js'
19
- import { InputData } from './definition-schema'
19
+ import { MarkdownConfiguration } from './definition-schema'
20
20
 
21
21
  hljs.registerLanguage('shell', shell)
22
22
  hljs.registerLanguage('bash', shell)
@@ -37,7 +37,7 @@ type Theme = {
37
37
  @customElement('widget-markdown-versionplaceholder')
38
38
  export class WidgetMarkdown extends LitElement {
39
39
  @property({ type: Object })
40
- inputData?: InputData
40
+ inputData?: MarkdownConfiguration
41
41
 
42
42
  @property({ type: Object })
43
43
  theme?: Theme
@@ -119,13 +119,15 @@ export class WidgetMarkdown extends LitElement {
119
119
  const dataItem = this.inputData?.data?.find((item) => item.label === varName)
120
120
  const value = dataItem?.value
121
121
 
122
+ // An unbound variable, or one whose bound value is empty, renders as
123
+ // nothing — never as the raw {{placeholder}}.
122
124
  if (value === null || value === undefined) {
123
- span.textContent = `{{${varName}}}`
125
+ span.textContent = ''
124
126
  } else if (typeof value === 'object') {
125
127
  try {
126
128
  span.textContent = JSON.stringify(value)
127
129
  } catch {
128
- span.textContent = `{{${varName}}}`
130
+ span.textContent = ''
129
131
  }
130
132
  } else {
131
133
  span.textContent = String(value)