@budibase/bbui 3.38.3 → 3.38.5

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "3.38.3",
4
+ "version": "3.38.5",
5
5
  "license": "MPL-2.0",
6
6
  "module": "dist/bbui.mjs",
7
7
  "exports": {
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@sveltejs/vite-plugin-svelte": "^6.1.3",
20
+ "@types/sanitize-html": "^2.13.0",
20
21
  "vite-plugin-css-injected-by-js": "3.5.2"
21
22
  },
22
23
  "keywords": [
@@ -74,6 +75,7 @@
74
75
  "date-fns": "^4.1.0",
75
76
  "dayjs": "^1.10.8",
76
77
  "easymde": "^2.16.1",
78
+ "sanitize-html": "^2.13.0",
77
79
  "svelte-portal": "^2.2.1"
78
80
  },
79
81
  "resolutions": {
@@ -103,5 +105,5 @@
103
105
  }
104
106
  }
105
107
  },
106
- "gitHead": "6d025a1d0b3c1b0dc4e1de0c88ce7f3ec6a97c0b"
108
+ "gitHead": "5795ec6c95812463cba1d8cede8295f6c2b915cb"
107
109
  }
@@ -90,6 +90,7 @@
90
90
 
91
91
  <style>
92
92
  button {
93
+ position: relative;
93
94
  transition:
94
95
  filter 130ms ease-out,
95
96
  background 130ms ease-out,
@@ -181,13 +182,14 @@
181
182
  .tooltip {
182
183
  position: absolute;
183
184
  pointer-events: none;
184
- left: 50%;
185
+ inset-inline-end: 0;
185
186
  top: calc(100% + 4px);
186
- width: 100vw;
187
+ width: max-content;
187
188
  max-width: 150px;
188
- transform: translateX(-50%);
189
+ min-width: 0;
189
190
  text-align: center;
190
191
  z-index: 1;
192
+ box-sizing: border-box;
191
193
  }
192
194
  .accent.is-selected,
193
195
  .accent:active {
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { marked } from "marked"
2
+ import { renderMarkdown } from "./renderMarkdown"
3
3
 
4
4
  export let value: string | undefined = undefined
5
5
  export let height: string | undefined = undefined
@@ -19,7 +19,7 @@
19
19
  ref.innerHTML = ""
20
20
  return
21
21
  }
22
- ref.innerHTML = marked.parse(markdown, { async: false })
22
+ ref.innerHTML = renderMarkdown(markdown)
23
23
  }
24
24
  </script>
25
25
 
@@ -0,0 +1,52 @@
1
+ import { marked } from "marked"
2
+ import sanitizeHtml from "sanitize-html"
3
+
4
+ const MARKDOWN_TAGS = [
5
+ "a",
6
+ "blockquote",
7
+ "br",
8
+ "code",
9
+ "del",
10
+ "em",
11
+ "h1",
12
+ "h2",
13
+ "h3",
14
+ "h4",
15
+ "h5",
16
+ "h6",
17
+ "hr",
18
+ "img",
19
+ "li",
20
+ "ol",
21
+ "p",
22
+ "pre",
23
+ "strong",
24
+ "table",
25
+ "tbody",
26
+ "td",
27
+ "th",
28
+ "thead",
29
+ "tr",
30
+ "ul",
31
+ ]
32
+
33
+ export const renderMarkdown = (markdown: string | undefined) => {
34
+ if (!markdown) {
35
+ return ""
36
+ }
37
+
38
+ const html = marked.parse(markdown, { async: false })
39
+
40
+ return sanitizeHtml(html, {
41
+ allowedTags: MARKDOWN_TAGS,
42
+ allowedAttributes: {
43
+ a: ["href", "title"],
44
+ img: ["alt", "src", "title"],
45
+ },
46
+ allowedSchemes: ["http", "https", "mailto", "tel"],
47
+ allowedSchemesByTag: {
48
+ img: ["http", "https"],
49
+ },
50
+ allowProtocolRelative: false,
51
+ })
52
+ }