@webwriter/quiz 1.0.10 → 1.1.2
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/LICENSE +6 -6
- package/custom.d.ts +175 -175
- package/dist/widgets/webwriter-choice-item.js +10 -7
- package/dist/widgets/webwriter-choice.js +36 -6
- package/dist/widgets/webwriter-order-item.js +14 -12
- package/dist/widgets/webwriter-order.js +28 -4
- package/dist/widgets/webwriter-quiz.js +1 -1
- package/dist/widgets/webwriter-task.js +0 -1
- package/dist/widgets/webwriter-text.js +26 -9
- package/lit-localize.json +14 -14
- package/localization/bg.xlf +69 -69
- package/localization/cs.xlf +69 -69
- package/localization/da.xlf +69 -69
- package/localization/de.xlf +74 -74
- package/localization/el.xlf +69 -69
- package/localization/es.xlf +69 -69
- package/localization/et.xlf +69 -69
- package/localization/fi.xlf +69 -69
- package/localization/fr.xlf +69 -69
- package/localization/generated/bg.ts +29 -29
- package/localization/generated/cs.ts +29 -29
- package/localization/generated/da.ts +29 -29
- package/localization/generated/de.ts +29 -29
- package/localization/generated/el.ts +29 -29
- package/localization/generated/es.ts +29 -29
- package/localization/generated/et.ts +29 -29
- package/localization/generated/fi.ts +29 -29
- package/localization/generated/fr.ts +29 -29
- package/localization/generated/hu.ts +29 -29
- package/localization/generated/id.ts +29 -29
- package/localization/generated/index.js +2 -2
- package/localization/generated/it.ts +29 -29
- package/localization/generated/ja.ts +29 -29
- package/localization/generated/ko.ts +29 -29
- package/localization/generated/locale-codes.js +79 -79
- package/localization/generated/lt.ts +29 -29
- package/localization/generated/lv.ts +29 -29
- package/localization/generated/nb.ts +29 -29
- package/localization/generated/nl.ts +29 -29
- package/localization/generated/pl.ts +29 -29
- package/localization/generated/pt-BR.ts +29 -29
- package/localization/generated/pt-PT.ts +29 -29
- package/localization/generated/ro.ts +29 -29
- package/localization/generated/ru.ts +29 -29
- package/localization/generated/sk.ts +29 -29
- package/localization/generated/sl.ts +29 -29
- package/localization/generated/sv.ts +29 -29
- package/localization/generated/tr.ts +29 -29
- package/localization/generated/uk.ts +29 -29
- package/localization/generated/zh-hans.ts +29 -29
- package/localization/hu.xlf +69 -69
- package/localization/id.xlf +69 -69
- package/localization/it.xlf +69 -69
- package/localization/ja.xlf +69 -69
- package/localization/ko.xlf +69 -69
- package/localization/lt.xlf +69 -69
- package/localization/lv.xlf +69 -69
- package/localization/nb.xlf +69 -69
- package/localization/nl.xlf +69 -69
- package/localization/pl.xlf +69 -69
- package/localization/pt-BR.xlf +69 -69
- package/localization/pt-PT.xlf +69 -69
- package/localization/ro.xlf +69 -69
- package/localization/ru.xlf +69 -69
- package/localization/sk.xlf +69 -69
- package/localization/sl.xlf +69 -69
- package/localization/sv.xlf +69 -69
- package/localization/tr.xlf +69 -69
- package/localization/uk.xlf +69 -69
- package/localization/zh-hans.xlf +69 -69
- package/package.json +7 -2
- package/src/lib/combobox.ts +455 -455
- package/src/lib/highlighter-fill.svg +5 -5
- package/src/snippets/Beispiel-Choice.html +57 -57
- package/src/snippets/Beispiel-Mark.html +13 -13
- package/src/snippets/Beispiel-Order.html +52 -52
- package/src/snippets/Beispiel-Text.html +20 -20
- package/src/snippets/blank.html +1 -0
- package/src/snippets/choice.html +7 -7
- package/src/snippets/cloze.html +3 -3
- package/src/snippets/mark.html +3 -3
- package/src/snippets/order.html +7 -7
- package/src/snippets/pairing.html +9 -9
- package/src/snippets/speech.html +3 -3
- package/src/snippets/text.html +3 -3
- package/src/snippets/wordsearch.html +3 -3
- package/src/widgets/webwriter-choice-item.ts +253 -250
- package/src/widgets/webwriter-choice.ts +336 -314
- package/src/widgets/webwriter-cloze-gap.ts +215 -215
- package/src/widgets/webwriter-cloze.ts +135 -135
- package/src/widgets/webwriter-mark.ts +431 -431
- package/src/widgets/webwriter-order-item.ts +440 -437
- package/src/widgets/webwriter-order.ts +309 -284
- package/src/widgets/webwriter-pairing-item.ts +160 -160
- package/src/widgets/webwriter-pairing.ts +192 -192
- package/src/widgets/webwriter-quiz.ts +281 -281
- package/src/widgets/webwriter-speech.ts +272 -272
- package/src/widgets/webwriter-task-explainer.ts +42 -42
- package/src/widgets/webwriter-task-hint.ts +22 -22
- package/src/widgets/webwriter-task-prompt.ts +23 -23
- package/src/widgets/webwriter-task.ts +546 -546
- package/src/widgets/webwriter-text.ts +155 -135
- package/tsconfig.json +6 -6
- package/.env +0 -1
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
import {html, css, LitElement} from "lit"
|
|
2
|
-
import {LitElementWw} from "@webwriter/lit"
|
|
3
|
-
import {customElement, query} from "lit/decorators.js"
|
|
4
|
-
import {styleMap} from "lit/directives/style-map.js"
|
|
5
|
-
|
|
6
|
-
import SlIconButton from "@shoelace-style/shoelace/dist/components/icon-button/icon-button.component.js"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import IconTextarea from "bootstrap-icons/icons/textarea.svg"
|
|
10
|
-
import { WebwriterClozeGap } from "./webwriter-cloze-gap.js"
|
|
11
|
-
import "@shoelace-style/shoelace/dist/themes/light.css"
|
|
12
|
-
|
|
13
|
-
import LOCALIZE from "../../localization/generated"
|
|
14
|
-
import {msg} from "@lit/localize"
|
|
15
|
-
|
|
16
|
-
declare global {interface HTMLElementTagNameMap {
|
|
17
|
-
"webwriter-cloze": WebwriterCloze;
|
|
18
|
-
}}
|
|
19
|
-
|
|
20
|
-
@customElement("webwriter-cloze")
|
|
21
|
-
export class WebwriterCloze extends LitElementWw {
|
|
22
|
-
|
|
23
|
-
localize = LOCALIZE
|
|
24
|
-
|
|
25
|
-
static shadowRootOptions: ShadowRootInit = {...LitElementWw.shadowRootOptions, delegatesFocus: false}
|
|
26
|
-
|
|
27
|
-
static scopedElements = {
|
|
28
|
-
"sl-icon-button": SlIconButton
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static styles = css`
|
|
32
|
-
:host {
|
|
33
|
-
min-height: 1rem;
|
|
34
|
-
position: relative;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
slot {
|
|
38
|
-
display: block;
|
|
39
|
-
cursor: text;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
slot[data-empty]:after {
|
|
43
|
-
content: var(--placeholder);
|
|
44
|
-
position: absolute;
|
|
45
|
-
left: 0;
|
|
46
|
-
top: 0;
|
|
47
|
-
color: darkgray;
|
|
48
|
-
pointer-events: none;
|
|
49
|
-
user-select: none;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
slot::after, slot::before {
|
|
53
|
-
content: ' ';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#add-gap {
|
|
57
|
-
position: absolute;
|
|
58
|
-
right: 0;
|
|
59
|
-
top: 0;
|
|
60
|
-
background: rgba(255, 255, 255, 0.85);
|
|
61
|
-
|
|
62
|
-
&[data-highlighting]::part(base) {
|
|
63
|
-
background: var(--sl-color-primary-100);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
:host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
|
|
68
|
-
display: none;
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
|
|
72
|
-
@query("#add-gap")
|
|
73
|
-
accessor addGapButton: SlIconButton
|
|
74
|
-
|
|
75
|
-
observer: MutationObserver
|
|
76
|
-
|
|
77
|
-
connectedCallback(): void {
|
|
78
|
-
super.connectedCallback()
|
|
79
|
-
document.addEventListener("selectionchange", e => {
|
|
80
|
-
const sel = document.getSelection()
|
|
81
|
-
const node = document.getSelection()?.anchorNode
|
|
82
|
-
const el = node.nodeType === node.TEXT_NODE? node.parentElement: node as HTMLElement
|
|
83
|
-
this.addGapButton.toggleAttribute("data-visible", el?.closest("webwriter-cloze")? true: false)
|
|
84
|
-
if(el?.closest("webwriter-cloze") && !sel.isCollapsed) {
|
|
85
|
-
this.addGapButton.toggleAttribute("data-highlighting", true)
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this.addGapButton.toggleAttribute("data-highlighting", false)
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
this.observer = new MutationObserver(() => this.requestUpdate())
|
|
92
|
-
this.observer.observe(this, {characterData: true, childList: true, subtree: true})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
disconnectedCallback(): void {
|
|
97
|
-
super.disconnectedCallback()
|
|
98
|
-
this.observer?.disconnect()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
toggleGap = () => {
|
|
102
|
-
const sel = document.getSelection()
|
|
103
|
-
const selectedElement = sel.anchorNode.childNodes.item(sel.anchorOffset)
|
|
104
|
-
if(selectedElement?.nodeName.toLowerCase() === "webwriter-cloze-gap") {
|
|
105
|
-
const gap = selectedElement as WebwriterClozeGap
|
|
106
|
-
selectedElement.replaceWith(document.createTextNode(gap.value))
|
|
107
|
-
}
|
|
108
|
-
else if(this.contains(sel.anchorNode)) {
|
|
109
|
-
if(sel.anchorNode !== this) {
|
|
110
|
-
const textContent = sel.toString()
|
|
111
|
-
sel.deleteFromDocument()
|
|
112
|
-
const textNode = sel.anchorNode as Text
|
|
113
|
-
const at = sel.anchorOffset
|
|
114
|
-
const clozeGap = document.createElement("webwriter-cloze-gap")
|
|
115
|
-
clozeGap.classList.add("webwriter-new")
|
|
116
|
-
clozeGap.setAttribute("value", textContent)
|
|
117
|
-
const afterTextNode = textNode.splitText(at)
|
|
118
|
-
afterTextNode.textContent = afterTextNode.textContent.trimStart()
|
|
119
|
-
textNode.textContent = textNode.textContent.trimEnd()
|
|
120
|
-
textNode.parentElement.insertBefore(clozeGap, afterTextNode)
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const clozeGap = document.createElement("webwriter-cloze-gap")
|
|
124
|
-
clozeGap.setAttribute("value", "")
|
|
125
|
-
this.append(clozeGap)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
render() {
|
|
131
|
-
return html`
|
|
132
|
-
<slot style=${styleMap({"--placeholder": `"${msg("Text to add gaps to")}"`})} ?data-empty=${!this.textContent.trim() && !this.querySelectorAll("& > p *:not(br)").length}></slot>
|
|
133
|
-
<sl-icon-button class="author-only" id="add-gap" src=${IconTextarea} @click=${this.toggleGap}></sl-icon-button>
|
|
134
|
-
`
|
|
135
|
-
}
|
|
1
|
+
import {html, css, LitElement} from "lit"
|
|
2
|
+
import {LitElementWw} from "@webwriter/lit"
|
|
3
|
+
import {customElement, query} from "lit/decorators.js"
|
|
4
|
+
import {styleMap} from "lit/directives/style-map.js"
|
|
5
|
+
|
|
6
|
+
import SlIconButton from "@shoelace-style/shoelace/dist/components/icon-button/icon-button.component.js"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import IconTextarea from "bootstrap-icons/icons/textarea.svg"
|
|
10
|
+
import { WebwriterClozeGap } from "./webwriter-cloze-gap.js"
|
|
11
|
+
import "@shoelace-style/shoelace/dist/themes/light.css"
|
|
12
|
+
|
|
13
|
+
import LOCALIZE from "../../localization/generated"
|
|
14
|
+
import {msg} from "@lit/localize"
|
|
15
|
+
|
|
16
|
+
declare global {interface HTMLElementTagNameMap {
|
|
17
|
+
"webwriter-cloze": WebwriterCloze;
|
|
18
|
+
}}
|
|
19
|
+
|
|
20
|
+
@customElement("webwriter-cloze")
|
|
21
|
+
export class WebwriterCloze extends LitElementWw {
|
|
22
|
+
|
|
23
|
+
localize = LOCALIZE
|
|
24
|
+
|
|
25
|
+
static shadowRootOptions: ShadowRootInit = {...LitElementWw.shadowRootOptions, delegatesFocus: false}
|
|
26
|
+
|
|
27
|
+
static scopedElements = {
|
|
28
|
+
"sl-icon-button": SlIconButton
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static styles = css`
|
|
32
|
+
:host {
|
|
33
|
+
min-height: 1rem;
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
slot {
|
|
38
|
+
display: block;
|
|
39
|
+
cursor: text;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
slot[data-empty]:after {
|
|
43
|
+
content: var(--placeholder);
|
|
44
|
+
position: absolute;
|
|
45
|
+
left: 0;
|
|
46
|
+
top: 0;
|
|
47
|
+
color: darkgray;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
user-select: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
slot::after, slot::before {
|
|
53
|
+
content: ' ';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#add-gap {
|
|
57
|
+
position: absolute;
|
|
58
|
+
right: 0;
|
|
59
|
+
top: 0;
|
|
60
|
+
background: rgba(255, 255, 255, 0.85);
|
|
61
|
+
|
|
62
|
+
&[data-highlighting]::part(base) {
|
|
63
|
+
background: var(--sl-color-primary-100);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
`
|
|
71
|
+
|
|
72
|
+
@query("#add-gap")
|
|
73
|
+
accessor addGapButton: SlIconButton
|
|
74
|
+
|
|
75
|
+
observer: MutationObserver
|
|
76
|
+
|
|
77
|
+
connectedCallback(): void {
|
|
78
|
+
super.connectedCallback()
|
|
79
|
+
document.addEventListener("selectionchange", e => {
|
|
80
|
+
const sel = document.getSelection()
|
|
81
|
+
const node = document.getSelection()?.anchorNode
|
|
82
|
+
const el = node.nodeType === node.TEXT_NODE? node.parentElement: node as HTMLElement
|
|
83
|
+
this.addGapButton.toggleAttribute("data-visible", el?.closest("webwriter-cloze")? true: false)
|
|
84
|
+
if(el?.closest("webwriter-cloze") && !sel.isCollapsed) {
|
|
85
|
+
this.addGapButton.toggleAttribute("data-highlighting", true)
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.addGapButton.toggleAttribute("data-highlighting", false)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
this.observer = new MutationObserver(() => this.requestUpdate())
|
|
92
|
+
this.observer.observe(this, {characterData: true, childList: true, subtree: true})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
disconnectedCallback(): void {
|
|
97
|
+
super.disconnectedCallback()
|
|
98
|
+
this.observer?.disconnect()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
toggleGap = () => {
|
|
102
|
+
const sel = document.getSelection()
|
|
103
|
+
const selectedElement = sel.anchorNode.childNodes.item(sel.anchorOffset)
|
|
104
|
+
if(selectedElement?.nodeName.toLowerCase() === "webwriter-cloze-gap") {
|
|
105
|
+
const gap = selectedElement as WebwriterClozeGap
|
|
106
|
+
selectedElement.replaceWith(document.createTextNode(gap.value))
|
|
107
|
+
}
|
|
108
|
+
else if(this.contains(sel.anchorNode)) {
|
|
109
|
+
if(sel.anchorNode !== this) {
|
|
110
|
+
const textContent = sel.toString()
|
|
111
|
+
sel.deleteFromDocument()
|
|
112
|
+
const textNode = sel.anchorNode as Text
|
|
113
|
+
const at = sel.anchorOffset
|
|
114
|
+
const clozeGap = document.createElement("webwriter-cloze-gap")
|
|
115
|
+
clozeGap.classList.add("webwriter-new")
|
|
116
|
+
clozeGap.setAttribute("value", textContent)
|
|
117
|
+
const afterTextNode = textNode.splitText(at)
|
|
118
|
+
afterTextNode.textContent = afterTextNode.textContent.trimStart()
|
|
119
|
+
textNode.textContent = textNode.textContent.trimEnd()
|
|
120
|
+
textNode.parentElement.insertBefore(clozeGap, afterTextNode)
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const clozeGap = document.createElement("webwriter-cloze-gap")
|
|
124
|
+
clozeGap.setAttribute("value", "")
|
|
125
|
+
this.append(clozeGap)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
render() {
|
|
131
|
+
return html`
|
|
132
|
+
<slot style=${styleMap({"--placeholder": `"${msg("Text to add gaps to")}"`})} ?data-empty=${!this.textContent.trim() && !this.querySelectorAll("& > p *:not(br)").length}></slot>
|
|
133
|
+
<sl-icon-button class="author-only" id="add-gap" src=${IconTextarea} @click=${this.toggleGap}></sl-icon-button>
|
|
134
|
+
`
|
|
135
|
+
}
|
|
136
136
|
}
|