@ember-eui/core 5.15.1 → 5.16.1

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}}
@@ -6,6 +6,7 @@
6
6
  @size={{@textSize}}
7
7
  @textAlign={{@textAlign}}
8
8
  {{did-insert this.setRootNode}}
9
+ {{did-update this.update @value}}
9
10
  ...attributes
10
11
  >
11
12
  {{#each this.result.components as |CompNode|}}
@@ -5,7 +5,7 @@ import {
5
5
  } from '../../utils/markdown/plugins/markdown-default-plugins';
6
6
  import { cached, tracked } from '@glimmer/tracking';
7
7
  import unified, { Processor } from 'unified';
8
- import { toDOM } from '../../utils/markdown/plugins/to-dom';
8
+ import { DynamicComponent, toDOM } from '../../utils/markdown/plugins/to-dom';
9
9
  import type { RehypeNode } from '../../utils/markdown/markdown-types';
10
10
  import type EuiMarkdownEditorComponent from '../eui-markdown-editor';
11
11
 
@@ -18,6 +18,14 @@ export interface EuiMarkdownEditorToolbarArgs {
18
18
 
19
19
  export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMarkdownEditorToolbarArgs> {
20
20
  @tracked rootNode?: HTMLDivElement;
21
+ @tracked result?:
22
+ | {
23
+ element: Node | undefined;
24
+ components: DynamicComponent[];
25
+ }
26
+ | string;
27
+
28
+ _lastValue?: string;
21
29
 
22
30
  get parsingPluginList() {
23
31
  return this.args.parsingPluginList || defaultParsingPlugins;
@@ -29,6 +37,7 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
29
37
 
30
38
  setRootNode = (node: HTMLDivElement) => {
31
39
  this.rootNode = node;
40
+ this.update();
32
41
  };
33
42
 
34
43
  @cached
@@ -47,17 +56,19 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
47
56
  .use(identityCompiler);
48
57
  }
49
58
 
50
- @cached
51
- get result() {
59
+ update = () => {
52
60
  if (this.rootNode) {
61
+ if (this.args.value === this._lastValue) return;
62
+ this._lastValue = this.args.value;
63
+ this.rootNode.innerHTML = '';
53
64
  try {
54
65
  const processed = this.processor.processSync(this.args.value);
55
- return toDOM(processed.result as RehypeNode, this.rootNode);
66
+ this.result = toDOM(processed.result as RehypeNode, this.rootNode);
56
67
  //eslint-disable-next-line
57
68
  } catch (e) {
58
- return this.args.value;
69
+ this.result = this.args.value;
59
70
  }
60
71
  }
61
- return this.args.value;
62
- }
72
+ this.result = this.args.value;
73
+ };
63
74
  }
@@ -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
 
@@ -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.1",
3
+ "version": "5.16.1",
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": "557764dea53e6451c9b229f0dca78ada9c76507c"
189
+ "gitHead": "f415ac77a1e3db648b96f9c4f077230c97b84673"
190
190
  }