@ember-eui/core 1.3.5 → 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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### Master
4
4
 
5
+ ### 1.4.0
6
+ 🚀 Enhancements
7
+ - Easier extending of processing plugins, add demo
5
8
  ### 1.3.5
6
9
  🐛 Bug / Fixes
7
10
  - Urls for markdown editor icons
@@ -5,7 +5,7 @@ import {
5
5
  defaultProcessingPlugins
6
6
  } from '../../utils/markdown/plugins/markdown-default-plugins';
7
7
  import { cached } from '@glimmer/tracking';
8
- import unified from 'unified';
8
+ import unified, { Processor } from 'unified';
9
9
  import { toDOM } from '../../utils/markdown/plugins/to-dom';
10
10
  import type { RehypeNode } from '../../utils/markdown/markdown-types';
11
11
 
@@ -28,7 +28,17 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
28
28
 
29
29
  @cached
30
30
  get processor() {
31
- return unified().use(this.parsingPluginList).use(this.processingPluginList);
31
+ const Compiler = (tree: any) => {
32
+ return tree;
33
+ };
34
+
35
+ function identityCompiler(this: Processor) {
36
+ this.Compiler = Compiler;
37
+ }
38
+ return unified()
39
+ .use(this.parsingPluginList)
40
+ .use(this.processingPluginList)
41
+ .use(identityCompiler);
32
42
  }
33
43
 
34
44
  @cached
@@ -34,12 +34,6 @@ import {
34
34
  Settings
35
35
  } from 'unified';
36
36
  import remark2Rehype from 'remark-rehype';
37
- import { RehypeNode } from '../markdown-types';
38
- // import * as MarkdownTooltip from './markdown_tooltip';
39
- // import * as MarkdownCheckbox from './markdown_checkbox';
40
- // import { markdownLinkValidator } from './markdown_link_validator';
41
- // import { EuiLink } from '../../link';
42
- // import { EuiCodeBlock, EuiCode } from '../../code';
43
37
  import markdown from 'remark-parse';
44
38
  import emoji from 'remark-emoji';
45
39
  import all from 'mdast-util-to-hast/lib/all';
@@ -71,29 +65,12 @@ const unknownHandler: Handler = (h, node) => {
71
65
 
72
66
  export const defaultParsingPlugins = getDefaultEuiMarkdownParsingPlugins();
73
67
 
74
- class Compiler {
75
- tree: RehypeNode | null = null;
76
- constructor(tree: RehypeNode) {
77
- this.tree = tree;
78
- }
79
-
80
- compile() {
81
- return this.tree;
82
- }
83
- }
84
-
85
- function compiler() {
86
- //@ts-expect-error
87
- this.Compiler = Compiler;
88
- }
89
-
90
68
  export const getDefaultEuiMarkdownProcessingPlugins = (): [
91
69
  [typeof remark2Rehype, Record<string, unknown>],
92
70
  ...PluggableList // any additional are generic
93
71
  ] => [
94
72
  [remark2Rehype, { allowDangerousHtml: true, unknownHandler }],
95
- [MarkdownAddComponents, {}],
96
- [compiler]
73
+ [MarkdownAddComponents, {}]
97
74
  ];
98
75
 
99
76
  export const defaultProcessingPlugins =
@@ -0,0 +1 @@
1
+ export { default } from '@ember-eui/core/utils/markdown/plugins/markdown-add-components';
@@ -0,0 +1 @@
1
+ export { default } from '@ember-eui/core/utils/markdown/plugins/markdown-default-plugins';
@@ -8,6 +8,7 @@ order: 1
8
8
  <EuiMarkdownEditor
9
9
  @value={{this.value}}
10
10
  @onChange={{set this 'value'}}
11
+ @processingPluginList={{this.processingPlugins}}
11
12
  />
12
13
  ```
13
14
 
@@ -15,8 +16,31 @@ order: 1
15
16
  import Component from '@glimmer/component';
16
17
  import { tracked } from '@glimmer/tracking';
17
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
+ ];
18
41
 
19
42
  export default class EuiMarkdownEditor1 extends Component {
43
+ processingPlugins = processingPlugins;
20
44
  @tracked value = `## 👋 Hello there!
21
45
 
22
46
  I'm a **EuiMarkdownEditor** with:
@@ -81,6 +105,16 @@ func main() {
81
105
 
82
106
  \`\`\`
83
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
+
84
118
  `;
85
119
  }
86
120
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-eui/core",
3
- "version": "1.3.5",
3
+ "version": "1.4.0",
4
4
  "description": "Ember Components for Elastic UI",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -154,5 +154,5 @@
154
154
  "volta": {
155
155
  "node": "12.22.1"
156
156
  },
157
- "gitHead": "93a5c9c6617c34c8851c48aba32380ad6ee9e945"
157
+ "gitHead": "205ab9480989c78d5516232395b233443735bbb6"
158
158
  }