@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.
@@ -17,6 +17,7 @@
17
17
  (if (get this.toastIdToDismissedMap toast.id) "euiGlobalToastListItem-isDismissed")
18
18
  }}
19
19
  @title={{toast.title}}
20
+ @useMarkdownFormat={{toast.useMarkdownFormat}}
20
21
  @body={{toast.body}}
21
22
  @color={{toast.color}}
22
23
  @iconType={{toast.iconType}}
@@ -5,9 +5,9 @@
5
5
  @grow={{@grow}}
6
6
  @size={{@textSize}}
7
7
  @textAlign={{@textAlign}}
8
+ {{did-insert this.setRootNode}}
8
9
  ...attributes
9
10
  >
10
- {{this.result.element}}
11
11
  {{#each this.result.components as |CompNode|}}
12
12
  {{#in-element CompNode.element}}
13
13
  {{#let
@@ -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
- try {
47
- const processed = this.processor.processSync(this.args.value);
48
- return toDOM(processed.result as RehypeNode);
49
- //eslint-disable-next-line
50
- } catch (e) {
51
- return this.args.value;
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
- {{!-- TODO: Translate strings when EuiI18n is available --}}
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
- <EuiText @size="s" class="euiToastBody">
49
- {{@body}}
50
- </EuiText>
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>
@@ -11,6 +11,7 @@ export interface EuiToastProps {
11
11
  color?: ToastColor;
12
12
  iconType?: string;
13
13
  toastLifeTimeMs?: number;
14
+ useMarkdownFormat?: boolean;
14
15
  onClose?: () => void;
15
16
  }
16
17
 
@@ -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.15.0",
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": "fb7f41ce8b57cee70c1427a9d2f20d1f02d5ebe2"
189
+ "gitHead": "935bd04cef925daf9e98960727a40e96ea895d3f"
190
190
  }