@webwriter/quiz 1.1.3 → 2.0.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/.github/workflows/publish.yml +8 -0
- package/LICENSE +6 -6
- package/README.md +778 -0
- package/assets/icons/grip-horizontal.svg +8 -0
- package/assets/icons/grip-vertical.svg +8 -0
- package/assets/icons/truefalse.svg +6 -0
- package/custom-elements.json +2779 -0
- package/custom.d.ts +180 -176
- package/dist/api/index.d.ts +27 -0
- package/dist/api/index.js +40 -0
- package/dist/migrate.js +1434 -0
- package/dist/widgets/webwriter-choice-item.js +4036 -3895
- package/dist/widgets/webwriter-choice.js +2269 -5821
- package/dist/widgets/webwriter-gap-item.js +3987 -0
- package/dist/widgets/webwriter-gap.js +2908 -0
- package/dist/widgets/webwriter-mark.js +4335 -3489
- package/dist/widgets/webwriter-order-item.js +4014 -3306
- package/dist/widgets/webwriter-order.js +2944 -4386
- package/dist/widgets/webwriter-pairing-item.js +1058 -2421
- package/dist/widgets/webwriter-pairing.js +2993 -4383
- package/dist/widgets/webwriter-quiz-hint.js +2469 -0
- package/dist/widgets/webwriter-quiz.js +4933 -6099
- package/dist/widgets/webwriter-speech.js +6077 -5230
- package/dist/widgets/webwriter-task-prompt.js +4775 -2165
- package/dist/widgets/webwriter-task.js +2364 -8382
- package/dist/widgets/webwriter-text.js +4169 -4337
- package/dist/widgets/webwriter-true-false.js +4674 -0
- package/editing-config.json +106 -0
- package/lit-localize.json +21 -15
- package/localization/de.xlf +407 -74
- package/localization/es.xlf +407 -69
- package/localization/fr.xlf +407 -69
- package/localization/generated/de.ts +112 -29
- package/localization/generated/es.ts +112 -29
- package/localization/generated/fr.ts +112 -29
- package/localization/generated/index.d.ts +5 -0
- package/localization/generated/index.js +2 -2
- package/localization/generated/it.ts +112 -29
- package/localization/generated/locale-codes.js +31 -79
- package/localization/generated/nl.ts +112 -29
- package/localization/it.xlf +407 -69
- package/localization/nl.xlf +407 -69
- package/package.json +119 -252
- package/scripts/apply-translations.mjs +97 -0
- package/src/api/index.ts +72 -0
- package/src/lib/artboard.ts +686 -0
- package/src/lib/draggable-grid.ts +432 -0
- package/src/lib/encrypted-property.ts +202 -0
- package/src/lib/hint-popup.ts +152 -0
- package/src/lib/utils.ts +97 -0
- package/src/lib/webwriter-quirks.ts +121 -0
- package/src/migrate/index.ts +622 -0
- package/src/migrate/legacy-solution.ts +362 -0
- package/src/snippets/order.html +9 -8
- package/src/widgets/choice/webwriter-choice-item.ts +316 -0
- package/src/widgets/choice/webwriter-choice.ts +328 -0
- package/src/widgets/choice/webwriter-true-false.ts +113 -0
- package/src/widgets/dnd/webwriter-dnd-draggable.ts +28 -0
- package/src/widgets/dnd/webwriter-dnd-dropzone.ts +9 -0
- package/src/widgets/dnd/webwriter-dnd.ts +36 -0
- package/src/widgets/gap/webwriter-gap-item.ts +250 -0
- package/src/widgets/gap/webwriter-gap.ts +447 -0
- package/src/widgets/order/webwriter-order-item.ts +243 -0
- package/src/widgets/order/webwriter-order.ts +282 -0
- package/src/widgets/pairing/webwriter-pairing-item.ts +46 -0
- package/src/widgets/pairing/webwriter-pairing.ts +934 -0
- package/src/widgets/speech/audio-player.ts +325 -0
- package/src/widgets/speech/audio-recorder.ts +285 -0
- package/src/widgets/speech/waveform.ts +113 -0
- package/src/widgets/speech/webwriter-speech.ts +87 -0
- package/src/widgets/webwriter-mark.ts +374 -432
- package/src/widgets/webwriter-quiz-hint.ts +36 -0
- package/src/widgets/webwriter-quiz.ts +320 -282
- package/src/widgets/webwriter-task-prompt.ts +49 -24
- package/src/widgets/webwriter-task.ts +216 -547
- package/src/widgets/webwriter-text.ts +291 -156
- package/tsconfig.api.json +12 -0
- package/tsconfig.json +8 -7
- package/dist/widgets/webwriter-choice.css +0 -444
- package/dist/widgets/webwriter-cloze-gap.css +0 -444
- package/dist/widgets/webwriter-cloze-gap.js +0 -5866
- package/dist/widgets/webwriter-cloze.css +0 -444
- package/dist/widgets/webwriter-cloze.js +0 -3786
- package/dist/widgets/webwriter-mark.css +0 -444
- package/dist/widgets/webwriter-order.css +0 -444
- package/dist/widgets/webwriter-pairing-item.css +0 -444
- package/dist/widgets/webwriter-pairing.css +0 -444
- package/dist/widgets/webwriter-quiz.css +0 -444
- package/dist/widgets/webwriter-task-explainer.css +0 -444
- package/dist/widgets/webwriter-task-explainer.js +0 -2872
- package/dist/widgets/webwriter-task-hint.css +0 -444
- package/dist/widgets/webwriter-task-hint.js +0 -2811
- package/dist/widgets/webwriter-task.css +0 -444
- package/dist/widgets/webwriter-text.css +0 -444
- package/localization/bg.xlf +0 -69
- package/localization/cs.xlf +0 -69
- package/localization/da.xlf +0 -69
- package/localization/el.xlf +0 -69
- package/localization/et.xlf +0 -69
- package/localization/fi.xlf +0 -69
- package/localization/generated/bg.ts +0 -30
- package/localization/generated/cs.ts +0 -30
- package/localization/generated/da.ts +0 -30
- package/localization/generated/el.ts +0 -30
- package/localization/generated/et.ts +0 -30
- package/localization/generated/fi.ts +0 -30
- package/localization/generated/hu.ts +0 -30
- package/localization/generated/id.ts +0 -30
- package/localization/generated/ja.ts +0 -30
- package/localization/generated/ko.ts +0 -30
- package/localization/generated/lt.ts +0 -30
- package/localization/generated/lv.ts +0 -30
- package/localization/generated/nb.ts +0 -30
- package/localization/generated/pl.ts +0 -30
- package/localization/generated/pt-BR.ts +0 -30
- package/localization/generated/pt-PT.ts +0 -30
- package/localization/generated/ro.ts +0 -30
- package/localization/generated/ru.ts +0 -30
- package/localization/generated/sk.ts +0 -30
- package/localization/generated/sl.ts +0 -30
- package/localization/generated/sv.ts +0 -30
- package/localization/generated/tr.ts +0 -30
- package/localization/generated/uk.ts +0 -30
- package/localization/generated/zh-hans.ts +0 -30
- package/localization/hu.xlf +0 -69
- package/localization/id.xlf +0 -69
- package/localization/ja.xlf +0 -69
- package/localization/ko.xlf +0 -69
- package/localization/lt.xlf +0 -69
- package/localization/lv.xlf +0 -69
- package/localization/nb.xlf +0 -69
- package/localization/pl.xlf +0 -69
- package/localization/pt-BR.xlf +0 -69
- package/localization/pt-PT.xlf +0 -69
- package/localization/ro.xlf +0 -69
- package/localization/ru.xlf +0 -69
- package/localization/sk.xlf +0 -69
- package/localization/sl.xlf +0 -69
- package/localization/sv.xlf +0 -69
- package/localization/tr.xlf +0 -69
- package/localization/uk.xlf +0 -69
- package/localization/zh-hans.xlf +0 -69
- package/src/lib/combobox.ts +0 -456
- package/src/lib/highlighter-fill.svg +0 -6
- package/src/snippets/Beispiel-Choice.html +0 -57
- package/src/snippets/Beispiel-Mark.html +0 -14
- package/src/snippets/Beispiel-Order.html +0 -52
- package/src/snippets/Beispiel-Text.html +0 -20
- package/src/snippets/blank.html +0 -1
- package/src/snippets/choice.html +0 -8
- package/src/snippets/cloze.html +0 -4
- package/src/snippets/mark.html +0 -4
- package/src/snippets/pairing.html +0 -10
- package/src/snippets/speech.html +0 -4
- package/src/snippets/text.html +0 -4
- package/src/snippets/wordsearch.html +0 -4
- package/src/widgets/webwriter-choice-item.ts +0 -254
- package/src/widgets/webwriter-choice.ts +0 -353
- package/src/widgets/webwriter-cloze-gap.ts +0 -216
- package/src/widgets/webwriter-cloze.ts +0 -136
- package/src/widgets/webwriter-order-item.ts +0 -441
- package/src/widgets/webwriter-order.ts +0 -327
- package/src/widgets/webwriter-pairing-item.ts +0 -161
- package/src/widgets/webwriter-pairing.ts +0 -193
- package/src/widgets/webwriter-speech.ts +0 -273
- package/src/widgets/webwriter-task-explainer.ts +0 -43
- package/src/widgets/webwriter-task-hint.ts +0 -23
package/custom.d.ts
CHANGED
|
@@ -1,176 +1,180 @@
|
|
|
1
|
-
declare module '*.apng' {
|
|
2
|
-
const content: string;
|
|
3
|
-
export default content;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.jpg' {
|
|
6
|
-
const content: string;
|
|
7
|
-
export default content;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.jpeg' {
|
|
10
|
-
const content: string;
|
|
11
|
-
export default content;
|
|
12
|
-
}
|
|
13
|
-
declare module '*.jfif' {
|
|
14
|
-
const content: string;
|
|
15
|
-
export default content;
|
|
16
|
-
}
|
|
17
|
-
declare module '*.pjpeg' {
|
|
18
|
-
const content: string;
|
|
19
|
-
export default content;
|
|
20
|
-
}
|
|
21
|
-
declare module '*.pjp' {
|
|
22
|
-
const content: string;
|
|
23
|
-
export default content;
|
|
24
|
-
}
|
|
25
|
-
declare module '*.png' {
|
|
26
|
-
const content: string;
|
|
27
|
-
export default content;
|
|
28
|
-
}
|
|
29
|
-
declare module '*.svg' {
|
|
30
|
-
const content: string;
|
|
31
|
-
export default content;
|
|
32
|
-
}
|
|
33
|
-
declare module '*.webp' {
|
|
34
|
-
const content: string;
|
|
35
|
-
export default content;
|
|
36
|
-
}
|
|
37
|
-
declare module '*.bmp' {
|
|
38
|
-
const content: string;
|
|
39
|
-
export default content;
|
|
40
|
-
}
|
|
41
|
-
declare module '*.ico' {
|
|
42
|
-
const content: string;
|
|
43
|
-
export default content;
|
|
44
|
-
}
|
|
45
|
-
declare module '*.cur' {
|
|
46
|
-
const content: string;
|
|
47
|
-
export default content;
|
|
48
|
-
}
|
|
49
|
-
declare module '*.tif' {
|
|
50
|
-
const content: string;
|
|
51
|
-
export default content;
|
|
52
|
-
}
|
|
53
|
-
declare module '*.tiff' {
|
|
54
|
-
const content: string;
|
|
55
|
-
export default content;
|
|
56
|
-
}
|
|
57
|
-
declare module '*.wav' {
|
|
58
|
-
const content: string;
|
|
59
|
-
export default content;
|
|
60
|
-
}
|
|
61
|
-
declare module '*.wave' {
|
|
62
|
-
const content: string;
|
|
63
|
-
export default content;
|
|
64
|
-
}
|
|
65
|
-
declare module '*.mp3' {
|
|
66
|
-
const content: string;
|
|
67
|
-
export default content;
|
|
68
|
-
}
|
|
69
|
-
declare module '*.aac' {
|
|
70
|
-
const content: string;
|
|
71
|
-
export default content;
|
|
72
|
-
}
|
|
73
|
-
declare module '*.aacp' {
|
|
74
|
-
const content: string;
|
|
75
|
-
export default content;
|
|
76
|
-
}
|
|
77
|
-
declare module '*.oga' {
|
|
78
|
-
const content: string;
|
|
79
|
-
export default content;
|
|
80
|
-
}
|
|
81
|
-
declare module '*.flac' {
|
|
82
|
-
const content: string;
|
|
83
|
-
export default content;
|
|
84
|
-
}
|
|
85
|
-
declare module '*.weba' {
|
|
86
|
-
const content: string;
|
|
87
|
-
export default content;
|
|
88
|
-
}
|
|
89
|
-
declare module '*.mp4' {
|
|
90
|
-
const content: string;
|
|
91
|
-
export default content;
|
|
92
|
-
}
|
|
93
|
-
declare module '*.webm' {
|
|
94
|
-
const content: string;
|
|
95
|
-
export default content;
|
|
96
|
-
}
|
|
97
|
-
declare module '*.avif' {
|
|
98
|
-
const content: string;
|
|
99
|
-
export default content;
|
|
100
|
-
}
|
|
101
|
-
declare module '*.gif' {
|
|
102
|
-
const content: string;
|
|
103
|
-
export default content;
|
|
104
|
-
}
|
|
105
|
-
declare module '*.mov' {
|
|
106
|
-
const content: string;
|
|
107
|
-
export default content;
|
|
108
|
-
}
|
|
109
|
-
declare module '*.avi' {
|
|
110
|
-
const content: string;
|
|
111
|
-
export default content;
|
|
112
|
-
}
|
|
113
|
-
declare module '*.ogv' {
|
|
114
|
-
const content: string;
|
|
115
|
-
export default content;
|
|
116
|
-
}
|
|
117
|
-
declare module '*.mkv' {
|
|
118
|
-
const content: string;
|
|
119
|
-
export default content;
|
|
120
|
-
}
|
|
121
|
-
declare module '*.opus' {
|
|
122
|
-
const content: string;
|
|
123
|
-
export default content;
|
|
124
|
-
}
|
|
125
|
-
declare module '*.mpeg' {
|
|
126
|
-
const content: string;
|
|
127
|
-
export default content;
|
|
128
|
-
}
|
|
129
|
-
declare module '*.woff' {
|
|
130
|
-
const content: string;
|
|
131
|
-
export default content;
|
|
132
|
-
}
|
|
133
|
-
declare module '*.woff2' {
|
|
134
|
-
const content: string;
|
|
135
|
-
export default content;
|
|
136
|
-
}
|
|
137
|
-
declare module '*.ttf' {
|
|
138
|
-
const content: string;
|
|
139
|
-
export default content;
|
|
140
|
-
}
|
|
141
|
-
declare module '*.otf' {
|
|
142
|
-
const content: string;
|
|
143
|
-
export default content;
|
|
144
|
-
}
|
|
145
|
-
declare module '*.pdf' {
|
|
146
|
-
const content: string;
|
|
147
|
-
export default content;
|
|
148
|
-
}
|
|
149
|
-
declare module '*.json' {
|
|
150
|
-
const content: {[key: string]: any};
|
|
151
|
-
export default content;
|
|
152
|
-
}
|
|
153
|
-
declare module '*.jsonld' {
|
|
154
|
-
const content: {[key: string]: any};
|
|
155
|
-
export default content;
|
|
156
|
-
}
|
|
157
|
-
declare module '*.txt' {
|
|
158
|
-
const content: string;
|
|
159
|
-
export default content;
|
|
160
|
-
}
|
|
161
|
-
declare module '*.csv' {
|
|
162
|
-
const content: string;
|
|
163
|
-
export default content;
|
|
164
|
-
}
|
|
165
|
-
declare module '*.htm' {
|
|
166
|
-
const content: string;
|
|
167
|
-
export default content;
|
|
168
|
-
}
|
|
169
|
-
declare module '*.html' {
|
|
170
|
-
const content: string;
|
|
171
|
-
export default content;
|
|
172
|
-
}
|
|
173
|
-
declare module '*.xml' {
|
|
174
|
-
const content: string;
|
|
175
|
-
export default content;
|
|
176
|
-
}
|
|
1
|
+
declare module '*.apng' {
|
|
2
|
+
const content: string;
|
|
3
|
+
export default content;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.jpg' {
|
|
6
|
+
const content: string;
|
|
7
|
+
export default content;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.jpeg' {
|
|
10
|
+
const content: string;
|
|
11
|
+
export default content;
|
|
12
|
+
}
|
|
13
|
+
declare module '*.jfif' {
|
|
14
|
+
const content: string;
|
|
15
|
+
export default content;
|
|
16
|
+
}
|
|
17
|
+
declare module '*.pjpeg' {
|
|
18
|
+
const content: string;
|
|
19
|
+
export default content;
|
|
20
|
+
}
|
|
21
|
+
declare module '*.pjp' {
|
|
22
|
+
const content: string;
|
|
23
|
+
export default content;
|
|
24
|
+
}
|
|
25
|
+
declare module '*.png' {
|
|
26
|
+
const content: string;
|
|
27
|
+
export default content;
|
|
28
|
+
}
|
|
29
|
+
declare module '*.svg' {
|
|
30
|
+
const content: string;
|
|
31
|
+
export default content;
|
|
32
|
+
}
|
|
33
|
+
declare module '*.webp' {
|
|
34
|
+
const content: string;
|
|
35
|
+
export default content;
|
|
36
|
+
}
|
|
37
|
+
declare module '*.bmp' {
|
|
38
|
+
const content: string;
|
|
39
|
+
export default content;
|
|
40
|
+
}
|
|
41
|
+
declare module '*.ico' {
|
|
42
|
+
const content: string;
|
|
43
|
+
export default content;
|
|
44
|
+
}
|
|
45
|
+
declare module '*.cur' {
|
|
46
|
+
const content: string;
|
|
47
|
+
export default content;
|
|
48
|
+
}
|
|
49
|
+
declare module '*.tif' {
|
|
50
|
+
const content: string;
|
|
51
|
+
export default content;
|
|
52
|
+
}
|
|
53
|
+
declare module '*.tiff' {
|
|
54
|
+
const content: string;
|
|
55
|
+
export default content;
|
|
56
|
+
}
|
|
57
|
+
declare module '*.wav' {
|
|
58
|
+
const content: string;
|
|
59
|
+
export default content;
|
|
60
|
+
}
|
|
61
|
+
declare module '*.wave' {
|
|
62
|
+
const content: string;
|
|
63
|
+
export default content;
|
|
64
|
+
}
|
|
65
|
+
declare module '*.mp3' {
|
|
66
|
+
const content: string;
|
|
67
|
+
export default content;
|
|
68
|
+
}
|
|
69
|
+
declare module '*.aac' {
|
|
70
|
+
const content: string;
|
|
71
|
+
export default content;
|
|
72
|
+
}
|
|
73
|
+
declare module '*.aacp' {
|
|
74
|
+
const content: string;
|
|
75
|
+
export default content;
|
|
76
|
+
}
|
|
77
|
+
declare module '*.oga' {
|
|
78
|
+
const content: string;
|
|
79
|
+
export default content;
|
|
80
|
+
}
|
|
81
|
+
declare module '*.flac' {
|
|
82
|
+
const content: string;
|
|
83
|
+
export default content;
|
|
84
|
+
}
|
|
85
|
+
declare module '*.weba' {
|
|
86
|
+
const content: string;
|
|
87
|
+
export default content;
|
|
88
|
+
}
|
|
89
|
+
declare module '*.mp4' {
|
|
90
|
+
const content: string;
|
|
91
|
+
export default content;
|
|
92
|
+
}
|
|
93
|
+
declare module '*.webm' {
|
|
94
|
+
const content: string;
|
|
95
|
+
export default content;
|
|
96
|
+
}
|
|
97
|
+
declare module '*.avif' {
|
|
98
|
+
const content: string;
|
|
99
|
+
export default content;
|
|
100
|
+
}
|
|
101
|
+
declare module '*.gif' {
|
|
102
|
+
const content: string;
|
|
103
|
+
export default content;
|
|
104
|
+
}
|
|
105
|
+
declare module '*.mov' {
|
|
106
|
+
const content: string;
|
|
107
|
+
export default content;
|
|
108
|
+
}
|
|
109
|
+
declare module '*.avi' {
|
|
110
|
+
const content: string;
|
|
111
|
+
export default content;
|
|
112
|
+
}
|
|
113
|
+
declare module '*.ogv' {
|
|
114
|
+
const content: string;
|
|
115
|
+
export default content;
|
|
116
|
+
}
|
|
117
|
+
declare module '*.mkv' {
|
|
118
|
+
const content: string;
|
|
119
|
+
export default content;
|
|
120
|
+
}
|
|
121
|
+
declare module '*.opus' {
|
|
122
|
+
const content: string;
|
|
123
|
+
export default content;
|
|
124
|
+
}
|
|
125
|
+
declare module '*.mpeg' {
|
|
126
|
+
const content: string;
|
|
127
|
+
export default content;
|
|
128
|
+
}
|
|
129
|
+
declare module '*.woff' {
|
|
130
|
+
const content: string;
|
|
131
|
+
export default content;
|
|
132
|
+
}
|
|
133
|
+
declare module '*.woff2' {
|
|
134
|
+
const content: string;
|
|
135
|
+
export default content;
|
|
136
|
+
}
|
|
137
|
+
declare module '*.ttf' {
|
|
138
|
+
const content: string;
|
|
139
|
+
export default content;
|
|
140
|
+
}
|
|
141
|
+
declare module '*.otf' {
|
|
142
|
+
const content: string;
|
|
143
|
+
export default content;
|
|
144
|
+
}
|
|
145
|
+
declare module '*.pdf' {
|
|
146
|
+
const content: string;
|
|
147
|
+
export default content;
|
|
148
|
+
}
|
|
149
|
+
declare module '*.json' {
|
|
150
|
+
const content: {[key: string]: any};
|
|
151
|
+
export default content;
|
|
152
|
+
}
|
|
153
|
+
declare module '*.jsonld' {
|
|
154
|
+
const content: {[key: string]: any};
|
|
155
|
+
export default content;
|
|
156
|
+
}
|
|
157
|
+
declare module '*.txt' {
|
|
158
|
+
const content: string;
|
|
159
|
+
export default content;
|
|
160
|
+
}
|
|
161
|
+
declare module '*.csv' {
|
|
162
|
+
const content: string;
|
|
163
|
+
export default content;
|
|
164
|
+
}
|
|
165
|
+
declare module '*.htm' {
|
|
166
|
+
const content: string;
|
|
167
|
+
export default content;
|
|
168
|
+
}
|
|
169
|
+
declare module '*.html' {
|
|
170
|
+
const content: string;
|
|
171
|
+
export default content;
|
|
172
|
+
}
|
|
173
|
+
declare module '*.xml' {
|
|
174
|
+
const content: string;
|
|
175
|
+
export default content;
|
|
176
|
+
}
|
|
177
|
+
declare module '*.css' {
|
|
178
|
+
const content: string;
|
|
179
|
+
export default content;
|
|
180
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type QuizType = {
|
|
2
|
+
packageId: string;
|
|
3
|
+
widgetPosition?: number;
|
|
4
|
+
id: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
getName(): string;
|
|
7
|
+
createInstance(): HTMLElement & IWebWriterQuizType;
|
|
8
|
+
};
|
|
9
|
+
export interface IWebWriterQuizType {
|
|
10
|
+
checkValidity(): boolean;
|
|
11
|
+
reset(): void;
|
|
12
|
+
checkAnswer?(detailedFeedback: boolean): number;
|
|
13
|
+
}
|
|
14
|
+
type WebwriterQuizRegistry = {
|
|
15
|
+
version: number;
|
|
16
|
+
quizTypes: QuizType[];
|
|
17
|
+
listeners: ((types: readonly QuizType[]) => void)[];
|
|
18
|
+
};
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
__wwQuizRegistry__: WebwriterQuizRegistry;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare function getQuizTypes(): readonly QuizType[];
|
|
25
|
+
export declare function registerQuizType(type: QuizType): void;
|
|
26
|
+
export declare function onQuizTypesChanged(cb: (types: readonly QuizType[]) => void): () => void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function getRegistry() {
|
|
2
|
+
window.__wwQuizRegistry__ ??= { version: 1, quizTypes: [], listeners: [] };
|
|
3
|
+
return window.__wwQuizRegistry__;
|
|
4
|
+
}
|
|
5
|
+
export function getQuizTypes() {
|
|
6
|
+
return [...getRegistry().quizTypes];
|
|
7
|
+
}
|
|
8
|
+
export function registerQuizType(type) {
|
|
9
|
+
const registry = getRegistry();
|
|
10
|
+
let i = 0;
|
|
11
|
+
// First, order by package id
|
|
12
|
+
// The @webwriter/quiz package is always first, regardless of its package id
|
|
13
|
+
if (type.packageId !== "@webwriter/quiz") {
|
|
14
|
+
while (i < registry.quizTypes.length) {
|
|
15
|
+
if (registry.quizTypes[i].packageId.localeCompare(type.packageId) >= 0)
|
|
16
|
+
break;
|
|
17
|
+
i++;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Then, order by widget position (ascending), and then by widget id (ascending)
|
|
21
|
+
const newPosition = type.widgetPosition ?? Infinity;
|
|
22
|
+
while (i < registry.quizTypes.length && registry.quizTypes[i].packageId === type.packageId) {
|
|
23
|
+
const currentPosition = registry.quizTypes[i].widgetPosition ?? Infinity;
|
|
24
|
+
if (currentPosition > newPosition)
|
|
25
|
+
break;
|
|
26
|
+
// Use id as a tiebreaker (alphabetical order)
|
|
27
|
+
if (currentPosition === newPosition && registry.quizTypes[i].id.localeCompare(type.id) >= 0)
|
|
28
|
+
break;
|
|
29
|
+
i++;
|
|
30
|
+
}
|
|
31
|
+
registry.quizTypes.splice(i, 0, type);
|
|
32
|
+
const quizTypes = getQuizTypes();
|
|
33
|
+
registry.listeners.forEach(cb => cb(quizTypes));
|
|
34
|
+
}
|
|
35
|
+
export function onQuizTypesChanged(cb) {
|
|
36
|
+
const registry = getRegistry();
|
|
37
|
+
cb(getQuizTypes());
|
|
38
|
+
registry.listeners.push(cb);
|
|
39
|
+
return () => registry.listeners = registry.listeners.filter(l => l !== cb);
|
|
40
|
+
}
|