@quesmed/types 2.4.10 → 2.4.11

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.
Files changed (27) hide show
  1. package/dist/cjs/models/Picture.d.ts +1 -0
  2. package/dist/cjs/resolvers/fragments/chapter.js +1 -0
  3. package/dist/cjs/resolvers/fragments/marksheet.js +1 -0
  4. package/dist/cjs/resolvers/fragments/picture.js +1 -0
  5. package/dist/cjs/resolvers/mutation/restricted/marksheet.js +12 -0
  6. package/dist/cjs/resolvers/query/restricted/marksheet.js +13 -0
  7. package/dist/cjs/resolvers/query/restricted/quesBook.js +1 -0
  8. package/dist/cjs/resolvers/query/restricted/question.js +4 -0
  9. package/dist/cjs/resolvers/query/restricted/todos.js +1 -0
  10. package/dist/cjs/resolvers/query/restricted/video.js +2 -0
  11. package/dist/cjs/resolvers/query/sample.js +2 -0
  12. package/dist/cjs/resolvers/query/video.js +2 -0
  13. package/dist/cjs/utils/lightgallery.js +25 -12
  14. package/dist/mjs/models/Picture.d.ts +1 -0
  15. package/dist/mjs/resolvers/fragments/chapter.js +1 -0
  16. package/dist/mjs/resolvers/fragments/marksheet.js +1 -0
  17. package/dist/mjs/resolvers/fragments/picture.js +1 -0
  18. package/dist/mjs/resolvers/mutation/restricted/marksheet.js +12 -0
  19. package/dist/mjs/resolvers/query/restricted/marksheet.js +13 -0
  20. package/dist/mjs/resolvers/query/restricted/quesBook.js +1 -0
  21. package/dist/mjs/resolvers/query/restricted/question.js +4 -0
  22. package/dist/mjs/resolvers/query/restricted/todos.js +1 -0
  23. package/dist/mjs/resolvers/query/restricted/video.js +2 -0
  24. package/dist/mjs/resolvers/query/sample.js +2 -0
  25. package/dist/mjs/resolvers/query/video.js +2 -0
  26. package/dist/mjs/utils/lightgallery.js +25 -12
  27. package/package.json +1 -1
@@ -12,6 +12,7 @@ export interface IPicture {
12
12
  path256: string;
13
13
  topicId: Id;
14
14
  topic: ITopic;
15
+ index: number;
15
16
  }
16
17
  export interface ICardPicture {
17
18
  id: Id;
@@ -18,6 +18,7 @@ exports.CHAPTER_FIELDS = (0, client_1.gql) `
18
18
  path
19
19
  path512
20
20
  path256
21
+ index
21
22
  topicId
22
23
  topic {
23
24
  id
@@ -86,6 +86,7 @@ exports.MARKSHEET_MARK_FIELDS = (0, client_1.gql) `
86
86
  path
87
87
  path512
88
88
  path256
89
+ index
89
90
  topicId
90
91
  topic {
91
92
  id
@@ -12,6 +12,7 @@ exports.PICTURE_FIELDS = (0, client_1.gql) `
12
12
  path
13
13
  path512
14
14
  path256
15
+ index
15
16
  topicId
16
17
  topic {
17
18
  id
@@ -129,6 +129,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
129
129
  path
130
130
  path512
131
131
  path256
132
+ index
132
133
  topicId
133
134
  topic {
134
135
  id
@@ -248,6 +249,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
248
249
  path
249
250
  path512
250
251
  path256
252
+ index
251
253
  topicId
252
254
  topic {
253
255
  id
@@ -370,6 +372,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
370
372
  path
371
373
  path512
372
374
  path256
375
+ index
373
376
  topicId
374
377
  topic {
375
378
  id
@@ -489,6 +492,7 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
489
492
  path
490
493
  path512
491
494
  path256
495
+ index
492
496
  topicId
493
497
  topic {
494
498
  id
@@ -703,6 +707,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
703
707
  path
704
708
  path512
705
709
  path256
710
+ index
706
711
  topicId
707
712
  topic {
708
713
  id
@@ -822,6 +827,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
822
827
  path
823
828
  path512
824
829
  path256
830
+ index
825
831
  topicId
826
832
  topic {
827
833
  id
@@ -944,6 +950,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
944
950
  path
945
951
  path512
946
952
  path256
953
+ index
947
954
  topicId
948
955
  topic {
949
956
  id
@@ -1063,6 +1070,7 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
1063
1070
  path
1064
1071
  path512
1065
1072
  path256
1073
+ index
1066
1074
  topicId
1067
1075
  topic {
1068
1076
  id
@@ -1282,6 +1290,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1282
1290
  path
1283
1291
  path512
1284
1292
  path256
1293
+ index
1285
1294
  topicId
1286
1295
  topic {
1287
1296
  id
@@ -1401,6 +1410,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1401
1410
  path
1402
1411
  path512
1403
1412
  path256
1413
+ index
1404
1414
  topicId
1405
1415
  topic {
1406
1416
  id
@@ -1523,6 +1533,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1523
1533
  path
1524
1534
  path512
1525
1535
  path256
1536
+ index
1526
1537
  topicId
1527
1538
  topic {
1528
1539
  id
@@ -1642,6 +1653,7 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1642
1653
  path
1643
1654
  path512
1644
1655
  path256
1656
+ index
1645
1657
  topicId
1646
1658
  topic {
1647
1659
  id
@@ -135,6 +135,7 @@ exports.MARKSHEET = (0, client_1.gql) `
135
135
  path
136
136
  path512
137
137
  path256
138
+ index
138
139
  topicId
139
140
  topic {
140
141
  id
@@ -254,6 +255,7 @@ exports.MARKSHEET = (0, client_1.gql) `
254
255
  path
255
256
  path512
256
257
  path256
258
+ index
257
259
  topicId
258
260
  topic {
259
261
  id
@@ -376,6 +378,7 @@ exports.MARKSHEET = (0, client_1.gql) `
376
378
  path
377
379
  path512
378
380
  path256
381
+ index
379
382
  topicId
380
383
  topic {
381
384
  id
@@ -495,6 +498,7 @@ exports.MARKSHEET = (0, client_1.gql) `
495
498
  path
496
499
  path512
497
500
  path256
501
+ index
498
502
  topicId
499
503
  topic {
500
504
  id
@@ -698,6 +702,7 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
698
702
  path
699
703
  path512
700
704
  path256
705
+ index
701
706
  topicId
702
707
  topic {
703
708
  id
@@ -820,6 +825,7 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
820
825
  path
821
826
  path512
822
827
  path256
828
+ index
823
829
  topicId
824
830
  topic {
825
831
  id
@@ -939,6 +945,7 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
939
945
  path
940
946
  path512
941
947
  path256
948
+ index
942
949
  topicId
943
950
  topic {
944
951
  id
@@ -1061,6 +1068,7 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
1061
1068
  path
1062
1069
  path512
1063
1070
  path256
1071
+ index
1064
1072
  topicId
1065
1073
  topic {
1066
1074
  id
@@ -1180,6 +1188,7 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
1180
1188
  path
1181
1189
  path512
1182
1190
  path256
1191
+ index
1183
1192
  topicId
1184
1193
  topic {
1185
1194
  id
@@ -1387,6 +1396,7 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1387
1396
  path
1388
1397
  path512
1389
1398
  path256
1399
+ index
1390
1400
  topicId
1391
1401
  topic {
1392
1402
  id
@@ -1506,6 +1516,7 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1506
1516
  path
1507
1517
  path512
1508
1518
  path256
1519
+ index
1509
1520
  topicId
1510
1521
  topic {
1511
1522
  id
@@ -1628,6 +1639,7 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1628
1639
  path
1629
1640
  path512
1630
1641
  path256
1642
+ index
1631
1643
  topicId
1632
1644
  topic {
1633
1645
  id
@@ -1747,6 +1759,7 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1747
1759
  path
1748
1760
  path512
1749
1761
  path256
1762
+ index
1750
1763
  topicId
1751
1764
  topic {
1752
1765
  id
@@ -25,6 +25,7 @@ exports.QUES_BOOK = (0, client_1.gql) `
25
25
  path
26
26
  path512
27
27
  path256
28
+ index
28
29
  }
29
30
  }
30
31
  topicId
@@ -78,6 +78,7 @@ exports.QUESTION = (0, client_1.gql) `
78
78
  path
79
79
  path512
80
80
  path256
81
+ index
81
82
  topicId
82
83
  topic {
83
84
  id
@@ -197,6 +198,7 @@ exports.QUESTION = (0, client_1.gql) `
197
198
  path
198
199
  path512
199
200
  path256
201
+ index
200
202
  topicId
201
203
  topic {
202
204
  id
@@ -319,6 +321,7 @@ exports.QUESTION = (0, client_1.gql) `
319
321
  path
320
322
  path512
321
323
  path256
324
+ index
322
325
  topicId
323
326
  topic {
324
327
  id
@@ -438,6 +441,7 @@ exports.QUESTION = (0, client_1.gql) `
438
441
  path
439
442
  path512
440
443
  path256
444
+ index
441
445
  topicId
442
446
  topic {
443
447
  id
@@ -65,6 +65,7 @@ exports.TODO = (0, client_1.gql) `
65
65
  path
66
66
  path512
67
67
  path256
68
+ index
68
69
  }
69
70
  }
70
71
  }
@@ -27,6 +27,7 @@ exports.VIDEO = (0, client_1.gql) `
27
27
  path
28
28
  path512
29
29
  path256
30
+ index
30
31
  topicId
31
32
  }
32
33
  }
@@ -169,6 +170,7 @@ exports.VIDEOS = (0, client_1.gql) `
169
170
  path
170
171
  path512
171
172
  path256
173
+ index
172
174
  }
173
175
  }
174
176
  }
@@ -59,6 +59,7 @@ exports.SAMPLE_MARKSHEET = (0, client_1.gql) `
59
59
  path
60
60
  path512
61
61
  path256
62
+ index
62
63
  topicId
63
64
  topic {
64
65
  id
@@ -122,6 +123,7 @@ exports.SAMPLE_TODO = (0, client_1.gql) `
122
123
  path
123
124
  path512
124
125
  path256
126
+ index
125
127
  topicId
126
128
  topic {
127
129
  id
@@ -47,6 +47,7 @@ exports.SAMPLE_VIDEOS = (0, client_1.gql) `
47
47
  path
48
48
  path512
49
49
  path256
50
+ index
50
51
  topicId
51
52
  topic {
52
53
  id
@@ -83,6 +84,7 @@ exports.SAMPLE_VIDEO = (0, client_1.gql) `
83
84
  path
84
85
  path512
85
86
  path256
87
+ index
86
88
  topicId
87
89
  topic {
88
90
  id
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lightgalleryOsceResolve = void 0;
4
- const lightgalleryRegex = /\[(lightgallery){1}[0-9]{0,}\]/;
4
+ const lightgalleryRegex = /\[lightgallery([0-9]{0,})\]/;
5
5
  function isOsceMarksheet(data) {
6
6
  return 'osceStationId' in data;
7
7
  }
@@ -55,7 +55,7 @@ const lightgalleryMutation = async (text, pictures, cache) => {
55
55
  if (pictures.length === 0) {
56
56
  return text;
57
57
  }
58
- const picturesHTML = [];
58
+ const picturesMdMap = {};
59
59
  for (const picture of pictures) {
60
60
  const pic = picture.path;
61
61
  const uri = `https://app.quesmed.com/${pic}`;
@@ -74,19 +74,32 @@ const lightgalleryMutation = async (text, pictures, cache) => {
74
74
  console.error(e);
75
75
  }
76
76
  }
77
+ let mdPic = `![${file}](${uri})`;
77
78
  if (picture.caption?.length > 0) {
78
- picturesHTML.push(`![${file}](${uri} "${picture.caption}")`);
79
+ mdPic = `![${file}](${uri} "${picture.caption}")`;
79
80
  }
80
- picturesHTML.push(`![${file}](${uri})`);
81
+ if (!picturesMdMap[picture.index]) {
82
+ picturesMdMap[picture.index] = [];
83
+ }
84
+ picturesMdMap[picture.index].push(mdPic);
81
85
  }
82
- if (lightgalleryRegex.test(text)) {
83
- picturesHTML.forEach((image, index) => {
84
- const lightgalleryTagToReplace = `[lightgallery${!index ? '' : index}]`;
85
- text = text.replace(lightgalleryTagToReplace, image);
86
- });
87
- return text;
86
+ const matches = text.matchAll(lightgalleryRegex);
87
+ let matchExists = false;
88
+ for (const match of matches) {
89
+ const index = parseInt(match[1]);
90
+ if (index === 0) {
91
+ matchExists = true;
92
+ }
93
+ if (!picturesMdMap[index]) {
94
+ // TODO: report to sentry or err that lightgallery pictures are missing
95
+ continue;
96
+ }
97
+ const mdPics = picturesMdMap[index].join(' ');
98
+ const lightgalleryTagToReplace = `[lightgallery${index > 0 ? index : ''}]`;
99
+ text = text.replace(lightgalleryTagToReplace, mdPics);
88
100
  }
89
- else {
90
- return text + '\n\n' + picturesHTML[0] + '\n';
101
+ if (!matchExists) {
102
+ return text + '\n\n' + picturesMdMap[0].join(' ') + '\n';
91
103
  }
104
+ return text;
92
105
  };
@@ -12,6 +12,7 @@ export interface IPicture {
12
12
  path256: string;
13
13
  topicId: Id;
14
14
  topic: ITopic;
15
+ index: number;
15
16
  }
16
17
  export interface ICardPicture {
17
18
  id: Id;
@@ -15,6 +15,7 @@ export const CHAPTER_FIELDS = gql `
15
15
  path
16
16
  path512
17
17
  path256
18
+ index
18
19
  topicId
19
20
  topic {
20
21
  id
@@ -83,6 +83,7 @@ export const MARKSHEET_MARK_FIELDS = gql `
83
83
  path
84
84
  path512
85
85
  path256
86
+ index
86
87
  topicId
87
88
  topic {
88
89
  id
@@ -9,6 +9,7 @@ export const PICTURE_FIELDS = gql `
9
9
  path
10
10
  path512
11
11
  path256
12
+ index
12
13
  topicId
13
14
  topic {
14
15
  id
@@ -126,6 +126,7 @@ export const BUILD_QUESTION_MARKSHEET = gql `
126
126
  path
127
127
  path512
128
128
  path256
129
+ index
129
130
  topicId
130
131
  topic {
131
132
  id
@@ -245,6 +246,7 @@ export const BUILD_QUESTION_MARKSHEET = gql `
245
246
  path
246
247
  path512
247
248
  path256
249
+ index
248
250
  topicId
249
251
  topic {
250
252
  id
@@ -367,6 +369,7 @@ export const BUILD_QUESTION_MARKSHEET = gql `
367
369
  path
368
370
  path512
369
371
  path256
372
+ index
370
373
  topicId
371
374
  topic {
372
375
  id
@@ -486,6 +489,7 @@ export const BUILD_QUESTION_MARKSHEET = gql `
486
489
  path
487
490
  path512
488
491
  path256
492
+ index
489
493
  topicId
490
494
  topic {
491
495
  id
@@ -700,6 +704,7 @@ export const BUILD_MARKSHEET = gql `
700
704
  path
701
705
  path512
702
706
  path256
707
+ index
703
708
  topicId
704
709
  topic {
705
710
  id
@@ -819,6 +824,7 @@ export const BUILD_MARKSHEET = gql `
819
824
  path
820
825
  path512
821
826
  path256
827
+ index
822
828
  topicId
823
829
  topic {
824
830
  id
@@ -941,6 +947,7 @@ export const BUILD_MARKSHEET = gql `
941
947
  path
942
948
  path512
943
949
  path256
950
+ index
944
951
  topicId
945
952
  topic {
946
953
  id
@@ -1060,6 +1067,7 @@ export const BUILD_MARKSHEET = gql `
1060
1067
  path
1061
1068
  path512
1062
1069
  path256
1070
+ index
1063
1071
  topicId
1064
1072
  topic {
1065
1073
  id
@@ -1279,6 +1287,7 @@ export const RE_BUILD_MARKSHEET = gql `
1279
1287
  path
1280
1288
  path512
1281
1289
  path256
1290
+ index
1282
1291
  topicId
1283
1292
  topic {
1284
1293
  id
@@ -1398,6 +1407,7 @@ export const RE_BUILD_MARKSHEET = gql `
1398
1407
  path
1399
1408
  path512
1400
1409
  path256
1410
+ index
1401
1411
  topicId
1402
1412
  topic {
1403
1413
  id
@@ -1520,6 +1530,7 @@ export const RE_BUILD_MARKSHEET = gql `
1520
1530
  path
1521
1531
  path512
1522
1532
  path256
1533
+ index
1523
1534
  topicId
1524
1535
  topic {
1525
1536
  id
@@ -1639,6 +1650,7 @@ export const RE_BUILD_MARKSHEET = gql `
1639
1650
  path
1640
1651
  path512
1641
1652
  path256
1653
+ index
1642
1654
  topicId
1643
1655
  topic {
1644
1656
  id
@@ -132,6 +132,7 @@ export const MARKSHEET = gql `
132
132
  path
133
133
  path512
134
134
  path256
135
+ index
135
136
  topicId
136
137
  topic {
137
138
  id
@@ -251,6 +252,7 @@ export const MARKSHEET = gql `
251
252
  path
252
253
  path512
253
254
  path256
255
+ index
254
256
  topicId
255
257
  topic {
256
258
  id
@@ -373,6 +375,7 @@ export const MARKSHEET = gql `
373
375
  path
374
376
  path512
375
377
  path256
378
+ index
376
379
  topicId
377
380
  topic {
378
381
  id
@@ -492,6 +495,7 @@ export const MARKSHEET = gql `
492
495
  path
493
496
  path512
494
497
  path256
498
+ index
495
499
  topicId
496
500
  topic {
497
501
  id
@@ -695,6 +699,7 @@ export const FLAGGED_QUESTIONS = gql `
695
699
  path
696
700
  path512
697
701
  path256
702
+ index
698
703
  topicId
699
704
  topic {
700
705
  id
@@ -817,6 +822,7 @@ export const FLAGGED_QUESTIONS = gql `
817
822
  path
818
823
  path512
819
824
  path256
825
+ index
820
826
  topicId
821
827
  topic {
822
828
  id
@@ -936,6 +942,7 @@ export const FLAGGED_QUESTIONS = gql `
936
942
  path
937
943
  path512
938
944
  path256
945
+ index
939
946
  topicId
940
947
  topic {
941
948
  id
@@ -1058,6 +1065,7 @@ export const FLAGGED_QUESTIONS = gql `
1058
1065
  path
1059
1066
  path512
1060
1067
  path256
1068
+ index
1061
1069
  topicId
1062
1070
  topic {
1063
1071
  id
@@ -1177,6 +1185,7 @@ export const FLAGGED_QUESTIONS = gql `
1177
1185
  path
1178
1186
  path512
1179
1187
  path256
1188
+ index
1180
1189
  topicId
1181
1190
  topic {
1182
1191
  id
@@ -1384,6 +1393,7 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1384
1393
  path
1385
1394
  path512
1386
1395
  path256
1396
+ index
1387
1397
  topicId
1388
1398
  topic {
1389
1399
  id
@@ -1503,6 +1513,7 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1503
1513
  path
1504
1514
  path512
1505
1515
  path256
1516
+ index
1506
1517
  topicId
1507
1518
  topic {
1508
1519
  id
@@ -1625,6 +1636,7 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1625
1636
  path
1626
1637
  path512
1627
1638
  path256
1639
+ index
1628
1640
  topicId
1629
1641
  topic {
1630
1642
  id
@@ -1744,6 +1756,7 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1744
1756
  path
1745
1757
  path512
1746
1758
  path256
1759
+ index
1747
1760
  topicId
1748
1761
  topic {
1749
1762
  id
@@ -22,6 +22,7 @@ export const QUES_BOOK = gql `
22
22
  path
23
23
  path512
24
24
  path256
25
+ index
25
26
  }
26
27
  }
27
28
  topicId
@@ -75,6 +75,7 @@ export const QUESTION = gql `
75
75
  path
76
76
  path512
77
77
  path256
78
+ index
78
79
  topicId
79
80
  topic {
80
81
  id
@@ -194,6 +195,7 @@ export const QUESTION = gql `
194
195
  path
195
196
  path512
196
197
  path256
198
+ index
197
199
  topicId
198
200
  topic {
199
201
  id
@@ -316,6 +318,7 @@ export const QUESTION = gql `
316
318
  path
317
319
  path512
318
320
  path256
321
+ index
319
322
  topicId
320
323
  topic {
321
324
  id
@@ -435,6 +438,7 @@ export const QUESTION = gql `
435
438
  path
436
439
  path512
437
440
  path256
441
+ index
438
442
  topicId
439
443
  topic {
440
444
  id
@@ -62,6 +62,7 @@ export const TODO = gql `
62
62
  path
63
63
  path512
64
64
  path256
65
+ index
65
66
  }
66
67
  }
67
68
  }
@@ -24,6 +24,7 @@ export const VIDEO = gql `
24
24
  path
25
25
  path512
26
26
  path256
27
+ index
27
28
  topicId
28
29
  }
29
30
  }
@@ -166,6 +167,7 @@ export const VIDEOS = gql `
166
167
  path
167
168
  path512
168
169
  path256
170
+ index
169
171
  }
170
172
  }
171
173
  }
@@ -56,6 +56,7 @@ export const SAMPLE_MARKSHEET = gql `
56
56
  path
57
57
  path512
58
58
  path256
59
+ index
59
60
  topicId
60
61
  topic {
61
62
  id
@@ -119,6 +120,7 @@ export const SAMPLE_TODO = gql `
119
120
  path
120
121
  path512
121
122
  path256
123
+ index
122
124
  topicId
123
125
  topic {
124
126
  id
@@ -44,6 +44,7 @@ export const SAMPLE_VIDEOS = gql `
44
44
  path
45
45
  path512
46
46
  path256
47
+ index
47
48
  topicId
48
49
  topic {
49
50
  id
@@ -80,6 +81,7 @@ export const SAMPLE_VIDEO = gql `
80
81
  path
81
82
  path512
82
83
  path256
84
+ index
83
85
  topicId
84
86
  topic {
85
87
  id
@@ -1,4 +1,4 @@
1
- const lightgalleryRegex = /\[(lightgallery){1}[0-9]{0,}\]/;
1
+ const lightgalleryRegex = /\[lightgallery([0-9]{0,})\]/;
2
2
  function isOsceMarksheet(data) {
3
3
  return 'osceStationId' in data;
4
4
  }
@@ -51,7 +51,7 @@ const lightgalleryMutation = async (text, pictures, cache) => {
51
51
  if (pictures.length === 0) {
52
52
  return text;
53
53
  }
54
- const picturesHTML = [];
54
+ const picturesMdMap = {};
55
55
  for (const picture of pictures) {
56
56
  const pic = picture.path;
57
57
  const uri = `https://app.quesmed.com/${pic}`;
@@ -70,19 +70,32 @@ const lightgalleryMutation = async (text, pictures, cache) => {
70
70
  console.error(e);
71
71
  }
72
72
  }
73
+ let mdPic = `![${file}](${uri})`;
73
74
  if (picture.caption?.length > 0) {
74
- picturesHTML.push(`![${file}](${uri} "${picture.caption}")`);
75
+ mdPic = `![${file}](${uri} "${picture.caption}")`;
75
76
  }
76
- picturesHTML.push(`![${file}](${uri})`);
77
+ if (!picturesMdMap[picture.index]) {
78
+ picturesMdMap[picture.index] = [];
79
+ }
80
+ picturesMdMap[picture.index].push(mdPic);
77
81
  }
78
- if (lightgalleryRegex.test(text)) {
79
- picturesHTML.forEach((image, index) => {
80
- const lightgalleryTagToReplace = `[lightgallery${!index ? '' : index}]`;
81
- text = text.replace(lightgalleryTagToReplace, image);
82
- });
83
- return text;
82
+ const matches = text.matchAll(lightgalleryRegex);
83
+ let matchExists = false;
84
+ for (const match of matches) {
85
+ const index = parseInt(match[1]);
86
+ if (index === 0) {
87
+ matchExists = true;
88
+ }
89
+ if (!picturesMdMap[index]) {
90
+ // TODO: report to sentry or err that lightgallery pictures are missing
91
+ continue;
92
+ }
93
+ const mdPics = picturesMdMap[index].join(' ');
94
+ const lightgalleryTagToReplace = `[lightgallery${index > 0 ? index : ''}]`;
95
+ text = text.replace(lightgalleryTagToReplace, mdPics);
84
96
  }
85
- else {
86
- return text + '\n\n' + picturesHTML[0] + '\n';
97
+ if (!matchExists) {
98
+ return text + '\n\n' + picturesMdMap[0].join(' ') + '\n';
87
99
  }
100
+ return text;
88
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.4.10",
3
+ "version": "2.4.11",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",