@player-ui/markdown-plugin 0.4.0-next.11 → 0.4.0-next.12
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/dist/index.cjs.js +24 -12
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +24 -12
- package/dist/markdown-plugin.dev.js +166 -1061
- package/dist/markdown-plugin.prod.js +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -5
- package/src/types.ts +4 -0
- package/src/utils/markdownParser.ts +28 -14
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-ui/markdown-plugin",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@player-ui/player": "0.4.0-next.
|
|
10
|
-
"@player-ui/types": "0.4.0-next.
|
|
9
|
+
"@player-ui/player": "0.4.0-next.12",
|
|
10
|
+
"@player-ui/types": "0.4.0-next.12"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"tapable-ts": "^0.2.3",
|
package/src/index.ts
CHANGED
|
@@ -39,11 +39,7 @@ export class MarkdownPlugin implements PlayerPlugin {
|
|
|
39
39
|
parser: options.parseNode,
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
return parsed[0];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return { ...node, nodeType: NodeType.MultiNode, values: parsed };
|
|
42
|
+
return parsed;
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
return node;
|
package/src/types.ts
CHANGED
|
@@ -45,6 +45,10 @@ export interface Mappers {
|
|
|
45
45
|
* required paragraph (composite) Asset
|
|
46
46
|
*/
|
|
47
47
|
paragraph: CompositeMapper;
|
|
48
|
+
/**
|
|
49
|
+
* required collection Asset to wrap arrays of assets
|
|
50
|
+
*/
|
|
51
|
+
collection: CompositeMapper;
|
|
48
52
|
/**
|
|
49
53
|
* strong markdown (e.g. **bold**)
|
|
50
54
|
*/
|
|
@@ -31,23 +31,37 @@ export function parseAssetMarkdownContent({
|
|
|
31
31
|
type?: Node.ChildrenTypes,
|
|
32
32
|
options?: ParseObjectOptions
|
|
33
33
|
) => Node.Node | null;
|
|
34
|
-
}) {
|
|
34
|
+
}): Node.Node | null {
|
|
35
35
|
const { children } = fromMarkdown(asset.value as string);
|
|
36
|
+
const isMultiParagraph = children.length > 1;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if (isMultiParagraph) {
|
|
39
|
+
const value = children.map((node) => {
|
|
40
|
+
const transformer = transformers[node.type as keyof typeof transformers];
|
|
41
|
+
return transformer({
|
|
42
|
+
astNode: node as any,
|
|
43
|
+
asset,
|
|
44
|
+
mappers,
|
|
45
|
+
transformers,
|
|
46
|
+
});
|
|
44
47
|
});
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
49
|
+
const collection = mappers.collection({
|
|
50
|
+
originalAsset: asset,
|
|
51
|
+
value,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return parser?.(collection, NodeType.Asset) || null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const transformer =
|
|
58
|
+
transformers[children[0].type as keyof typeof transformers];
|
|
59
|
+
const content = transformer({
|
|
60
|
+
astNode: children[0] as any,
|
|
61
|
+
asset,
|
|
62
|
+
mappers,
|
|
63
|
+
transformers,
|
|
52
64
|
});
|
|
65
|
+
|
|
66
|
+
return parser?.(content, NodeType.Asset) || null;
|
|
53
67
|
}
|