@pocketprep/ui-kit 3.4.77 → 3.4.79
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/@pocketprep/ui-kit.js +1659 -1644
- package/dist/@pocketprep/ui-kit.js.map +1 -1
- package/dist/@pocketprep/ui-kit.umd.cjs +5 -5
- package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/lib/components/Quiz/Question/ChoicesContainer.vue +8 -4
- package/lib/components/Quiz/Question/MobileMatrixChoicesContainer.vue +11 -6
- package/lib/components/Quiz/Question/MobileMatrixRadioGroup.vue +8 -3
- package/lib/utils.ts +6 -2
- package/package.json +1 -1
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
? 'Correct Answer, '
|
|
120
120
|
: 'Incorrect Answer, '
|
|
121
121
|
: ''
|
|
122
|
-
}${
|
|
122
|
+
}${ stripHtmlTags(choice.text) }`"
|
|
123
123
|
v-html="choice.text"
|
|
124
124
|
/>
|
|
125
125
|
<PocketButton
|
|
@@ -334,11 +334,15 @@ export default class ChoicesContainer extends Vue {
|
|
|
334
334
|
} }) breakpoints!: TBreakPointsObject
|
|
335
335
|
@Prop({ default: [] }) keywordDefinitions!: { keyword: string; definition: string }[]
|
|
336
336
|
|
|
337
|
-
|
|
338
|
-
|
|
337
|
+
stripHtmlTags (string?: string) {
|
|
338
|
+
if (string) {
|
|
339
|
+
const div = document.createElement('div')
|
|
340
|
+
div.innerHTML = string
|
|
341
|
+
return div.textContent || ''
|
|
342
|
+
}
|
|
343
|
+
return ''
|
|
339
344
|
}
|
|
340
345
|
|
|
341
|
-
|
|
342
346
|
@Emit('emitChoiceFocusIn')
|
|
343
347
|
emitChoiceFocusIn (choiceKey: TChoiceKey) {
|
|
344
348
|
return choiceKey
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
class="uikit-question-mobile-matrix-choices-container__row-label"
|
|
49
49
|
v-dark="isDarkMode"
|
|
50
50
|
>
|
|
51
|
-
{{
|
|
51
|
+
{{ stripHtmlTags(rowLabel) }}
|
|
52
52
|
<Icon
|
|
53
53
|
class="uikit-question-mobile-matrix-choices-container__toggle-row-icon"
|
|
54
54
|
:class="{
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
>
|
|
79
79
|
{{ selectedColumnHeaders[rowIndex][colHeaderIndex] ===
|
|
80
80
|
selectedColumnHeaders[rowIndex][selectedColumnHeaders[rowIndex].length - 1] ?
|
|
81
|
-
|
|
82
|
-
`${
|
|
81
|
+
stripHtmlTags(selectedColumnHeaders[rowIndex][colHeaderIndex]) :
|
|
82
|
+
`${stripHtmlTags(selectedColumnHeaders[rowIndex][colHeaderIndex])},`
|
|
83
83
|
}}
|
|
84
84
|
</div>
|
|
85
85
|
</template>
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
matrixChoiceLayout[rowIndex][columnIndex]?.startsWith('d'),
|
|
128
128
|
}"
|
|
129
129
|
>
|
|
130
|
-
{{
|
|
130
|
+
{{ stripHtmlTags(column) }}
|
|
131
131
|
</div>
|
|
132
132
|
</div>
|
|
133
133
|
</div>
|
|
@@ -204,8 +204,13 @@ export default class MobileMatrixChoicesContainer extends Vue {
|
|
|
204
204
|
selectedColumnHeaders: string[][] = []
|
|
205
205
|
brandColors = BrandColors
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
stripHtmlTags (string?: string) {
|
|
208
|
+
if (string) {
|
|
209
|
+
const div = document.createElement('div')
|
|
210
|
+
div.innerHTML = string
|
|
211
|
+
return div.textContent || ''
|
|
212
|
+
}
|
|
213
|
+
return ''
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
get defaultCheckboxGrid () {
|
|
@@ -40,8 +40,13 @@ const radioButtonColor = (choice: string) => {
|
|
|
40
40
|
return 'blue'
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const stripHtmlTags = (string?: string) => {
|
|
44
|
+
if (string) {
|
|
45
|
+
const div = document.createElement('div')
|
|
46
|
+
div.innerHTML = string
|
|
47
|
+
return div.textContent || ''
|
|
48
|
+
}
|
|
49
|
+
return ''
|
|
45
50
|
}
|
|
46
51
|
</script>
|
|
47
52
|
|
|
@@ -78,7 +83,7 @@ const stripText = (string?: string) => {
|
|
|
78
83
|
}"
|
|
79
84
|
@click="!disabled && !showAnswers && selectChoice(choice)"
|
|
80
85
|
>
|
|
81
|
-
{{
|
|
86
|
+
{{ stripHtmlTags(labels[index]) }}
|
|
82
87
|
</div>
|
|
83
88
|
</li>
|
|
84
89
|
</ul>
|
package/lib/utils.ts
CHANGED
|
@@ -66,6 +66,10 @@ export const studyModes = {
|
|
|
66
66
|
},
|
|
67
67
|
} as const
|
|
68
68
|
|
|
69
|
+
export const escapeRegex = (string: string) => {
|
|
70
|
+
return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
export const highlightKeywordsInText = (params: {
|
|
70
74
|
text: string
|
|
71
75
|
keywordDefinitions: { keyword: string }[]
|
|
@@ -79,7 +83,7 @@ export const highlightKeywordsInText = (params: {
|
|
|
79
83
|
const keywords = params.keywordDefinitions.map(k => k.keyword)
|
|
80
84
|
|
|
81
85
|
return keywords.reduce((acc, word) => {
|
|
82
|
-
const regex = new RegExp(`(\\W)(${word})(\\W)`, 'i')
|
|
86
|
+
const regex = new RegExp(`(\\W)(${escapeRegex(word)})(\\W)`, 'i')
|
|
83
87
|
return acc.replace(
|
|
84
88
|
regex,
|
|
85
89
|
`$1<span class="keyword-highlight${params.isDarkMode
|
|
@@ -89,4 +93,4 @@ export const highlightKeywordsInText = (params: {
|
|
|
89
93
|
<span style="pointer-events: none;">$2</span></span>$3`
|
|
90
94
|
)
|
|
91
95
|
}, params.text)
|
|
92
|
-
}
|
|
96
|
+
}
|