@ember-eui/core 1.2.6 → 1.4.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/addon/components/common.ts +13 -0
  3. package/addon/components/eui-button/index.hbs +2 -0
  4. package/addon/components/eui-button-content/index.hbs +1 -0
  5. package/addon/components/eui-button-empty/index.hbs +2 -0
  6. package/addon/components/eui-button-icon/index.hbs +2 -0
  7. package/addon/components/eui-code/index.hbs +9 -0
  8. package/addon/components/eui-code-block/index.d.ts +2 -0
  9. package/addon/components/eui-code-block/index.hbs +10 -0
  10. package/addon/components/eui-code-block-impl/code-block-controls/index.hbs +33 -0
  11. package/addon/components/eui-code-block-impl/index.hbs +111 -0
  12. package/addon/components/eui-code-block-impl/index.ts +121 -0
  13. package/addon/components/eui-copy/index.hbs +8 -0
  14. package/addon/components/eui-copy/index.ts +37 -0
  15. package/addon/components/eui-icon/index.hbs +37 -32
  16. package/addon/components/eui-icon/index.ts +1 -1
  17. package/addon/components/eui-inner-text/index.hbs +1 -0
  18. package/addon/components/eui-inner-text/index.ts +61 -0
  19. package/addon/components/eui-markdown-editor/index.hbs +63 -0
  20. package/addon/components/eui-markdown-editor/index.ts +221 -0
  21. package/addon/components/eui-markdown-editor-drop-zone/index.hbs +21 -0
  22. package/addon/components/eui-markdown-editor-drop-zone/index.ts +5 -0
  23. package/addon/components/eui-markdown-editor-footer/index.hbs +108 -0
  24. package/addon/components/eui-markdown-editor-footer/index.ts +20 -0
  25. package/addon/components/eui-markdown-editor-text-area/index.hbs +8 -0
  26. package/addon/components/eui-markdown-editor-toolbar/index.hbs +86 -0
  27. package/addon/components/eui-markdown-editor-toolbar/index.ts +97 -0
  28. package/addon/components/eui-markdown-format/index.hbs +13 -0
  29. package/addon/components/eui-markdown-format/index.ts +55 -0
  30. package/addon/components/eui-markdown-format/markdown-checkbox/index.hbs +8 -0
  31. package/addon/components/eui-markdown-format/markdown-checkbox/index.ts +28 -0
  32. package/addon/components/eui-markdown-format/markdown-code/index.hbs +3 -0
  33. package/addon/components/eui-markdown-format/markdown-code-block/index.hbs +7 -0
  34. package/addon/components/eui-markdown-format/markdown-tooltip/index.hbs +8 -0
  35. package/addon/components/markdown-checkmark-icon/index.hbs +0 -0
  36. package/addon/modifiers/get-cursor-node.ts +54 -0
  37. package/addon/modifiers/resize-observer.ts +6 -2
  38. package/addon/utils/copy-to-clipboard.ts +70 -0
  39. package/addon/utils/css-mappings/eui-code-block-impl.ts +24 -0
  40. package/addon/utils/css-mappings/index.ts +2 -0
  41. package/addon/utils/markdown/markdown-actions.ts +616 -0
  42. package/addon/utils/markdown/markdown-modes.ts +23 -0
  43. package/addon/utils/markdown/markdown-types.ts +140 -0
  44. package/addon/utils/markdown/markdown-unified-plugins.d.ts +27 -0
  45. package/addon/utils/markdown/plugins/markdown-add-components.ts +63 -0
  46. package/addon/utils/markdown/plugins/markdown-checkbox.ts +80 -0
  47. package/addon/utils/markdown/plugins/markdown-default-plugins.ts +77 -0
  48. package/addon/utils/markdown/plugins/markdown-tooltip.ts +113 -0
  49. package/addon/utils/markdown/plugins/to-dom.ts +93 -0
  50. package/app/components/eui-code/index.js +1 -0
  51. package/app/components/eui-code-block/index.js +1 -0
  52. package/app/components/eui-code-block-impl/code-block-controls/index.js +1 -0
  53. package/app/components/eui-code-block-impl/index.js +1 -0
  54. package/app/components/eui-copy/index.js +1 -0
  55. package/app/components/eui-inner-text/index.js +1 -0
  56. package/app/components/eui-markdown-editor/index.js +1 -0
  57. package/app/components/eui-markdown-editor-drop-zone/index.js +1 -0
  58. package/app/components/eui-markdown-editor-footer/index.js +1 -0
  59. package/app/components/eui-markdown-editor-text-area/index.js +1 -0
  60. package/app/components/eui-markdown-editor-toolbar/index.js +1 -0
  61. package/app/components/eui-markdown-format/index.js +1 -0
  62. package/app/components/eui-markdown-format/markdown-checkbox/index.js +1 -0
  63. package/app/components/eui-markdown-format/markdown-code/index.js +1 -0
  64. package/app/components/eui-markdown-format/markdown-code-block/index.js +1 -0
  65. package/app/components/eui-markdown-format/markdown-tooltip/index.js +1 -0
  66. package/app/modifiers/get-cursor-node.js +1 -0
  67. package/app/styles/ember-eui.scss +13 -0
  68. package/app/utils/markdown/plugins/markdown-add-components.js +1 -0
  69. package/app/utils/markdown/plugins/markdown-default-plugins.js +1 -0
  70. package/docs/editors/code/code-block-demo/demo1.md +62 -0
  71. package/docs/editors/code/code-block.md +1 -0
  72. package/docs/editors/code/inline-demo/demo1.md +49 -0
  73. package/docs/editors/code/inline.md +1 -0
  74. package/docs/editors/markdown-editor/base-editor-demo/demo1.md +120 -0
  75. package/docs/editors/markdown-editor/base-editor.md +1 -0
  76. package/package.json +16 -3
  77. package/public/markdown-checkmark.svg +3 -0
  78. package/public/markdown-logo.svg +3 -0
@@ -0,0 +1,62 @@
1
+ ---
2
+ order: 1
3
+ ---
4
+
5
+ # Demo
6
+
7
+ ```hbs template
8
+ <div>
9
+ <EuiCodeBlock
10
+ @language={{this.language}}
11
+ @isCopyable={{true}}
12
+ @overflowHeight='500px'
13
+ >
14
+ {{this.htmlCode}}
15
+ </EuiCodeBlock>
16
+ </div>
17
+ <EuiTextArea
18
+ @value={{this.htmlCode}}
19
+ {{on 'input' (pick 'target.value' (set this 'htmlCode'))}}
20
+ />
21
+
22
+ <EuiSelect
23
+ @value={{this.language}}
24
+ @hasNoInitialSelection={{true}}
25
+ @options={{array
26
+ (hash value='javascript' text='javascript')
27
+ (hash value='html' text='html')
28
+ (hash value='golang' text='golang')
29
+ }}
30
+ @id={{selectId}}
31
+ {{on 'change' (pick 'target.value' (set this 'language'))}}
32
+ >
33
+ <:prepend as |classes|>
34
+ <EuiFormLabel class={{classes}} for={{selectId}}>
35
+ Choose a language
36
+ </EuiFormLabel>
37
+ </:prepend>
38
+ </EuiSelect>
39
+ ```
40
+
41
+ ```javascript component
42
+ import Component from '@glimmer/component';
43
+ import { tracked } from '@glimmer/tracking';
44
+ import { action } from '@ember/object';
45
+
46
+ export default class EuiMarkdownEditor1 extends Component {
47
+ @tracked language = 'html';
48
+ @tracked value = `### hehe
49
+ - [ ] hola
50
+ - [ ] hola
51
+ - [x] hola
52
+ \`\`\`javascript
53
+ class Human {}
54
+ \`\`\`
55
+ `;
56
+ @tracked htmlCode = `<!--I'm an example of HTML-->
57
+ <div>
58
+ asdf
59
+ </div>
60
+ `;
61
+ }
62
+ ```
@@ -0,0 +1 @@
1
+ # CodeBlock
@@ -0,0 +1,49 @@
1
+ ---
2
+ order: 1
3
+ ---
4
+
5
+ # Demo
6
+
7
+ ```hbs template
8
+ <EuiText>
9
+ <p>
10
+ Sometimes you need to emphasize
11
+ <EuiCode>Code</EuiCode>
12
+ like this.
13
+ </p>
14
+ <p>
15
+ You can also pass a language in like
16
+ <EuiCode language='html'>{{this.htmlCode}}</EuiCode>.
17
+ </p>
18
+ <p>
19
+ Make the background transparent like this
20
+ <EuiCode @language='html' @transparentBackground={{true}}>
21
+ {{this.htmlCode}}
22
+ </EuiCode>
23
+ .
24
+ </p>
25
+ </EuiText>
26
+ <EuiTextArea @value={{this.htmlCode}} {{on "input" (pick "target.value" (set this "htmlCode"))}}/>
27
+ ```
28
+
29
+ ```javascript component
30
+ import Component from '@glimmer/component';
31
+ import { tracked } from '@glimmer/tracking';
32
+ import { action } from '@ember/object';
33
+
34
+ export default class EuiMarkdownEditor1 extends Component {
35
+ @tracked value = `### hehe
36
+ - [ ] hola
37
+ - [ ] hola
38
+ - [x] hola
39
+ \`\`\`javascript
40
+ class Human {}
41
+ \`\`\`
42
+ `;
43
+ @tracked htmlCode = `<!--I'm an example of HTML-->
44
+ <div>
45
+ asdf
46
+ </div>
47
+ `;
48
+ }
49
+ ```
@@ -0,0 +1 @@
1
+ # Inline
@@ -0,0 +1,120 @@
1
+ ---
2
+ order: 1
3
+ ---
4
+
5
+ # Demo
6
+
7
+ ```hbs template
8
+ <EuiMarkdownEditor
9
+ @value={{this.value}}
10
+ @onChange={{set this 'value'}}
11
+ @processingPluginList={{this.processingPlugins}}
12
+ />
13
+ ```
14
+
15
+ ```javascript component
16
+ import Component from '@glimmer/component';
17
+ import { tracked } from '@glimmer/tracking';
18
+ import { action } from '@ember/object';
19
+ import { visit } from '@ember-eui/core/utils/markdown/plugins/markdown-add-components';
20
+ import { defaultProcessingPlugins } from '@ember-eui/core/utils/markdown/plugins/markdown-default-plugins';
21
+
22
+
23
+ /*
24
+ Quick example how you can extend plugins, this plugin adds _blank to `a` elements
25
+ */
26
+ function TargetBlankProcessingPlugin() {
27
+ return (tree) => {
28
+ visit(tree, (node) => {
29
+ if (node.type === 'element' && node.tagName === 'a') {
30
+ node.properties.target = '_blank';
31
+ }
32
+ return node;
33
+ });
34
+ };
35
+ }
36
+
37
+ const processingPlugins = [
38
+ ...defaultProcessingPlugins,
39
+ [TargetBlankProcessingPlugin, {}]
40
+ ];
41
+
42
+ export default class EuiMarkdownEditor1 extends Component {
43
+ processingPlugins = processingPlugins;
44
+ @tracked value = `## 👋 Hello there!
45
+
46
+ I'm a **EuiMarkdownEditor** with:
47
+
48
+ - a \`height\` set to \`200\`
49
+ - my parent container is a flex item
50
+
51
+
52
+ ### Things you should know
53
+
54
+ When my content is very long 😅
55
+
56
+ The preview height is automatically adjusted 😉
57
+
58
+ To avoid a scrollbar 😌
59
+
60
+ ### That's why I look good 😍
61
+
62
+ - [ ] First Checkbox
63
+ - [ ] Second Checkbox
64
+ - [x] Third Checkbox
65
+
66
+ \`\`\`ts
67
+ class Human {
68
+ get fullName() {
69
+ return \`${this.name} ${this.lastName}\`;
70
+ }
71
+ }
72
+ \`\`\`
73
+
74
+ \`\`\`golang
75
+ package main
76
+
77
+ import \"fmt\"
78
+
79
+ func main() {
80
+
81
+ // \`var\` declares 1 or more variables.
82
+ var a = "initial"
83
+ fmt.Println(a)
84
+
85
+ // You can declare multiple variables at once.
86
+ var b, c int = 1, 2
87
+ fmt.Println(b, c)
88
+
89
+ // Go will infer the type of initialized variables.
90
+ var d = true
91
+ fmt.Println(d)
92
+
93
+ // Variables declared without a corresponding
94
+ // initialization are _zero-valued_. For example, the
95
+ // zero value for an \`int\` is \`0\`.
96
+ var e int
97
+ fmt.Println(e)
98
+
99
+ // The \`:=\` syntax is shorthand for declaring and
100
+ // initializing a variable, e.g. for
101
+ // \`var f string = "apple"\` in this case.
102
+ f := "apple"
103
+ fmt.Println(f)
104
+ }
105
+
106
+ \`\`\`
107
+
108
+ ----
109
+
110
+ ### You can also add tooltips if you want more explanation!
111
+
112
+ !{tooltip[You can also add tooltips](Some helpful description)}
113
+
114
+ ### And links, check the demo source in how to tweak plugins!
115
+
116
+ [Access Google!](https://google.com)
117
+
118
+ `;
119
+ }
120
+ ```
@@ -0,0 +1 @@
1
+ # Base Editor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-eui/core",
3
- "version": "1.2.6",
3
+ "version": "1.4.0",
4
4
  "description": "Ember Components for Elastic UI",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -77,9 +77,20 @@
77
77
  "ember-style-modifier": "^0.6.0",
78
78
  "ember-svg-jar": "https://github.com/betocantu93/ember-svg-jar.git#add-bundle-flag",
79
79
  "ember-truth-helpers": "^2.1.0",
80
+ "highlight.js": "^9.18.5",
80
81
  "lodash-es": "^4.17.21",
82
+ "mdast-util-to-hast": "^10.0.0",
83
+ "rehype-raw": "^5.0.0",
84
+ "rehype-stringify": "^8.0.0",
85
+ "remark-breaks": "^3.0.2",
86
+ "remark-emoji": "^2.1.0",
87
+ "remark-highlight.js": "^6.0.0",
88
+ "remark-parse": "^8.0.3",
89
+ "remark-rehype": "^8.0.0",
81
90
  "resolve": "^1.13.1",
82
- "tabbable": "^5.1.5"
91
+ "tabbable": "^5.1.5",
92
+ "unified": "^9.2.0",
93
+ "vfile": "^4.2.0"
83
94
  },
84
95
  "devDependencies": {
85
96
  "@ember/optional-features": "^1.3.0",
@@ -121,6 +132,8 @@
121
132
  "eslint-plugin-node": "^11.1.0",
122
133
  "eslint-plugin-prettier": "^3.3.1",
123
134
  "loader.js": "^4.7.0",
135
+ "lodash-es": "^4.17.21",
136
+ "mdast-util-to-hast": "^10.0.0",
124
137
  "npm-run-all": "^4.1.5",
125
138
  "prettier": "^2.2.1",
126
139
  "qunit-dom": "^1.2.0",
@@ -141,5 +154,5 @@
141
154
  "volta": {
142
155
  "node": "12.22.1"
143
156
  },
144
- "gitHead": "86127330c27486495fc56259e63163d5e34642a4"
157
+ "gitHead": "205ab9480989c78d5516232395b233443735bbb6"
145
158
  }
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
2
+ <path d="M11.828 13H4.172A1.173 1.173 0 013 11.828V4.172C3 3.526 3.526 3 4.172 3h7.656C12.474 3 13 3.526 13 4.172v7.656c0 .646-.526 1.172-1.172 1.172zM4.172 3.781a.391.391 0 00-.39.39v7.657c0 .216.175.39.39.39h7.656a.39.39 0 00.39-.39V4.172a.391.391 0 00-.39-.39H4.172zm7.244 2.175l-.582-.521L7.22 9.469 5.125 7.476l-.539.566 2.68 2.548 4.15-4.634z" />
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="26" height="16" fill="none" viewBox="0 0 26 16">
2
+ <path d="M1.25 1.875c0-.345.28-.625.625-.625h22.25c.345 0 .625.28.625.625v12.25c0 .345-.28.625-.625.625H1.875a.625.625 0 01-.625-.625V1.875zM1.875 0C.839 0 0 .84 0 1.875v12.25C0 15.161.84 16 1.875 16h22.25C25.16 16 26 15.16 26 14.125V1.875C26 .839 25.16 0 24.125 0H1.875zM3.75 3.75v8.5h2.5V7.375l2.5 3.125 2.5-3.125v4.875h2.5v-8.5h-2.5l-2.5 3.125-2.5-3.125h-2.5zm11.875 4.375l3.75 4.125 3.75-4.125h-2.5V3.75h-2.5v4.375h-2.5z" />
3
+ </svg>