@ember-eui/core 5.15.0 → 5.16.0
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/addon/components/eui-global-toast-list/index.hbs +1 -0
- package/addon/components/eui-markdown-format/index.hbs +1 -1
- package/addon/components/eui-markdown-format/index.ts +16 -7
- package/addon/components/eui-toast/index.hbs +11 -10
- package/addon/services/eui-toaster.ts +1 -0
- package/addon/utils/markdown/plugins/to-dom.ts +4 -1
- package/docs/display/toast/demo/d01-toast.md +17 -0
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
defaultParsingPlugins,
|
|
4
4
|
defaultProcessingPlugins
|
|
5
5
|
} from '../../utils/markdown/plugins/markdown-default-plugins';
|
|
6
|
-
import { cached } from '@glimmer/tracking';
|
|
6
|
+
import { cached, tracked } from '@glimmer/tracking';
|
|
7
7
|
import unified, { Processor } from 'unified';
|
|
8
8
|
import { toDOM } from '../../utils/markdown/plugins/to-dom';
|
|
9
9
|
import type { RehypeNode } from '../../utils/markdown/markdown-types';
|
|
@@ -17,6 +17,8 @@ export interface EuiMarkdownEditorToolbarArgs {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMarkdownEditorToolbarArgs> {
|
|
20
|
+
@tracked rootNode?: HTMLDivElement;
|
|
21
|
+
|
|
20
22
|
get parsingPluginList() {
|
|
21
23
|
return this.args.parsingPluginList || defaultParsingPlugins;
|
|
22
24
|
}
|
|
@@ -25,6 +27,10 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
|
|
|
25
27
|
return this.args.processingPluginList || defaultProcessingPlugins;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
setRootNode = (node: HTMLDivElement) => {
|
|
31
|
+
this.rootNode = node;
|
|
32
|
+
};
|
|
33
|
+
|
|
28
34
|
@cached
|
|
29
35
|
get processor() {
|
|
30
36
|
const Compiler = (tree: any) => {
|
|
@@ -43,12 +49,15 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
|
|
|
43
49
|
|
|
44
50
|
@cached
|
|
45
51
|
get result() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (this.rootNode) {
|
|
53
|
+
try {
|
|
54
|
+
const processed = this.processor.processSync(this.args.value);
|
|
55
|
+
return toDOM(processed.result as RehypeNode, this.rootNode);
|
|
56
|
+
//eslint-disable-next-line
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return this.args.value;
|
|
59
|
+
}
|
|
52
60
|
}
|
|
61
|
+
return this.args.value;
|
|
53
62
|
}
|
|
54
63
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
<div
|
|
1
|
+
<div
|
|
2
2
|
class={{class-names
|
|
3
3
|
componentName="EuiToast"
|
|
4
4
|
color=(arg-or-default @color "none")
|
|
5
|
-
}}
|
|
5
|
+
}}
|
|
6
6
|
...attributes
|
|
7
7
|
>
|
|
8
|
-
{{
|
|
8
|
+
{{! TODO: Translate strings when EuiI18n is available }}
|
|
9
9
|
<p {{screen-reader-only}}>
|
|
10
10
|
A new notification appears
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<div
|
|
14
|
-
class={{class-names
|
|
15
|
-
"euiToastHeader"
|
|
16
|
-
(if @body "euiToastHeader--withBody")
|
|
17
|
-
}}
|
|
14
|
+
class={{class-names "euiToastHeader" (if @body "euiToastHeader--withBody")}}
|
|
18
15
|
aria-label="Notification"
|
|
19
16
|
data-test-subj="euiToastHeader"
|
|
20
17
|
>
|
|
@@ -45,8 +42,12 @@
|
|
|
45
42
|
{{/if}}
|
|
46
43
|
|
|
47
44
|
{{#if @body}}
|
|
48
|
-
|
|
49
|
-
{{@body}}
|
|
50
|
-
|
|
45
|
+
{{#if @useMarkdownFormat}}
|
|
46
|
+
<EuiMarkdownFormat @value={{@body}} />
|
|
47
|
+
{{else}}
|
|
48
|
+
<EuiText @size="s" class="euiToastBody">
|
|
49
|
+
{{@body}}
|
|
50
|
+
</EuiText>
|
|
51
|
+
{{/if}}
|
|
51
52
|
{{/if}}
|
|
52
53
|
</div>
|
|
@@ -13,7 +13,7 @@ const createDocument = () => {
|
|
|
13
13
|
|
|
14
14
|
export interface DynamicComponent {}
|
|
15
15
|
|
|
16
|
-
export const toDOM = (tree: RehypeNode) => {
|
|
16
|
+
export const toDOM = (tree: RehypeNode, rootNode?: HTMLDivElement) => {
|
|
17
17
|
let document = createDocument();
|
|
18
18
|
let components: DynamicComponent[] = [];
|
|
19
19
|
|
|
@@ -64,6 +64,9 @@ export const toDOM = (tree: RehypeNode) => {
|
|
|
64
64
|
if (node) {
|
|
65
65
|
let { type } = node;
|
|
66
66
|
if (type === 'root') {
|
|
67
|
+
if (rootNode) {
|
|
68
|
+
return toElements(rootNode, node.children);
|
|
69
|
+
}
|
|
67
70
|
let element = createElement('div', node, 'root');
|
|
68
71
|
return toElements(element, node.children);
|
|
69
72
|
} else if (type === 'element') {
|
|
@@ -28,6 +28,23 @@ export default class DemoToastListComponent extends Component {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
toasts = [
|
|
31
|
+
{
|
|
32
|
+
title: 'You can use markdown for body too!',
|
|
33
|
+
useMarkdownFormat: true,
|
|
34
|
+
body: `
|
|
35
|
+
##### This tooltip is using markdown!
|
|
36
|
+
|
|
37
|
+
You can pass \`useMarkdownFormat: true\`
|
|
38
|
+
|
|
39
|
+
[click here](https://www.google.com)
|
|
40
|
+
|
|
41
|
+
\`\`\`typescript
|
|
42
|
+
class Hello {
|
|
43
|
+
@tracked count = 1;
|
|
44
|
+
}
|
|
45
|
+
\`\`\`
|
|
46
|
+
`
|
|
47
|
+
},
|
|
31
48
|
{
|
|
32
49
|
title: `Long toast`,
|
|
33
50
|
body: 'This toast overrides the default toastLifeTimeMs value and will be around for 15 seconds.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"description": "Ember Components for Elastic UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -186,5 +186,5 @@
|
|
|
186
186
|
"volta": {
|
|
187
187
|
"extends": "../../package.json"
|
|
188
188
|
},
|
|
189
|
-
"gitHead": "
|
|
189
|
+
"gitHead": "935bd04cef925daf9e98960727a40e96ea895d3f"
|
|
190
190
|
}
|