@ember-eui/core 1.2.6 → 1.3.3
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/CHANGELOG.md +9 -0
- package/addon/components/common.ts +13 -0
- package/addon/components/eui-button/index.hbs +2 -0
- package/addon/components/eui-button-content/index.hbs +1 -0
- package/addon/components/eui-button-empty/index.hbs +2 -0
- package/addon/components/eui-button-icon/index.hbs +2 -0
- package/addon/components/eui-code/index.hbs +9 -0
- package/addon/components/eui-code-block/index.d.ts +2 -0
- package/addon/components/eui-code-block/index.hbs +10 -0
- package/addon/components/eui-code-block-impl/code-block-controls/index.hbs +33 -0
- package/addon/components/eui-code-block-impl/index.hbs +111 -0
- package/addon/components/eui-code-block-impl/index.ts +121 -0
- package/addon/components/eui-copy/index.hbs +8 -0
- package/addon/components/eui-copy/index.ts +37 -0
- package/addon/components/eui-icon/index.hbs +37 -32
- package/addon/components/eui-inner-text/index.hbs +1 -0
- package/addon/components/eui-inner-text/index.ts +61 -0
- package/addon/components/eui-markdown-editor/index.hbs +63 -0
- package/addon/components/eui-markdown-editor/index.ts +221 -0
- package/addon/components/eui-markdown-editor-drop-zone/index.hbs +21 -0
- package/addon/components/eui-markdown-editor-drop-zone/index.ts +5 -0
- package/addon/components/eui-markdown-editor-footer/index.hbs +108 -0
- package/addon/components/eui-markdown-editor-footer/index.ts +20 -0
- package/addon/components/eui-markdown-editor-text-area/index.hbs +8 -0
- package/addon/components/eui-markdown-editor-toolbar/index.hbs +86 -0
- package/addon/components/eui-markdown-editor-toolbar/index.ts +97 -0
- package/addon/components/eui-markdown-format/index.hbs +13 -0
- package/addon/components/eui-markdown-format/index.ts +45 -0
- package/addon/components/eui-markdown-format/markdown-checkbox/index.hbs +8 -0
- package/addon/components/eui-markdown-format/markdown-checkbox/index.ts +28 -0
- package/addon/components/eui-markdown-format/markdown-code/index.hbs +3 -0
- package/addon/components/eui-markdown-format/markdown-code-block/index.hbs +7 -0
- package/addon/components/eui-markdown-format/markdown-tooltip/index.hbs +8 -0
- package/addon/components/markdown-checkmark-icon/index.hbs +0 -0
- package/addon/modifiers/get-cursor-node.ts +54 -0
- package/addon/modifiers/resize-observer.ts +6 -2
- package/addon/utils/copy-to-clipboard.ts +70 -0
- package/addon/utils/css-mappings/eui-code-block-impl.ts +24 -0
- package/addon/utils/css-mappings/index.ts +2 -0
- package/addon/utils/markdown/markdown-actions.ts +616 -0
- package/addon/utils/markdown/markdown-modes.ts +23 -0
- package/addon/utils/markdown/markdown-types.ts +140 -0
- package/addon/utils/markdown/markdown-unified-plugins.d.ts +27 -0
- package/addon/utils/markdown/plugins/markdown-add-components.ts +63 -0
- package/addon/utils/markdown/plugins/markdown-checkbox.ts +80 -0
- package/addon/utils/markdown/plugins/markdown-default-plugins.ts +100 -0
- package/addon/utils/markdown/plugins/markdown-tooltip.ts +113 -0
- package/addon/utils/markdown/plugins/to-dom.ts +93 -0
- package/app/components/eui-code/index.js +1 -0
- package/app/components/eui-code-block/index.js +1 -0
- package/app/components/eui-code-block-impl/code-block-controls/index.js +1 -0
- package/app/components/eui-code-block-impl/index.js +1 -0
- package/app/components/eui-copy/index.js +1 -0
- package/app/components/eui-inner-text/index.js +1 -0
- package/app/components/eui-markdown-editor/index.js +1 -0
- package/app/components/eui-markdown-editor-drop-zone/index.js +1 -0
- package/app/components/eui-markdown-editor-footer/index.js +1 -0
- package/app/components/eui-markdown-editor-text-area/index.js +1 -0
- package/app/components/eui-markdown-editor-toolbar/index.js +1 -0
- package/app/components/eui-markdown-format/index.js +1 -0
- package/app/components/eui-markdown-format/markdown-checkbox/index.js +1 -0
- package/app/components/eui-markdown-format/markdown-code/index.js +1 -0
- package/app/components/eui-markdown-format/markdown-code-block/index.js +1 -0
- package/app/components/eui-markdown-format/markdown-tooltip/index.js +1 -0
- package/app/modifiers/get-cursor-node.js +1 -0
- package/app/styles/ember-eui.scss +13 -0
- package/docs/editors/code/code-block-demo/demo1.md +62 -0
- package/docs/editors/code/code-block.md +1 -0
- package/docs/editors/code/inline-demo/demo1.md +49 -0
- package/docs/editors/code/inline.md +1 -0
- package/docs/editors/markdown-editor/base-editor-demo/demo1.md +86 -0
- package/docs/editors/markdown-editor/base-editor.md +1 -0
- package/package.json +31 -5
- package/public/markdown-checkmark.svg +3 -0
- package/public/markdown-logo.svg +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
### Master
|
|
4
4
|
|
|
5
|
+
### 1.3.0
|
|
6
|
+
🚀 Enhancements
|
|
7
|
+
`@ember-eui/core`
|
|
8
|
+
- `<EuiMarkdownEditor />` `<EuiMarkdownFormat />` `<EuiCode />` `<EuiCopy />` `<EuiCodeBlock />`
|
|
9
|
+
|
|
10
|
+
`@ember-eui/validated-form`
|
|
11
|
+
- `<Form.FieldMarkdownEditor />`
|
|
12
|
+
|
|
13
|
+
|
|
5
14
|
### 1.2.6
|
|
6
15
|
🐛 Bug / Fixes
|
|
7
16
|
- Update ember-svg-jar dependency
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
// utility types:
|
|
2
|
+
/**
|
|
3
|
+
* XOR for some properties applied to a type
|
|
4
|
+
* (XOR is one of these but not both or neither)
|
|
5
|
+
*
|
|
6
|
+
* Usage: OneOf<typeToExtend, one | but | not | multiple | of | these | are | required>
|
|
7
|
+
*
|
|
8
|
+
* To require aria-label or aria-labelledby but not both
|
|
9
|
+
* Example: OneOf<Type, 'aria-label' | 'aria-labelledby'>
|
|
10
|
+
*/
|
|
11
|
+
export type OneOf<T, K extends keyof T> = Omit<T, K> &
|
|
12
|
+
{ [k in K]: Pick<Required<T>, k> & { [k1 in Exclude<K, k>]?: never } }[K];
|
|
13
|
+
|
|
1
14
|
export interface CommonArgs {
|
|
2
15
|
'aria-label'?: string;
|
|
3
16
|
'data-test-subj'?: string;
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
@iconType={{@iconType}}
|
|
21
21
|
@iconSide={{@iconSide}}
|
|
22
22
|
@iconClasses={{@iconClasses}}
|
|
23
|
+
@useSvg={{@useSvg}}
|
|
23
24
|
@textClasses={{class-names "euiButton__text" @textClasses}}
|
|
24
25
|
>
|
|
25
26
|
{{yield}}
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
@iconType={{@iconType}}
|
|
47
48
|
@iconSide={{@iconSide}}
|
|
48
49
|
@iconClasses={{@iconClasses}}
|
|
50
|
+
@useSvg={{@useSvg}}
|
|
49
51
|
@textClasses={{class-names "euiButton__text" @textClasses}}
|
|
50
52
|
>
|
|
51
53
|
{{yield}}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
@iconType={{@iconType}}
|
|
18
18
|
@iconSide={{@iconSide}}
|
|
19
19
|
@iconClasses={{@iconClasses}}
|
|
20
|
+
@useSvg={{@useSvg}}
|
|
20
21
|
@textClasses={{class-names "euiButtonEmpty__text" @textClasses}}
|
|
21
22
|
>
|
|
22
23
|
{{yield}}
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
@iconType={{@iconType}}
|
|
43
44
|
@iconSide={{@iconSide}}
|
|
44
45
|
@iconClasses={{@iconClasses}}
|
|
46
|
+
@useSvg={{@useSvg}}
|
|
45
47
|
@textClasses={{class-names "euiButtonEmpty__text" @textClasses}}
|
|
46
48
|
>
|
|
47
49
|
{{yield}}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
class="euiButtonIcon__icon {{@iconClasses}}"
|
|
11
11
|
@type={{@iconType}}
|
|
12
12
|
@size={{arg-or-default @iconSize "m"}}
|
|
13
|
+
@useSvg={{@useSvg}}
|
|
13
14
|
aria-hidden="true"
|
|
14
15
|
/>
|
|
15
16
|
{{/if}}
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
class="euiButtonIcon__icon {{@iconClasses}}"
|
|
28
29
|
@type={{@iconType}}
|
|
29
30
|
@size={{@iconSize}}
|
|
31
|
+
@useSvg={{@useSvg}}
|
|
30
32
|
aria-hidden="true"
|
|
31
33
|
/>
|
|
32
34
|
{{/if}}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{{#if (or (and @isCopyable @innerText) @overflowHeight)}}
|
|
2
|
+
<div class="euiCodeBlock__controls">
|
|
3
|
+
{{#if @overflowHeight}}
|
|
4
|
+
<EuiButtonIcon
|
|
5
|
+
class="euiCodeBlock__fullScreenButton"
|
|
6
|
+
@size="s"
|
|
7
|
+
{{on "click" @toggleFullScreen}}
|
|
8
|
+
@iconType={{if @isFullScreen "cross" "fullScreen"}}
|
|
9
|
+
@color="text"
|
|
10
|
+
aria-label={{if @isFullScreen "Collapse" "Expand"}}
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if (and @isCopyable @innerText)}}
|
|
15
|
+
<div class="euiCodeBlock__copyButton">
|
|
16
|
+
<EuiCopy
|
|
17
|
+
@textToCopy={{@innerText}}
|
|
18
|
+
@beforeMessage="Copy"
|
|
19
|
+
@afterMessage="Copied"
|
|
20
|
+
as |copy|
|
|
21
|
+
>
|
|
22
|
+
<EuiButtonIcon
|
|
23
|
+
@size="s"
|
|
24
|
+
{{on "click" copy}}
|
|
25
|
+
@iconType="copy"
|
|
26
|
+
@color="text"
|
|
27
|
+
aria-label="Copy"
|
|
28
|
+
/>
|
|
29
|
+
</EuiCopy>
|
|
30
|
+
</div>
|
|
31
|
+
{{/if}}
|
|
32
|
+
</div>
|
|
33
|
+
{{/if}}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{{#let
|
|
2
|
+
(class-names
|
|
3
|
+
"euiCodeBlock__pre"
|
|
4
|
+
(if (eq this.whiteSpace "pre") "euiCodeBlock__pre--whiteSpacePre")
|
|
5
|
+
(if (eq this.whiteSpace "pre-wrap") "euiCodeBlock__pre--whiteSpacePreWrap")
|
|
6
|
+
)
|
|
7
|
+
(class-names "euiCodeBlock__code" @language)
|
|
8
|
+
(class-names
|
|
9
|
+
"euiCodeBlock"
|
|
10
|
+
(if this.transparentBackground "euiCodeBlock--transparentBackground")
|
|
11
|
+
(if @inline "euiCodeBlock--inline")
|
|
12
|
+
(if (or @isCopyable @overflowHeight) "euiCodeBlock--hasControls")
|
|
13
|
+
componentName="EuiCodeBlockImpl"
|
|
14
|
+
paddingSize=this.paddingSize
|
|
15
|
+
fontSize=this.fontSize
|
|
16
|
+
)
|
|
17
|
+
as |preClasses codeClasses classes|
|
|
18
|
+
}}
|
|
19
|
+
{{#if @inline}}
|
|
20
|
+
{{#if this.isPortalTargetReady}}
|
|
21
|
+
{{#in-element this.codeTarget}}
|
|
22
|
+
{{yield}}
|
|
23
|
+
{{/in-element}}
|
|
24
|
+
<span
|
|
25
|
+
class={{classes}}
|
|
26
|
+
{{style (if @overflowHeight (hash maxHeight=@overflowHeight))}}
|
|
27
|
+
><code
|
|
28
|
+
{{did-insert (set this "code")}}
|
|
29
|
+
class={{codeClasses}}
|
|
30
|
+
></code></span>
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{else}}
|
|
33
|
+
{{! Not inline }}
|
|
34
|
+
{{#if this.isPortalTargetReady}}
|
|
35
|
+
{{#in-element this.codeTarget}}
|
|
36
|
+
{{yield}}
|
|
37
|
+
{{/in-element}}
|
|
38
|
+
<EuiInnerText @fallback="" as |setRef innerText|>
|
|
39
|
+
<div
|
|
40
|
+
class={{classes}}
|
|
41
|
+
{{style (if @overflowHeight (hash maxHeight=@overflowHeight))}}
|
|
42
|
+
>
|
|
43
|
+
<pre
|
|
44
|
+
{{did-insert setRef}}
|
|
45
|
+
class={{preClasses}}
|
|
46
|
+
{{style (if @overflowHeight (hash maxHeight=@overflowHeight))}}
|
|
47
|
+
><code
|
|
48
|
+
{{did-insert (set this "code")}}
|
|
49
|
+
class={{codeClasses}}
|
|
50
|
+
></code></pre>
|
|
51
|
+
|
|
52
|
+
<EuiCodeBlockImpl::CodeBlockControls
|
|
53
|
+
@innerText={{innerText}}
|
|
54
|
+
@isCopyable={{@isCopyable}}
|
|
55
|
+
@overflowHeight={{@overflowHeight}}
|
|
56
|
+
@toggleFullScreen={{set this "isFullScreen" (not this.isFullScreen)}}
|
|
57
|
+
@isFullScreen={{this.isFullScreen}}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
{{#if this.isFullScreen}}
|
|
61
|
+
<EuiOverlayMask>
|
|
62
|
+
<div
|
|
63
|
+
{{focus-trap
|
|
64
|
+
isActive=true
|
|
65
|
+
focusTrapOptions=(hash
|
|
66
|
+
clickOutsideDeactivates=true returnFocusOnDeactivate=true
|
|
67
|
+
)
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
class={{class-names
|
|
72
|
+
"euiCodeBlock euiCodeBlock-paddingLarge euiCodeBlock-isFullScreen"
|
|
73
|
+
fontSize=this.fontSize
|
|
74
|
+
componentName="EuiCodeBlockImpl"
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<pre class={{preClasses}}>
|
|
78
|
+
{{!template-lint-disable}}
|
|
79
|
+
<code
|
|
80
|
+
{{did-insert
|
|
81
|
+
(queue (set this "codeFullScreen") this.update)
|
|
82
|
+
}}
|
|
83
|
+
{{will-destroy (set this "codeFullScreen" null)}}
|
|
84
|
+
{{did-update this.update @language}}
|
|
85
|
+
class={{codeClasses}}
|
|
86
|
+
tabIndex={{0}}
|
|
87
|
+
tabIndex={{0}}
|
|
88
|
+
{{on "keydown" this.onKeyDown}}
|
|
89
|
+
></code>
|
|
90
|
+
{{!template-lint-enable}}
|
|
91
|
+
</pre>
|
|
92
|
+
<EuiCodeBlockImpl::CodeBlockControls
|
|
93
|
+
@innerText={{innerText}}
|
|
94
|
+
@isCopyable={{@isCopyable}}
|
|
95
|
+
@overflowHeight={{@overflowHeight}}
|
|
96
|
+
@toggleFullScreen={{set
|
|
97
|
+
this
|
|
98
|
+
"isFullScreen"
|
|
99
|
+
(not this.isFullScreen)
|
|
100
|
+
}}
|
|
101
|
+
@isFullScreen={{this.isFullScreen}}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</EuiOverlayMask>
|
|
106
|
+
{{/if}}
|
|
107
|
+
</div>
|
|
108
|
+
</EuiInnerText>
|
|
109
|
+
{{/if}}
|
|
110
|
+
{{/if}}
|
|
111
|
+
{{/let}}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { argOrDefaultDecorator as argOrDefault } from '../../helpers/arg-or-default';
|
|
5
|
+
import { PaddingSize, FontSize } from '../eui-code-block';
|
|
6
|
+
//@ts-ignore
|
|
7
|
+
import hljs from 'highlight.js';
|
|
8
|
+
import { keys } from '../../utils/keys';
|
|
9
|
+
import { scheduleOnce } from '@ember/runloop';
|
|
10
|
+
|
|
11
|
+
type EuiCodeImplArgs = {
|
|
12
|
+
fontSize?: FontSize;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Displays the passed code in an inline format. Also removes any margins set.
|
|
16
|
+
*/
|
|
17
|
+
inline?: boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Displays an icon button to copy the code snippet to the clipboard.
|
|
21
|
+
*/
|
|
22
|
+
isCopyable?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets the syntax highlighting for a specific language
|
|
26
|
+
*/
|
|
27
|
+
language?: string;
|
|
28
|
+
overflowHeight?: number;
|
|
29
|
+
paddingSize?: PaddingSize;
|
|
30
|
+
transparentBackground?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specify how `white-space` inside the element is handled.
|
|
33
|
+
* `pre` respects line breaks/white space but doesn't force them to wrap the line
|
|
34
|
+
* `pre-wrap` respects line breaks/white space but does force them to wrap the line when necessary.
|
|
35
|
+
*/
|
|
36
|
+
whiteSpace?: 'pre' | 'pre-wrap';
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default class EuiAccordionAccordionComponent extends Component<EuiCodeImplArgs> {
|
|
40
|
+
// Defaults
|
|
41
|
+
@argOrDefault(false) declare transparentBackground: boolean;
|
|
42
|
+
@argOrDefault('l') declare paddingSize: string;
|
|
43
|
+
@argOrDefault('s') declare fontSize: string;
|
|
44
|
+
@argOrDefault(false) declare isCopyable: boolean;
|
|
45
|
+
@argOrDefault('pre-wrap') declare whiteSpace: string;
|
|
46
|
+
|
|
47
|
+
@tracked isFullScreen: boolean = false;
|
|
48
|
+
@tracked isPortalTargetReady: boolean = false;
|
|
49
|
+
@tracked codeTarget: HTMLDivElement | null = null;
|
|
50
|
+
@tracked code: HTMLElement | null = null;
|
|
51
|
+
@tracked codeFullScreen: HTMLElement | null = null;
|
|
52
|
+
|
|
53
|
+
observer: MutationObserver | null = null;
|
|
54
|
+
|
|
55
|
+
constructor(owner: unknown, args: EuiCodeImplArgs) {
|
|
56
|
+
super(owner, args);
|
|
57
|
+
this.codeTarget = document.createElement('div');
|
|
58
|
+
this.isPortalTargetReady = true;
|
|
59
|
+
this.setupObserver();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setupObserver() {
|
|
63
|
+
this.observer?.disconnect();
|
|
64
|
+
this.observer = new MutationObserver((mutationsList) => {
|
|
65
|
+
if (mutationsList.length) this.update();
|
|
66
|
+
});
|
|
67
|
+
if (this.codeTarget) {
|
|
68
|
+
this.update();
|
|
69
|
+
this.observer.observe(this.codeTarget, {
|
|
70
|
+
characterData: true,
|
|
71
|
+
subtree: true,
|
|
72
|
+
childList: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
willDestroy(): void {
|
|
78
|
+
this.observer?.disconnect();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@action
|
|
82
|
+
update() {
|
|
83
|
+
const render = () => {
|
|
84
|
+
const language = this.args.language;
|
|
85
|
+
const html = (
|
|
86
|
+
this.isPortalTargetReady && this.codeTarget?.innerHTML
|
|
87
|
+
? this.codeTarget.innerHTML
|
|
88
|
+
: ''
|
|
89
|
+
).trim();
|
|
90
|
+
|
|
91
|
+
const code = this.code;
|
|
92
|
+
|
|
93
|
+
if (code) {
|
|
94
|
+
code.innerHTML = html;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (language) {
|
|
98
|
+
if (code) {
|
|
99
|
+
hljs.highlightBlock(code);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.codeFullScreen) {
|
|
104
|
+
this.codeFullScreen.innerHTML = html;
|
|
105
|
+
if (language) {
|
|
106
|
+
hljs.highlightBlock(this.codeFullScreen);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
scheduleOnce('afterRender', this, render);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@action
|
|
114
|
+
onKeyDown(event: KeyboardEvent): void {
|
|
115
|
+
if (event.key === keys.ESCAPE) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
this.isFullScreen = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { copyToClipboard } from '../../utils/copy-to-clipboard';
|
|
5
|
+
|
|
6
|
+
type EuiCopyArgs = {
|
|
7
|
+
/**
|
|
8
|
+
* Text that will be copied to clipboard when copy function is executed.
|
|
9
|
+
*/
|
|
10
|
+
textToCopy: string;
|
|
11
|
+
/**
|
|
12
|
+
* Tooltip message displayed before copy function is called.
|
|
13
|
+
*/
|
|
14
|
+
beforeMessage?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Tooltip message displayed after copy function is called that lets the user know that
|
|
17
|
+
* 'textToCopy' has been copied to the clipboard.
|
|
18
|
+
*/
|
|
19
|
+
afterMessage?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default class EuiCopyComponent extends Component<EuiCopyArgs> {
|
|
23
|
+
@tracked tooltipText = this.args.beforeMessage;
|
|
24
|
+
|
|
25
|
+
@action
|
|
26
|
+
copy(): void {
|
|
27
|
+
const isCopied = copyToClipboard(this.args.textToCopy);
|
|
28
|
+
if (isCopied) {
|
|
29
|
+
this.tooltipText = this.args.afterMessage;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@action
|
|
34
|
+
resetTooltipText(): void {
|
|
35
|
+
this.tooltipText = this.args.beforeMessage;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
{{#if this.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class={{class-names
|
|
5
|
-
this.optionalColorClass
|
|
6
|
-
(if this.isAppIcon "euiIcon--app")
|
|
7
|
-
componentName="EuiIcon"
|
|
8
|
-
size=this.size
|
|
9
|
-
}}
|
|
10
|
-
alt={{if @title @title}}
|
|
11
|
-
tabIndex={{@tabIndex}}
|
|
12
|
-
...attributes
|
|
13
|
-
/>
|
|
1
|
+
{{#if this.icon.inner}}
|
|
2
|
+
{{! has the shape of a curried component }}
|
|
3
|
+
{{component this.icon}}
|
|
14
4
|
{{else}}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
{{#if this.useImage}}
|
|
6
|
+
<img
|
|
7
|
+
src={{this.icon}}
|
|
8
|
+
class={{class-names
|
|
9
|
+
this.optionalColorClass
|
|
10
|
+
(if this.isAppIcon "euiIcon--app")
|
|
11
|
+
componentName="EuiIcon"
|
|
12
|
+
size=this.size
|
|
13
|
+
}}
|
|
14
|
+
alt={{if @title @title}}
|
|
15
|
+
tabIndex={{@tabIndex}}
|
|
16
|
+
...attributes
|
|
17
|
+
/>
|
|
18
|
+
{{else}}
|
|
19
|
+
<Svg
|
|
20
|
+
@name={{this.icon}}
|
|
21
|
+
@loadingSvg={{this.emptyIcon}}
|
|
22
|
+
class={{class-names
|
|
23
|
+
this.optionalColorClass
|
|
24
|
+
(if this.isAppIcon "euiIcon--app")
|
|
25
|
+
componentName="EuiIcon"
|
|
26
|
+
size=this.size
|
|
27
|
+
}}
|
|
28
|
+
style={{this.optionalCustomStyles}}
|
|
29
|
+
tabIndex={{this.tabIndex}}
|
|
30
|
+
role="image"
|
|
31
|
+
aria-hidden={{if this.isAriaHidden true}}
|
|
32
|
+
aria-label={{if @aria-label @aria-label this.titleId}}
|
|
33
|
+
aria-labelledby={{if @aria-labelledby @aria-labelledby this.titleId}}
|
|
34
|
+
@title={{@title}}
|
|
35
|
+
@onIconLoad={{@onIconLoad}}
|
|
36
|
+
...attributes
|
|
37
|
+
/>
|
|
38
|
+
{{/if}}
|
|
34
39
|
{{/if}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{yield this.setRef this.innerText}}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import GlimmerComponent from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
|
|
5
|
+
type InnerTextArgs = {
|
|
6
|
+
fallback?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default class EuiImage extends GlimmerComponent<InnerTextArgs> {
|
|
10
|
+
@tracked ref: HTMLElement | null = null;
|
|
11
|
+
@tracked innerText = '';
|
|
12
|
+
observer: MutationObserver | null = null;
|
|
13
|
+
|
|
14
|
+
get innerTextFallback() {
|
|
15
|
+
return this.args.fallback ?? '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setupObserver() {
|
|
19
|
+
this.observer?.disconnect();
|
|
20
|
+
this.observer = new MutationObserver((mutationsList) => {
|
|
21
|
+
if (mutationsList.length) this.updateInnerText(this.ref);
|
|
22
|
+
});
|
|
23
|
+
if (this.ref) {
|
|
24
|
+
this.updateInnerText(this.ref);
|
|
25
|
+
this.observer.observe(this.ref, {
|
|
26
|
+
characterData: true,
|
|
27
|
+
subtree: true,
|
|
28
|
+
childList: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
updateInnerText(node: HTMLElement | null) {
|
|
34
|
+
if (!node) return;
|
|
35
|
+
this.setInnerText(
|
|
36
|
+
// Check for `innerText` implementation rather than a simple OR check
|
|
37
|
+
// because in real cases the result of `innerText` could correctly be `null`
|
|
38
|
+
// while the result of `textContent` could correctly be non-`null` due to
|
|
39
|
+
// differing reliance on browser layout calculations.
|
|
40
|
+
// We prefer the result of `innerText`, if available.
|
|
41
|
+
'innerText' in node
|
|
42
|
+
? node.innerText
|
|
43
|
+
: (node as HTMLElement).textContent || this.innerTextFallback
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setInnerText(text: string) {
|
|
48
|
+
this.innerText = text;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@action
|
|
52
|
+
setRef(ref: HTMLElement): void {
|
|
53
|
+
this.ref = ref;
|
|
54
|
+
this.setupObserver();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
willDestroy(): void {
|
|
58
|
+
super.willDestroy();
|
|
59
|
+
this.observer?.disconnect();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class={{class-names
|
|
3
|
+
"euiMarkdownEditor"
|
|
4
|
+
(if (eq this.height "full") "euiMarkdownEditor--fullHeight")
|
|
5
|
+
(if this.isPreviewing "euiMarkdownEditor--isPreviewing")
|
|
6
|
+
}}
|
|
7
|
+
{{did-update
|
|
8
|
+
this.updateCurrentHeight
|
|
9
|
+
this.currentHeight
|
|
10
|
+
this.isPreviewing
|
|
11
|
+
this.height
|
|
12
|
+
this.autoExpandPreview
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<EuiMarkdownEditorToolbar
|
|
16
|
+
@selectedNode={{this.selectedNode}}
|
|
17
|
+
@markdownActions={{this.markdownActions}}
|
|
18
|
+
@onClickPreview={{this.setViewMode}}
|
|
19
|
+
@viewMode={{this.viewMode}}
|
|
20
|
+
@uiPlugins={{this.toolbarPlugins}}
|
|
21
|
+
{{did-insert this.setEditorToolbarRef}}
|
|
22
|
+
/>
|
|
23
|
+
{{#if this.isPreviewing}}
|
|
24
|
+
<div
|
|
25
|
+
class="euiMarkdownEditorPreview"
|
|
26
|
+
{{did-insert (set this "previewRef")}}
|
|
27
|
+
{{style (hash height=this.previewHeight)}}
|
|
28
|
+
>
|
|
29
|
+
<EuiMarkdownFormat
|
|
30
|
+
@parsingPluginList={{this.parsingPluginList}}
|
|
31
|
+
@processingPluginList={{this.processingPluginList}}
|
|
32
|
+
@value={{@value}}
|
|
33
|
+
@replaceNode={{this.replaceNode}}
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
{{/if}}
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
class="euiMarkdownEditor__toggleContainer"
|
|
40
|
+
{{style height=this.editorToggleContainerHeight}}
|
|
41
|
+
>
|
|
42
|
+
<EuiMarkdownEditorDropZone
|
|
43
|
+
@uiPlugins={{this.toolbarPlugins}}
|
|
44
|
+
{{resize-observer onResize=this.onResize}}
|
|
45
|
+
>
|
|
46
|
+
<EuiMarkdownEditorTextArea
|
|
47
|
+
{{get-cursor-node (get this.parsed "0") this.setSelectedNode}}
|
|
48
|
+
{{did-update this.onParse this.parsed}}
|
|
49
|
+
{{did-insert this.setTextAreaRef}}
|
|
50
|
+
disabled={{@disabled}}
|
|
51
|
+
id={{this.editorId}}
|
|
52
|
+
@height={{this.textAreaHeight}}
|
|
53
|
+
@maxHeight={{this.textAreaMaxHeight}}
|
|
54
|
+
value={{@value}}
|
|
55
|
+
aria-label={{@ariaLabel}}
|
|
56
|
+
aria-labelledby={{@ariaLabelledBy}}
|
|
57
|
+
aria-describedby={{@ariaDescribedBy}}
|
|
58
|
+
{{on "input" (pick "target.value" @onChange)}}
|
|
59
|
+
...attributes
|
|
60
|
+
/>
|
|
61
|
+
</EuiMarkdownEditorDropZone>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|