@player-ui/markdown-plugin 0.11.0-next.3 → 0.11.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/package.json
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-ui/markdown-plugin",
|
|
9
|
-
"version": "0.11.0
|
|
9
|
+
"version": "0.11.0",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@player-ui/player": "0.11.0
|
|
13
|
-
"@player-ui/types": "0.11.0
|
|
12
|
+
"@player-ui/player": "0.11.0",
|
|
13
|
+
"@player-ui/types": "0.11.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@player-ui/partial-match-fingerprint-plugin": "workspace:*",
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { Asset, AssetWrapper } from "@player-ui/types";
|
|
2
2
|
import type { Mappers } from "../../types";
|
|
3
3
|
|
|
4
|
-
// Mock Asset Plugin implementation of the markdown plugin:
|
|
5
|
-
|
|
6
|
-
let depth = 0;
|
|
7
|
-
|
|
8
4
|
/**
|
|
9
5
|
* Wrap an Asset in an AssetWrapper
|
|
10
6
|
*/
|
|
@@ -66,94 +62,98 @@ function applyModifierToAssets({
|
|
|
66
62
|
return modifiedAsset;
|
|
67
63
|
}
|
|
68
64
|
|
|
69
|
-
export const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
value
|
|
74
|
-
}),
|
|
75
|
-
collection: ({ originalAsset, value }) => ({
|
|
76
|
-
id: `${originalAsset.id}-collection-${depth++}`,
|
|
77
|
-
type: "collection",
|
|
78
|
-
values: value.map(wrapAsset),
|
|
79
|
-
}),
|
|
80
|
-
strong: ({ originalAsset, value }) =>
|
|
81
|
-
flatSingleElementCompositeAsset({
|
|
82
|
-
id: `${originalAsset.id}-text-${depth++}`,
|
|
83
|
-
type: "composite",
|
|
84
|
-
values: value.map((v) =>
|
|
85
|
-
wrapAsset(
|
|
86
|
-
applyModifierToAssets({
|
|
87
|
-
asset: v,
|
|
88
|
-
types: ["text"],
|
|
89
|
-
modifiers: [
|
|
90
|
-
{
|
|
91
|
-
type: "tag",
|
|
92
|
-
value: "important",
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
}),
|
|
96
|
-
),
|
|
97
|
-
),
|
|
98
|
-
}),
|
|
99
|
-
emphasis: ({ originalAsset, value }) =>
|
|
100
|
-
flatSingleElementCompositeAsset({
|
|
65
|
+
export const buildMockMappers = (): Mappers => {
|
|
66
|
+
let depth = 0;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
text: ({ originalAsset, value }) => ({
|
|
101
70
|
id: `${originalAsset.id}-text-${depth++}`,
|
|
102
|
-
type: "
|
|
103
|
-
|
|
104
|
-
wrapAsset(
|
|
105
|
-
applyModifierToAssets({
|
|
106
|
-
asset: v,
|
|
107
|
-
types: ["text"],
|
|
108
|
-
modifiers: [
|
|
109
|
-
{
|
|
110
|
-
type: "tag",
|
|
111
|
-
value: "emphasis",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
}),
|
|
115
|
-
),
|
|
116
|
-
),
|
|
71
|
+
type: "text",
|
|
72
|
+
value,
|
|
117
73
|
}),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type: "composite",
|
|
74
|
+
collection: ({ originalAsset, value }) => ({
|
|
75
|
+
id: `${originalAsset.id}-collection-${depth++}`,
|
|
76
|
+
type: "collection",
|
|
122
77
|
values: value.map(wrapAsset),
|
|
123
78
|
}),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}),
|
|
138
|
-
link: ({ originalAsset, value, href }) =>
|
|
139
|
-
flatSingleElementCompositeAsset({
|
|
140
|
-
id: `${originalAsset.id}-link-${depth++}`,
|
|
141
|
-
type: "composite",
|
|
142
|
-
values: value.map((v) =>
|
|
143
|
-
wrapAsset(
|
|
144
|
-
applyModifierToAssets({
|
|
145
|
-
asset: v,
|
|
146
|
-
types: ["text", "image"],
|
|
147
|
-
modifiers: [
|
|
148
|
-
{
|
|
149
|
-
type: "link",
|
|
150
|
-
metaData: {
|
|
151
|
-
ref: href,
|
|
79
|
+
strong: ({ originalAsset, value }) =>
|
|
80
|
+
flatSingleElementCompositeAsset({
|
|
81
|
+
id: `${originalAsset.id}-text-${depth++}`,
|
|
82
|
+
type: "composite",
|
|
83
|
+
values: value.map((v) =>
|
|
84
|
+
wrapAsset(
|
|
85
|
+
applyModifierToAssets({
|
|
86
|
+
asset: v,
|
|
87
|
+
types: ["text"],
|
|
88
|
+
modifiers: [
|
|
89
|
+
{
|
|
90
|
+
type: "tag",
|
|
91
|
+
value: "important",
|
|
152
92
|
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
),
|
|
156
96
|
),
|
|
157
|
-
),
|
|
97
|
+
}),
|
|
98
|
+
emphasis: ({ originalAsset, value }) =>
|
|
99
|
+
flatSingleElementCompositeAsset({
|
|
100
|
+
id: `${originalAsset.id}-text-${depth++}`,
|
|
101
|
+
type: "composite",
|
|
102
|
+
values: value.map((v) =>
|
|
103
|
+
wrapAsset(
|
|
104
|
+
applyModifierToAssets({
|
|
105
|
+
asset: v,
|
|
106
|
+
types: ["text"],
|
|
107
|
+
modifiers: [
|
|
108
|
+
{
|
|
109
|
+
type: "tag",
|
|
110
|
+
value: "emphasis",
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
}),
|
|
114
|
+
),
|
|
115
|
+
),
|
|
116
|
+
}),
|
|
117
|
+
paragraph: ({ originalAsset, value }) =>
|
|
118
|
+
flatSingleElementCompositeAsset({
|
|
119
|
+
id: `${originalAsset.id}-composite-${depth++}`,
|
|
120
|
+
type: "composite",
|
|
121
|
+
values: value.map(wrapAsset),
|
|
122
|
+
}),
|
|
123
|
+
list: ({ originalAsset, value, ordered }) => ({
|
|
124
|
+
id: `${originalAsset.id}-list-${depth++}`,
|
|
125
|
+
type: "list",
|
|
126
|
+
values: value.map(wrapAsset),
|
|
127
|
+
...(ordered && { metaData: { listType: "ordered" } }),
|
|
158
128
|
}),
|
|
129
|
+
image: ({ originalAsset, value, src }) => ({
|
|
130
|
+
id: `${originalAsset.id}-image-${depth++}`,
|
|
131
|
+
type: "image",
|
|
132
|
+
accessibility: value,
|
|
133
|
+
metaData: {
|
|
134
|
+
ref: src,
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
link: ({ originalAsset, value, href }) =>
|
|
138
|
+
flatSingleElementCompositeAsset({
|
|
139
|
+
id: `${originalAsset.id}-link-${depth++}`,
|
|
140
|
+
type: "composite",
|
|
141
|
+
values: value.map((v) =>
|
|
142
|
+
wrapAsset(
|
|
143
|
+
applyModifierToAssets({
|
|
144
|
+
asset: v,
|
|
145
|
+
types: ["text", "image"],
|
|
146
|
+
modifiers: [
|
|
147
|
+
{
|
|
148
|
+
type: "link",
|
|
149
|
+
metaData: {
|
|
150
|
+
ref: href,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
),
|
|
157
|
+
}),
|
|
158
|
+
};
|
|
159
159
|
};
|
|
@@ -3,7 +3,7 @@ import type { InProgressState, Flow } from "@player-ui/player";
|
|
|
3
3
|
import { Player } from "@player-ui/player";
|
|
4
4
|
import { Registry } from "@player-ui/partial-match-registry";
|
|
5
5
|
import { PartialMatchFingerprintPlugin } from "@player-ui/partial-match-fingerprint-plugin";
|
|
6
|
-
import {
|
|
6
|
+
import { buildMockMappers } from "./helpers";
|
|
7
7
|
import { MarkdownPlugin } from "..";
|
|
8
8
|
|
|
9
9
|
describe("MarkdownPlugin", () => {
|
|
@@ -103,7 +103,7 @@ describe("MarkdownPlugin", () => {
|
|
|
103
103
|
|
|
104
104
|
it("parses the flow containing markdown into valid FRF, based on the given mappers", () => {
|
|
105
105
|
const player = new Player({
|
|
106
|
-
plugins: [new MarkdownPlugin(
|
|
106
|
+
plugins: [new MarkdownPlugin(buildMockMappers())],
|
|
107
107
|
});
|
|
108
108
|
player.start(unparsedFlow);
|
|
109
109
|
|
|
@@ -120,19 +120,19 @@ describe("MarkdownPlugin", () => {
|
|
|
120
120
|
"values": [
|
|
121
121
|
{
|
|
122
122
|
"asset": {
|
|
123
|
-
"id": "markdown-primaryInfo-collection-bold-composite-
|
|
123
|
+
"id": "markdown-primaryInfo-collection-bold-composite-3",
|
|
124
124
|
"type": "composite",
|
|
125
125
|
"values": [
|
|
126
126
|
{
|
|
127
127
|
"asset": {
|
|
128
|
-
"id": "markdown-primaryInfo-collection-bold-text-
|
|
128
|
+
"id": "markdown-primaryInfo-collection-bold-text-0",
|
|
129
129
|
"type": "text",
|
|
130
130
|
"value": "some ",
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
134
|
"asset": {
|
|
135
|
-
"id": "markdown-primaryInfo-collection-bold-text-
|
|
135
|
+
"id": "markdown-primaryInfo-collection-bold-text-1",
|
|
136
136
|
"modifiers": [
|
|
137
137
|
{
|
|
138
138
|
"type": "tag",
|
|
@@ -148,7 +148,7 @@ describe("MarkdownPlugin", () => {
|
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
"asset": {
|
|
151
|
-
"id": "markdown-primaryInfo-collection-italic-text-
|
|
151
|
+
"id": "markdown-primaryInfo-collection-italic-text-4",
|
|
152
152
|
"modifiers": [
|
|
153
153
|
{
|
|
154
154
|
"type": "tag",
|
|
@@ -161,7 +161,7 @@ describe("MarkdownPlugin", () => {
|
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"asset": {
|
|
164
|
-
"id": "markdown-primaryInfo-collection-orderd-list-list-
|
|
164
|
+
"id": "markdown-primaryInfo-collection-orderd-list-list-16",
|
|
165
165
|
"metaData": {
|
|
166
166
|
"listType": "ordered",
|
|
167
167
|
},
|
|
@@ -169,21 +169,21 @@ describe("MarkdownPlugin", () => {
|
|
|
169
169
|
"values": [
|
|
170
170
|
{
|
|
171
171
|
"asset": {
|
|
172
|
-
"id": "markdown-primaryInfo-collection-orderd-list-text-
|
|
172
|
+
"id": "markdown-primaryInfo-collection-orderd-list-text-7",
|
|
173
173
|
"type": "text",
|
|
174
174
|
"value": "First",
|
|
175
175
|
},
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
"asset": {
|
|
179
|
-
"id": "markdown-primaryInfo-collection-orderd-list-text-
|
|
179
|
+
"id": "markdown-primaryInfo-collection-orderd-list-text-10",
|
|
180
180
|
"type": "text",
|
|
181
181
|
"value": "Second",
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
185
|
"asset": {
|
|
186
|
-
"id": "markdown-primaryInfo-collection-orderd-list-text-
|
|
186
|
+
"id": "markdown-primaryInfo-collection-orderd-list-text-13",
|
|
187
187
|
"type": "text",
|
|
188
188
|
"value": "Third",
|
|
189
189
|
},
|
|
@@ -193,12 +193,12 @@ describe("MarkdownPlugin", () => {
|
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
"asset": {
|
|
196
|
-
"id": "markdown-primaryInfo-collection-unorderd-list-list-
|
|
196
|
+
"id": "markdown-primaryInfo-collection-unorderd-list-list-27",
|
|
197
197
|
"type": "list",
|
|
198
198
|
"values": [
|
|
199
199
|
{
|
|
200
200
|
"asset": {
|
|
201
|
-
"id": "markdown-primaryInfo-collection-unorderd-list-text-
|
|
201
|
+
"id": "markdown-primaryInfo-collection-unorderd-list-text-17",
|
|
202
202
|
"modifiers": [
|
|
203
203
|
{
|
|
204
204
|
"metaData": {
|
|
@@ -213,14 +213,14 @@ describe("MarkdownPlugin", () => {
|
|
|
213
213
|
},
|
|
214
214
|
{
|
|
215
215
|
"asset": {
|
|
216
|
-
"id": "markdown-primaryInfo-collection-unorderd-list-text-
|
|
216
|
+
"id": "markdown-primaryInfo-collection-unorderd-list-text-21",
|
|
217
217
|
"type": "text",
|
|
218
218
|
"value": "Second",
|
|
219
219
|
},
|
|
220
220
|
},
|
|
221
221
|
{
|
|
222
222
|
"asset": {
|
|
223
|
-
"id": "markdown-primaryInfo-collection-unorderd-list-text-
|
|
223
|
+
"id": "markdown-primaryInfo-collection-unorderd-list-text-24",
|
|
224
224
|
"type": "text",
|
|
225
225
|
"value": "Third",
|
|
226
226
|
},
|
|
@@ -231,7 +231,7 @@ describe("MarkdownPlugin", () => {
|
|
|
231
231
|
{
|
|
232
232
|
"asset": {
|
|
233
233
|
"accessibility": "alt text",
|
|
234
|
-
"id": "markdown-primaryInfo-collection-image-image-
|
|
234
|
+
"id": "markdown-primaryInfo-collection-image-image-28",
|
|
235
235
|
"metaData": {
|
|
236
236
|
"ref": "image.png",
|
|
237
237
|
},
|
|
@@ -240,7 +240,7 @@ describe("MarkdownPlugin", () => {
|
|
|
240
240
|
},
|
|
241
241
|
{
|
|
242
242
|
"asset": {
|
|
243
|
-
"id": "markdown-primaryInfo-collection-unsupported-text-
|
|
243
|
+
"id": "markdown-primaryInfo-collection-unsupported-text-30",
|
|
244
244
|
"type": "text",
|
|
245
245
|
"value": "Highlights are ==not supported==",
|
|
246
246
|
},
|
|
@@ -250,19 +250,19 @@ describe("MarkdownPlugin", () => {
|
|
|
250
250
|
},
|
|
251
251
|
"title": {
|
|
252
252
|
"asset": {
|
|
253
|
-
"id": "markdown-view-title-composite-
|
|
253
|
+
"id": "markdown-view-title-composite-35",
|
|
254
254
|
"type": "composite",
|
|
255
255
|
"values": [
|
|
256
256
|
{
|
|
257
257
|
"asset": {
|
|
258
|
-
"id": "markdown-view-title-text-
|
|
258
|
+
"id": "markdown-view-title-text-32",
|
|
259
259
|
"type": "text",
|
|
260
260
|
"value": "Learn more at ",
|
|
261
261
|
},
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
264
|
"asset": {
|
|
265
|
-
"id": "markdown-view-title-text-
|
|
265
|
+
"id": "markdown-view-title-text-33",
|
|
266
266
|
"modifiers": [
|
|
267
267
|
{
|
|
268
268
|
"metaData": {
|
|
@@ -287,9 +287,9 @@ describe("MarkdownPlugin", () => {
|
|
|
287
287
|
const player = new Player({
|
|
288
288
|
plugins: [
|
|
289
289
|
new MarkdownPlugin({
|
|
290
|
-
text:
|
|
291
|
-
paragraph:
|
|
292
|
-
collection:
|
|
290
|
+
text: buildMockMappers().text,
|
|
291
|
+
paragraph: buildMockMappers().paragraph,
|
|
292
|
+
collection: buildMockMappers().collection,
|
|
293
293
|
}),
|
|
294
294
|
],
|
|
295
295
|
});
|
|
@@ -347,7 +347,7 @@ describe("MarkdownPlugin", () => {
|
|
|
347
347
|
},
|
|
348
348
|
{
|
|
349
349
|
"asset": {
|
|
350
|
-
"id": "markdown-primaryInfo-collection-unsupported-text-
|
|
350
|
+
"id": "markdown-primaryInfo-collection-unsupported-text-0",
|
|
351
351
|
"type": "text",
|
|
352
352
|
"value": "Highlights are ==not supported==",
|
|
353
353
|
},
|
|
@@ -377,7 +377,7 @@ describe("MarkdownPlugin", () => {
|
|
|
377
377
|
fingerprint.register({ type: "composite" }, 2);
|
|
378
378
|
|
|
379
379
|
const player = new Player({
|
|
380
|
-
plugins: [fingerprint, new MarkdownPlugin(
|
|
380
|
+
plugins: [fingerprint, new MarkdownPlugin(buildMockMappers())],
|
|
381
381
|
});
|
|
382
382
|
|
|
383
383
|
player.start({
|
|
@@ -428,19 +428,19 @@ describe("MarkdownPlugin", () => {
|
|
|
428
428
|
"id": "action",
|
|
429
429
|
"label": {
|
|
430
430
|
"asset": {
|
|
431
|
-
"id": "action-label-composite-
|
|
431
|
+
"id": "action-label-composite-3",
|
|
432
432
|
"type": "composite",
|
|
433
433
|
"values": [
|
|
434
434
|
{
|
|
435
435
|
"asset": {
|
|
436
|
-
"id": "action-label-text-
|
|
436
|
+
"id": "action-label-text-0",
|
|
437
437
|
"type": "text",
|
|
438
438
|
"value": "Clicked 0 ",
|
|
439
439
|
},
|
|
440
440
|
},
|
|
441
441
|
{
|
|
442
442
|
"asset": {
|
|
443
|
-
"id": "action-label-text-
|
|
443
|
+
"id": "action-label-text-1",
|
|
444
444
|
"modifiers": [
|
|
445
445
|
{
|
|
446
446
|
"type": "tag",
|
|
@@ -457,8 +457,8 @@ describe("MarkdownPlugin", () => {
|
|
|
457
457
|
"type": "action",
|
|
458
458
|
}
|
|
459
459
|
`);
|
|
460
|
-
expect(fingerprint.get("action-label-text-
|
|
461
|
-
expect(fingerprint.get("action-label-text-
|
|
460
|
+
expect(fingerprint.get("action-label-text-0")).toBe(1);
|
|
461
|
+
expect(fingerprint.get("action-label-text-1")).toBe(1);
|
|
462
462
|
});
|
|
463
463
|
});
|
|
464
464
|
});
|