@vaadin/markdown 25.3.0-alpha9 → 25.3.0-beta1
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/custom-elements.json +18 -0
- package/package.json +8 -8
- package/src/markdown-helpers.js +7 -2
- package/src/vaadin-markdown.d.ts +13 -0
- package/src/vaadin-markdown.js +19 -2
- package/web-types.json +19 -1
- package/web-types.lit.json +8 -1
package/custom-elements.json
CHANGED
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
},
|
|
36
36
|
"description": "The Markdown content.",
|
|
37
37
|
"attribute": "content"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"kind": "field",
|
|
41
|
+
"name": "lineBreaks",
|
|
42
|
+
"privacy": "public",
|
|
43
|
+
"type": {
|
|
44
|
+
"text": "boolean"
|
|
45
|
+
},
|
|
46
|
+
"description": "When set to `true`, single line breaks (\"soft breaks\") within a\nparagraph are converted into `<br>` elements, the same way chat and\nmessage-style Markdown behaves.\n\nBy default, following the original Markdown specification, single line\nbreaks are ignored (collapsed into a space) and a blank line is\nrequired to start a new paragraph.",
|
|
47
|
+
"attribute": "line-breaks"
|
|
38
48
|
}
|
|
39
49
|
],
|
|
40
50
|
"attributes": [
|
|
@@ -46,6 +56,14 @@
|
|
|
46
56
|
"description": "The Markdown content.",
|
|
47
57
|
"fieldName": "content"
|
|
48
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"name": "line-breaks",
|
|
61
|
+
"type": {
|
|
62
|
+
"text": "boolean"
|
|
63
|
+
},
|
|
64
|
+
"description": "When set to `true`, single line breaks (\"soft breaks\") within a\nparagraph are converted into `<br>` elements, the same way chat and\nmessage-style Markdown behaves.\n\nBy default, following the original Markdown specification, single line\nbreaks are ignored (collapsed into a space) and a blank line is\nrequired to start a new paragraph.",
|
|
65
|
+
"fieldName": "lineBreaks"
|
|
66
|
+
},
|
|
49
67
|
{
|
|
50
68
|
"type": {
|
|
51
69
|
"text": "string"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/markdown",
|
|
3
|
-
"version": "25.3.0-
|
|
3
|
+
"version": "25.3.0-beta1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
|
-
"@vaadin/component-base": "25.3.0-
|
|
39
|
-
"@vaadin/vaadin-themable-mixin": "25.3.0-
|
|
38
|
+
"@vaadin/component-base": "25.3.0-beta1",
|
|
39
|
+
"@vaadin/vaadin-themable-mixin": "25.3.0-beta1",
|
|
40
40
|
"dompurify": "^3.4.10",
|
|
41
41
|
"lit": "^3.0.0",
|
|
42
42
|
"marked": "^18.0.5"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@vaadin/aura": "25.3.0-
|
|
46
|
-
"@vaadin/chai-plugins": "25.3.0-
|
|
47
|
-
"@vaadin/test-runner-commands": "25.3.0-
|
|
45
|
+
"@vaadin/aura": "25.3.0-beta1",
|
|
46
|
+
"@vaadin/chai-plugins": "25.3.0-beta1",
|
|
47
|
+
"@vaadin/test-runner-commands": "25.3.0-beta1",
|
|
48
48
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
49
|
-
"@vaadin/vaadin-lumo-styles": "25.3.0-
|
|
49
|
+
"@vaadin/vaadin-lumo-styles": "25.3.0-beta1"
|
|
50
50
|
},
|
|
51
51
|
"customElements": "custom-elements.json",
|
|
52
52
|
"web-types": [
|
|
53
53
|
"web-types.json",
|
|
54
54
|
"web-types.lit.json"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "295432e44a6967e1aff36462b2e3e1d0e64eb8cc"
|
|
57
57
|
}
|
package/src/markdown-helpers.js
CHANGED
|
@@ -76,10 +76,15 @@ function synchronizeNodes(targetNode, sourceNode) {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Updates the content of a target element with the given Markdown parsed as HTML.
|
|
79
|
+
*
|
|
80
|
+
* When `lineBreaks` is enabled, single line breaks ("soft breaks") within a
|
|
81
|
+
* paragraph are converted into `<br>` elements, matching the behavior of
|
|
82
|
+
* chat/message-style Markdown. By default they are ignored, following the
|
|
83
|
+
* original Markdown specification.
|
|
79
84
|
*/
|
|
80
|
-
export function renderMarkdownToElement(element, markdown) {
|
|
85
|
+
export function renderMarkdownToElement(element, markdown, { lineBreaks = false } = {}) {
|
|
81
86
|
const template = document.createElement('template');
|
|
82
|
-
template.innerHTML = DOMPurify.sanitize(parse(markdown || ''), {
|
|
87
|
+
template.innerHTML = DOMPurify.sanitize(parse(markdown || '', { breaks: lineBreaks }), {
|
|
83
88
|
CUSTOM_ELEMENT_HANDLING: {
|
|
84
89
|
tagNameCheck: (_tagName) => true,
|
|
85
90
|
},
|
package/src/vaadin-markdown.d.ts
CHANGED
|
@@ -24,6 +24,19 @@ declare class Markdown extends SlotStylesMixin(ElementMixin(ThemableMixin(HTMLEl
|
|
|
24
24
|
* The Markdown content.
|
|
25
25
|
*/
|
|
26
26
|
content: string | null | undefined;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* When set to `true`, single line breaks ("soft breaks") within a
|
|
30
|
+
* paragraph are converted into `<br>` elements, the same way chat and
|
|
31
|
+
* message-style Markdown behaves.
|
|
32
|
+
*
|
|
33
|
+
* By default, following the original Markdown specification, single line
|
|
34
|
+
* breaks are ignored (collapsed into a space) and a blank line is
|
|
35
|
+
* required to start a new paragraph.
|
|
36
|
+
*
|
|
37
|
+
* @attr {boolean} line-breaks
|
|
38
|
+
*/
|
|
39
|
+
lineBreaks: boolean;
|
|
27
40
|
}
|
|
28
41
|
|
|
29
42
|
declare global {
|
package/src/vaadin-markdown.js
CHANGED
|
@@ -59,6 +59,23 @@ class Markdown extends SlotStylesMixin(ElementMixin(ThemableMixin(PolylitMixin(L
|
|
|
59
59
|
type: String,
|
|
60
60
|
sync: true,
|
|
61
61
|
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* When set to `true`, single line breaks ("soft breaks") within a
|
|
65
|
+
* paragraph are converted into `<br>` elements, the same way chat and
|
|
66
|
+
* message-style Markdown behaves.
|
|
67
|
+
*
|
|
68
|
+
* By default, following the original Markdown specification, single line
|
|
69
|
+
* breaks are ignored (collapsed into a space) and a blank line is
|
|
70
|
+
* required to start a new paragraph.
|
|
71
|
+
*
|
|
72
|
+
* @attr {boolean} line-breaks
|
|
73
|
+
*/
|
|
74
|
+
lineBreaks: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
value: false,
|
|
77
|
+
sync: true,
|
|
78
|
+
},
|
|
62
79
|
};
|
|
63
80
|
}
|
|
64
81
|
|
|
@@ -74,8 +91,8 @@ class Markdown extends SlotStylesMixin(ElementMixin(ThemableMixin(PolylitMixin(L
|
|
|
74
91
|
updated(props) {
|
|
75
92
|
super.updated(props);
|
|
76
93
|
|
|
77
|
-
if (props.has('content')) {
|
|
78
|
-
renderMarkdownToElement(this, this.content);
|
|
94
|
+
if (props.has('content') || props.has('lineBreaks')) {
|
|
95
|
+
renderMarkdownToElement(this, this.content, { lineBreaks: this.lineBreaks });
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
98
|
}
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/markdown",
|
|
4
|
-
"version": "25.3.0-
|
|
4
|
+
"version": "25.3.0-beta1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
]
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
"name": "line-breaks",
|
|
24
|
+
"description": "When set to `true`, single line breaks (\"soft breaks\") within a\nparagraph are converted into `<br>` elements, the same way chat and\nmessage-style Markdown behaves.\n\nBy default, following the original Markdown specification, single line\nbreaks are ignored (collapsed into a space) and a blank line is\nrequired to start a new paragraph.",
|
|
25
|
+
"value": {
|
|
26
|
+
"type": [
|
|
27
|
+
"boolean"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
22
31
|
{
|
|
23
32
|
"name": "theme",
|
|
24
33
|
"description": "The theme variants to apply to the component.",
|
|
@@ -39,6 +48,15 @@
|
|
|
39
48
|
"string"
|
|
40
49
|
]
|
|
41
50
|
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "lineBreaks",
|
|
54
|
+
"description": "When set to `true`, single line breaks (\"soft breaks\") within a\nparagraph are converted into `<br>` elements, the same way chat and\nmessage-style Markdown behaves.\n\nBy default, following the original Markdown specification, single line\nbreaks are ignored (collapsed into a space) and a blank line is\nrequired to start a new paragraph.",
|
|
55
|
+
"value": {
|
|
56
|
+
"type": [
|
|
57
|
+
"boolean"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
61
|
],
|
|
44
62
|
"events": []
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/markdown",
|
|
4
|
-
"version": "25.3.0-
|
|
4
|
+
"version": "25.3.0-beta1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
"value": {
|
|
26
26
|
"kind": "expression"
|
|
27
27
|
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "?lineBreaks",
|
|
31
|
+
"description": "When set to `true`, single line breaks (\"soft breaks\") within a\nparagraph are converted into `<br>` elements, the same way chat and\nmessage-style Markdown behaves.\n\nBy default, following the original Markdown specification, single line\nbreaks are ignored (collapsed into a space) and a blank line is\nrequired to start a new paragraph.",
|
|
32
|
+
"value": {
|
|
33
|
+
"kind": "expression"
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
]
|
|
30
37
|
}
|