@ember-eui/core 5.14.6 → 5.15.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.
|
@@ -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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
}
|
|
@@ -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') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.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": "
|
|
189
|
+
"gitHead": "557764dea53e6451c9b229f0dca78ada9c76507c"
|
|
190
190
|
}
|