@ember-eui/core 7.0.3 → 7.0.6
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.
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
{{! This hbs was inspired by https://github.com/ampatspell/ember-cli-remark-static/blob/v3.0.5/addon/components/remark.hbs }}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
@color={{@color}}
|
|
5
|
-
@grow={{@grow}}
|
|
6
|
-
@size={{@textSize}}
|
|
7
|
-
@textAlign={{@textAlign}}
|
|
8
|
-
{{did-insert this.setRootNode}}
|
|
9
|
-
{{did-update this.update @value}}
|
|
10
|
-
...attributes
|
|
11
|
-
>
|
|
2
|
+
{{#if this.result}}
|
|
3
|
+
{{this.result.element}}
|
|
12
4
|
{{#each this.result.components as |CompNode|}}
|
|
13
5
|
{{#in-element CompNode.element}}
|
|
14
6
|
{{#let
|
|
@@ -22,4 +14,4 @@
|
|
|
22
14
|
{{/let}}
|
|
23
15
|
{{/in-element}}
|
|
24
16
|
{{/each}}
|
|
25
|
-
|
|
17
|
+
{{/if}}
|
|
@@ -3,12 +3,11 @@ import {
|
|
|
3
3
|
defaultParsingPlugins,
|
|
4
4
|
defaultProcessingPlugins
|
|
5
5
|
} from '../../utils/markdown/plugins/markdown-default-plugins';
|
|
6
|
-
import { cached
|
|
6
|
+
import { cached } from '@glimmer/tracking';
|
|
7
7
|
import unified, { Processor } from 'unified';
|
|
8
|
-
import {
|
|
8
|
+
import { 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
|
-
|
|
12
11
|
export interface EuiMarkdownEditorToolbarArgs {
|
|
13
12
|
parsingPluginList?: typeof defaultParsingPlugins;
|
|
14
13
|
processingPluginList?: typeof defaultProcessingPlugins;
|
|
@@ -17,16 +16,6 @@ export interface EuiMarkdownEditorToolbarArgs {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMarkdownEditorToolbarArgs> {
|
|
20
|
-
@tracked rootNode?: HTMLDivElement;
|
|
21
|
-
@tracked result?:
|
|
22
|
-
| {
|
|
23
|
-
element: Node | undefined;
|
|
24
|
-
components: DynamicComponent[];
|
|
25
|
-
}
|
|
26
|
-
| string;
|
|
27
|
-
|
|
28
|
-
_lastValue?: string;
|
|
29
|
-
|
|
30
19
|
get parsingPluginList() {
|
|
31
20
|
return this.args.parsingPluginList || defaultParsingPlugins;
|
|
32
21
|
}
|
|
@@ -35,11 +24,6 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
|
|
|
35
24
|
return this.args.processingPluginList || defaultProcessingPlugins;
|
|
36
25
|
}
|
|
37
26
|
|
|
38
|
-
setRootNode = (node: HTMLDivElement) => {
|
|
39
|
-
this.rootNode = node;
|
|
40
|
-
this.update();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
27
|
@cached
|
|
44
28
|
get processor() {
|
|
45
29
|
const Compiler = (tree: any) => {
|
|
@@ -56,19 +40,16 @@ export default class EuiMarkdownEditorToolbarComponent extends Component<EuiMark
|
|
|
56
40
|
.use(identityCompiler);
|
|
57
41
|
}
|
|
58
42
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.result = this.args.value;
|
|
70
|
-
}
|
|
43
|
+
@cached
|
|
44
|
+
get result() {
|
|
45
|
+
try {
|
|
46
|
+
const processed = this.processor.processSync(this.args.value);
|
|
47
|
+
return toDOM(processed.result as RehypeNode, {
|
|
48
|
+
rootClasses: ['euiMarkdownFormat', 'euiText', 'euiText--medium']
|
|
49
|
+
});
|
|
50
|
+
//eslint-disable-next-line
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return this.args.value;
|
|
71
53
|
}
|
|
72
|
-
|
|
73
|
-
};
|
|
54
|
+
}
|
|
74
55
|
}
|
|
@@ -13,7 +13,12 @@ const createDocument = () => {
|
|
|
13
13
|
|
|
14
14
|
export interface DynamicComponent {}
|
|
15
15
|
|
|
16
|
-
export const toDOM = (
|
|
16
|
+
export const toDOM = (
|
|
17
|
+
tree: RehypeNode,
|
|
18
|
+
options?: {
|
|
19
|
+
rootClasses?: string[];
|
|
20
|
+
}
|
|
21
|
+
) => {
|
|
17
22
|
let document = createDocument();
|
|
18
23
|
let components: DynamicComponent[] = [];
|
|
19
24
|
|
|
@@ -30,14 +35,14 @@ export const toDOM = (tree: RehypeNode, rootNode?: HTMLDivElement) => {
|
|
|
30
35
|
const createElement = (
|
|
31
36
|
name: string,
|
|
32
37
|
node: RehypeNode,
|
|
33
|
-
|
|
38
|
+
classesToAdd?: string[] | string
|
|
34
39
|
) => {
|
|
35
40
|
let element = document.createElement(name);
|
|
36
41
|
let properties = node.properties;
|
|
37
|
-
let
|
|
42
|
+
let finalClassNames = [];
|
|
38
43
|
if (properties) {
|
|
39
44
|
if (properties.className) {
|
|
40
|
-
|
|
45
|
+
finalClassNames.push(...(properties.className as string[]));
|
|
41
46
|
}
|
|
42
47
|
for (let key in properties) {
|
|
43
48
|
if (attributes.includes(key)) {
|
|
@@ -51,12 +56,15 @@ export const toDOM = (tree: RehypeNode, rootNode?: HTMLDivElement) => {
|
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if (classesToAdd) {
|
|
60
|
+
if (Array.isArray(classesToAdd)) {
|
|
61
|
+
finalClassNames.push(...classesToAdd);
|
|
62
|
+
} else {
|
|
63
|
+
finalClassNames.push(classesToAdd);
|
|
64
|
+
}
|
|
59
65
|
}
|
|
66
|
+
|
|
67
|
+
element.classList.add(...finalClassNames);
|
|
60
68
|
return element;
|
|
61
69
|
};
|
|
62
70
|
|
|
@@ -64,10 +72,11 @@ export const toDOM = (tree: RehypeNode, rootNode?: HTMLDivElement) => {
|
|
|
64
72
|
if (node) {
|
|
65
73
|
let { type } = node;
|
|
66
74
|
if (type === 'root') {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
let element = createElement(
|
|
76
|
+
'div',
|
|
77
|
+
node,
|
|
78
|
+
options?.rootClasses || ['root']
|
|
79
|
+
);
|
|
71
80
|
return toElements(element, node.children);
|
|
72
81
|
} else if (type === 'element') {
|
|
73
82
|
let element = createElement(node.tagName, node);
|
|
@@ -76,7 +85,9 @@ export const toDOM = (tree: RehypeNode, rootNode?: HTMLDivElement) => {
|
|
|
76
85
|
return document.createTextNode(node.value);
|
|
77
86
|
} else if (type === 'component') {
|
|
78
87
|
let { inline } = node.properties;
|
|
79
|
-
let element = createElement(inline ? 'span' : 'div', node,
|
|
88
|
+
let element = createElement(inline ? 'span' : 'div', node, [
|
|
89
|
+
'component'
|
|
90
|
+
]);
|
|
80
91
|
let { _children, ...properties } = node.properties;
|
|
81
92
|
let content = toElements(document.createElement('span'), node.children);
|
|
82
93
|
components.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-eui/core",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
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": "dd0f213c42296e63e079c7e13331bf1005dd3566"
|
|
190
190
|
}
|