@webwriter/quiz 1.0.3 → 1.0.4

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 (41) hide show
  1. package/LICENSE +6 -6
  2. package/custom.d.ts +175 -175
  3. package/dist/widgets/webwriter-choice-item.js +58 -13
  4. package/dist/widgets/webwriter-choice.js +64 -19
  5. package/dist/widgets/webwriter-cloze-gap.js +59 -14
  6. package/dist/widgets/webwriter-cloze.js +56 -11
  7. package/dist/widgets/webwriter-mark.js +56 -11
  8. package/dist/widgets/webwriter-order-item.js +56 -11
  9. package/dist/widgets/webwriter-order.js +64 -19
  10. package/dist/widgets/webwriter-pairing.js +59 -14
  11. package/dist/widgets/webwriter-quiz.js +67 -22
  12. package/dist/widgets/webwriter-speech.js +66 -20
  13. package/dist/widgets/webwriter-task.js +534 -308
  14. package/dist/widgets/webwriter-text.js +60 -14
  15. package/package.json +200 -200
  16. package/src/lib/combobox.ts +455 -455
  17. package/src/snippets/choice.html +7 -7
  18. package/src/snippets/cloze.html +3 -3
  19. package/src/snippets/mark.html +3 -3
  20. package/src/snippets/order.html +7 -7
  21. package/src/snippets/pairing.html +9 -9
  22. package/src/snippets/speech.html +3 -3
  23. package/src/snippets/text.html +3 -3
  24. package/src/snippets/wordsearch.html +3 -3
  25. package/src/widgets/webwriter-choice-item.ts +250 -250
  26. package/src/widgets/webwriter-choice.ts +309 -309
  27. package/src/widgets/webwriter-cloze-gap.ts +216 -216
  28. package/src/widgets/webwriter-cloze.ts +135 -135
  29. package/src/widgets/webwriter-mark.ts +434 -434
  30. package/src/widgets/webwriter-order-item.ts +444 -444
  31. package/src/widgets/webwriter-order.ts +272 -272
  32. package/src/widgets/webwriter-pairing-item.ts +155 -155
  33. package/src/widgets/webwriter-pairing.ts +187 -187
  34. package/src/widgets/webwriter-quiz.ts +280 -280
  35. package/src/widgets/webwriter-speech.ts +267 -267
  36. package/src/widgets/webwriter-task-explainer.ts +37 -37
  37. package/src/widgets/webwriter-task-hint.ts +16 -16
  38. package/src/widgets/webwriter-task-prompt.ts +17 -17
  39. package/src/widgets/webwriter-task.ts +543 -543
  40. package/src/widgets/webwriter-text.ts +130 -130
  41. package/tsconfig.json +6 -6
@@ -1,156 +1,156 @@
1
- import {html, css} from "lit"
2
- import {LitElementWw, option} from "@webwriter/lit"
3
- import {customElement, property} from "lit/decorators.js"
4
- import "@shoelace-style/shoelace/dist/themes/light.css"
5
-
6
- declare global {interface HTMLElementTagNameMap {
7
- "webwriter-pairing-item": WebwriterPairingItem;
8
- }}
9
-
10
- @customElement("webwriter-pairing-item")
11
- export class WebwriterPairingItem extends LitElementWw {
12
-
13
- tabIndex = -1
14
-
15
- static styles = css`
16
-
17
- :host {
18
- aspect-ratio: 1;
19
- min-width: 125px;
20
- max-width: 350px;
21
- min-height: 125px;
22
- max-height: 350px;
23
- position: relative;
24
- overflow: hidden;
25
- overflow-y: auto;
26
- scrollbar-width: thin;
27
- resize: both;
28
- border: 2px solid var(--sl-color-gray-500);
29
- border-radius: 5px;
30
- background: white;
31
- }
32
-
33
- slot {
34
- width: 100%;
35
- height: 100%;
36
- display: flex;
37
- box-sizing: border-box;
38
- position: relative;
39
- font-size: 0.8em;
40
- z-index: 1;
41
- }
42
-
43
- :host([droppreview]) slot {
44
- background: lightblue;
45
- }
46
-
47
- ::slotted(*) {
48
- height: 100%;
49
- width: 100%;
50
- box-sizing: border-box;
51
- }
52
-
53
- ::slotted(:not(:is(picture, audio, video, img, iframe))) {
54
- padding: 5px !important;
55
- }
56
-
57
- #handle {
58
- box-sizing: border-box;
59
- border-radius: 2px;
60
- position: absolute;
61
- left: 1px;
62
- bottom: 1px;
63
- width: 20px;
64
- height: 30px;
65
- display: inline-block;
66
- overflow: hidden;
67
- line-height: 5px;
68
- padding: 6px 4px;
69
- cursor: move;
70
- vertical-align: middle;
71
- font-size: 12px;
72
- font-family: sans-serif;
73
- letter-spacing: 2px;
74
- color: #cccccc;
75
- text-shadow: 1px 0 1px black;
76
- font-weight: 600;
77
- opacity: 0.95;
78
- z-index: 100;
79
- }
80
- #handle::after {
81
- content: '.. .. ..';
82
- }
83
-
84
- :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
85
- display: none !important;
86
- }
87
-
88
- #click-overlay {
89
- position: absolute;
90
- top: 0;
91
- width: 100%;
92
- height: 100%;
93
- cursor: pointer;
94
- }
95
-
96
- #click-overlay:hover {
97
- background: var(--sl-color-primary-600);
98
- opacity: 10%;
99
- }
100
-
101
- :host(.ww-selected) #click-overlay {
102
- display: none;
103
- }
104
- `
105
-
106
- @property({attribute: true, reflect: true, converter: {toAttribute: (v: boolean) => v? "true": "false", fromAttribute: (attr: string) => attr === "true"}})
107
- accessor draggable = true
108
-
109
- @property({type: Boolean, attribute: true, reflect: true})
110
- accessor dropPreview = false
111
-
112
- connectedCallback(): void {
113
- super.connectedCallback()
114
- this.addEventListener("dragstart", e => {
115
- if(e.target !== this) {
116
- e.preventDefault()
117
- }
118
- // this.dropPreview = undefined
119
- e.dataTransfer.setData("text/html", this.outerHTML)
120
- e.dataTransfer.setData("text/plain", this.id)
121
- // setTimeout(() => this.baseEl.style.visibility = "hidden")
122
- e.stopPropagation()
123
- })
124
- this.addEventListener("drop", e => {
125
- e.stopPropagation()
126
- const id = e.dataTransfer.getData("text/plain")
127
- const el = document.querySelector(`webwriter-pairing-item#${id}`)
128
- if(!el) {
129
- const html = e.dataTransfer.getData("text/html")
130
- this.parentElement.insertAdjacentHTML("beforeend", html)
131
- }
132
- else if(el && !this.contains(el)) {
133
- this.parentElement.insertAdjacentElement("beforeend", el)
134
- }
135
- this.dispatchEvent(new CustomEvent("ww-pairwith", {bubbles: true, detail: {with: id}}))
136
- }, {passive: true})
137
- this.addEventListener("dragover", e => {
138
- this.dropPreview = true
139
- e.preventDefault()
140
- e.stopImmediatePropagation()
141
- })
142
- this.addEventListener("dragleave", () => this.dropPreview = false, {passive: true})
143
- document.addEventListener("dragend", (e) => {
144
- // (e.target as HTMLElement)?.remove()
145
- this.dropPreview = false
146
- }, {passive: true})
147
- }
148
-
149
- render() {
150
- return html`
151
- <slot></slot>
152
- <div class="author-only" id="handle" @click=${() => this.dispatchEvent(new FocusEvent("focus"))}></div>
153
-
154
- `
155
- }
1
+ import {html, css} from "lit"
2
+ import {LitElementWw, option} from "@webwriter/lit"
3
+ import {customElement, property} from "lit/decorators.js"
4
+ import "@shoelace-style/shoelace/dist/themes/light.css"
5
+
6
+ declare global {interface HTMLElementTagNameMap {
7
+ "webwriter-pairing-item": WebwriterPairingItem;
8
+ }}
9
+
10
+ @customElement("webwriter-pairing-item")
11
+ export class WebwriterPairingItem extends LitElementWw {
12
+
13
+ tabIndex = -1
14
+
15
+ static styles = css`
16
+
17
+ :host {
18
+ aspect-ratio: 1;
19
+ min-width: 125px;
20
+ max-width: 350px;
21
+ min-height: 125px;
22
+ max-height: 350px;
23
+ position: relative;
24
+ overflow: hidden;
25
+ overflow-y: auto;
26
+ scrollbar-width: thin;
27
+ resize: both;
28
+ border: 2px solid var(--sl-color-gray-500);
29
+ border-radius: 5px;
30
+ background: white;
31
+ }
32
+
33
+ slot {
34
+ width: 100%;
35
+ height: 100%;
36
+ display: flex;
37
+ box-sizing: border-box;
38
+ position: relative;
39
+ font-size: 0.8em;
40
+ z-index: 1;
41
+ }
42
+
43
+ :host([droppreview]) slot {
44
+ background: lightblue;
45
+ }
46
+
47
+ ::slotted(*) {
48
+ height: 100%;
49
+ width: 100%;
50
+ box-sizing: border-box;
51
+ }
52
+
53
+ ::slotted(:not(:is(picture, audio, video, img, iframe))) {
54
+ padding: 5px !important;
55
+ }
56
+
57
+ #handle {
58
+ box-sizing: border-box;
59
+ border-radius: 2px;
60
+ position: absolute;
61
+ left: 1px;
62
+ bottom: 1px;
63
+ width: 20px;
64
+ height: 30px;
65
+ display: inline-block;
66
+ overflow: hidden;
67
+ line-height: 5px;
68
+ padding: 6px 4px;
69
+ cursor: move;
70
+ vertical-align: middle;
71
+ font-size: 12px;
72
+ font-family: sans-serif;
73
+ letter-spacing: 2px;
74
+ color: #cccccc;
75
+ text-shadow: 1px 0 1px black;
76
+ font-weight: 600;
77
+ opacity: 0.95;
78
+ z-index: 100;
79
+ }
80
+ #handle::after {
81
+ content: '.. .. ..';
82
+ }
83
+
84
+ :host(:not([contenteditable=true]):not([contenteditable=""])) .author-only {
85
+ display: none !important;
86
+ }
87
+
88
+ #click-overlay {
89
+ position: absolute;
90
+ top: 0;
91
+ width: 100%;
92
+ height: 100%;
93
+ cursor: pointer;
94
+ }
95
+
96
+ #click-overlay:hover {
97
+ background: var(--sl-color-primary-600);
98
+ opacity: 10%;
99
+ }
100
+
101
+ :host(.ww-selected) #click-overlay {
102
+ display: none;
103
+ }
104
+ `
105
+
106
+ @property({attribute: true, reflect: true, converter: {toAttribute: (v: boolean) => v? "true": "false", fromAttribute: (attr: string) => attr === "true"}})
107
+ accessor draggable = true
108
+
109
+ @property({type: Boolean, attribute: true, reflect: true})
110
+ accessor dropPreview = false
111
+
112
+ connectedCallback(): void {
113
+ super.connectedCallback()
114
+ this.addEventListener("dragstart", e => {
115
+ if(e.target !== this) {
116
+ e.preventDefault()
117
+ }
118
+ // this.dropPreview = undefined
119
+ e.dataTransfer.setData("text/html", this.outerHTML)
120
+ e.dataTransfer.setData("text/plain", this.id)
121
+ // setTimeout(() => this.baseEl.style.visibility = "hidden")
122
+ e.stopPropagation()
123
+ })
124
+ this.addEventListener("drop", e => {
125
+ e.stopPropagation()
126
+ const id = e.dataTransfer.getData("text/plain")
127
+ const el = document.querySelector(`webwriter-pairing-item#${id}`)
128
+ if(!el) {
129
+ const html = e.dataTransfer.getData("text/html")
130
+ this.parentElement.insertAdjacentHTML("beforeend", html)
131
+ }
132
+ else if(el && !this.contains(el)) {
133
+ this.parentElement.insertAdjacentElement("beforeend", el)
134
+ }
135
+ this.dispatchEvent(new CustomEvent("ww-pairwith", {bubbles: true, detail: {with: id}}))
136
+ }, {passive: true})
137
+ this.addEventListener("dragover", e => {
138
+ this.dropPreview = true
139
+ e.preventDefault()
140
+ e.stopImmediatePropagation()
141
+ })
142
+ this.addEventListener("dragleave", () => this.dropPreview = false, {passive: true})
143
+ document.addEventListener("dragend", (e) => {
144
+ // (e.target as HTMLElement)?.remove()
145
+ this.dropPreview = false
146
+ }, {passive: true})
147
+ }
148
+
149
+ render() {
150
+ return html`
151
+ <slot></slot>
152
+ <div class="author-only" id="handle" @click=${() => this.dispatchEvent(new FocusEvent("focus"))}></div>
153
+
154
+ `
155
+ }
156
156
  }