@pie-qti/default-components 0.1.1
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/.turbo/turbo-build.log +1 -0
- package/CHANGELOG.md +9 -0
- package/STYLING.md +226 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +190 -0
- package/dist/plugins/associate/index.d.ts +8 -0
- package/dist/plugins/associate/index.d.ts.map +1 -0
- package/dist/plugins/associate/index.js +8 -0
- package/dist/plugins/choice/index.d.ts +8 -0
- package/dist/plugins/choice/index.d.ts.map +1 -0
- package/dist/plugins/choice/index.js +8 -0
- package/dist/plugins/custom/index.d.ts +8 -0
- package/dist/plugins/custom/index.d.ts.map +1 -0
- package/dist/plugins/custom/index.js +8 -0
- package/dist/plugins/end-attempt/index.d.ts +8 -0
- package/dist/plugins/end-attempt/index.d.ts.map +1 -0
- package/dist/plugins/end-attempt/index.js +8 -0
- package/dist/plugins/extended-text/index.d.ts +8 -0
- package/dist/plugins/extended-text/index.d.ts.map +1 -0
- package/dist/plugins/extended-text/index.js +8 -0
- package/dist/plugins/gap-match/index.d.ts +8 -0
- package/dist/plugins/gap-match/index.d.ts.map +1 -0
- package/dist/plugins/gap-match/index.js +8 -0
- package/dist/plugins/graphic-associate/index.d.ts +8 -0
- package/dist/plugins/graphic-associate/index.d.ts.map +1 -0
- package/dist/plugins/graphic-associate/index.js +8 -0
- package/dist/plugins/graphic-gap-match/index.d.ts +8 -0
- package/dist/plugins/graphic-gap-match/index.d.ts.map +1 -0
- package/dist/plugins/graphic-gap-match/index.js +8 -0
- package/dist/plugins/graphic-order/index.d.ts +8 -0
- package/dist/plugins/graphic-order/index.d.ts.map +1 -0
- package/dist/plugins/graphic-order/index.js +8 -0
- package/dist/plugins/hotspot/index.d.ts +8 -0
- package/dist/plugins/hotspot/index.d.ts.map +1 -0
- package/dist/plugins/hotspot/index.js +8 -0
- package/dist/plugins/hottext/index.d.ts +8 -0
- package/dist/plugins/hottext/index.d.ts.map +1 -0
- package/dist/plugins/hottext/index.js +8 -0
- package/dist/plugins/index.d.ts +30 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +30 -0
- package/dist/plugins/match/index.d.ts +8 -0
- package/dist/plugins/match/index.d.ts.map +1 -0
- package/dist/plugins/match/index.js +8 -0
- package/dist/plugins/media/index.d.ts +8 -0
- package/dist/plugins/media/index.d.ts.map +1 -0
- package/dist/plugins/media/index.js +8 -0
- package/dist/plugins/order/index.d.ts +8 -0
- package/dist/plugins/order/index.d.ts.map +1 -0
- package/dist/plugins/order/index.js +8 -0
- package/dist/plugins/position-object/index.d.ts +8 -0
- package/dist/plugins/position-object/index.d.ts.map +1 -0
- package/dist/plugins/position-object/index.js +8 -0
- package/dist/plugins/select-point/index.d.ts +8 -0
- package/dist/plugins/select-point/index.d.ts.map +1 -0
- package/dist/plugins/select-point/index.js +8 -0
- package/dist/plugins/slider/index.d.ts +8 -0
- package/dist/plugins/slider/index.d.ts.map +1 -0
- package/dist/plugins/slider/index.js +8 -0
- package/dist/shared/actions/typesetAction.d.ts +26 -0
- package/dist/shared/actions/typesetAction.d.ts.map +1 -0
- package/dist/shared/actions/typesetAction.js +70 -0
- package/dist/shared/extensions/MathLiveEditor.d.ts +19 -0
- package/dist/shared/extensions/MathLiveEditor.d.ts.map +1 -0
- package/dist/shared/extensions/MathLiveEditor.js +239 -0
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +15 -0
- package/dist/shared/utils/eventHelpers.d.ts +18 -0
- package/dist/shared/utils/eventHelpers.d.ts.map +1 -0
- package/dist/shared/utils/eventHelpers.js +30 -0
- package/dist/shared/utils/pairHelpers.d.ts +55 -0
- package/dist/shared/utils/pairHelpers.d.ts.map +1 -0
- package/dist/shared/utils/pairHelpers.js +76 -0
- package/dist/shared/utils/touchDragHelper.d.ts +33 -0
- package/dist/shared/utils/touchDragHelper.d.ts.map +1 -0
- package/dist/shared/utils/touchDragHelper.js +168 -0
- package/dist/shared/utils/webComponentHelpers.d.ts +9 -0
- package/dist/shared/utils/webComponentHelpers.d.ts.map +1 -0
- package/dist/shared/utils/webComponentHelpers.js +26 -0
- package/package.json +93 -0
- package/src/index.ts +213 -0
- package/src/plugins/associate/AssociateInteraction.svelte +273 -0
- package/src/plugins/associate/index.ts +9 -0
- package/src/plugins/choice/ChoiceInteraction.svelte +212 -0
- package/src/plugins/choice/index.ts +9 -0
- package/src/plugins/custom/CustomInteraction.svelte +61 -0
- package/src/plugins/custom/index.ts +9 -0
- package/src/plugins/drawing/DrawingInteraction.svelte +90 -0
- package/src/plugins/end-attempt/EndAttemptInteraction.svelte +142 -0
- package/src/plugins/end-attempt/index.ts +9 -0
- package/src/plugins/extended-text/ExtendedTextInteraction.svelte +77 -0
- package/src/plugins/extended-text/index.ts +9 -0
- package/src/plugins/gap-match/GapMatchInteraction.svelte +379 -0
- package/src/plugins/gap-match/index.ts +9 -0
- package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +427 -0
- package/src/plugins/graphic-associate/index.ts +9 -0
- package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +508 -0
- package/src/plugins/graphic-gap-match/index.ts +9 -0
- package/src/plugins/graphic-order/GraphicOrderInteraction.svelte +241 -0
- package/src/plugins/graphic-order/index.ts +9 -0
- package/src/plugins/hotspot/HotspotInteraction.svelte +244 -0
- package/src/plugins/hotspot/index.ts +9 -0
- package/src/plugins/hottext/HottextInteraction.svelte +296 -0
- package/src/plugins/hottext/index.ts +9 -0
- package/src/plugins/index.ts +31 -0
- package/src/plugins/match/MatchInteraction.svelte +70 -0
- package/src/plugins/match/index.ts +9 -0
- package/src/plugins/media/MediaInteraction.svelte +213 -0
- package/src/plugins/media/index.ts +9 -0
- package/src/plugins/order/OrderInteraction.svelte +159 -0
- package/src/plugins/order/index.ts +9 -0
- package/src/plugins/position-object/PositionObjectInteraction.svelte +671 -0
- package/src/plugins/position-object/README.md +130 -0
- package/src/plugins/position-object/index.ts +9 -0
- package/src/plugins/select-point/SelectPointInteraction.svelte +453 -0
- package/src/plugins/select-point/index.ts +9 -0
- package/src/plugins/slider/SliderInteraction.svelte +141 -0
- package/src/plugins/slider/index.ts +9 -0
- package/src/plugins/upload/UploadInteraction.svelte +59 -0
- package/src/shared/actions/typesetAction.ts +87 -0
- package/src/shared/components/CustomInteractionFallback.svelte +153 -0
- package/src/shared/components/DragHandle.svelte +44 -0
- package/src/shared/components/DrawingCanvas.svelte +243 -0
- package/src/shared/components/FileUpload.svelte +153 -0
- package/src/shared/components/GraphicGapMatch.svelte +316 -0
- package/src/shared/components/GraphicGapMatchAdapter.svelte +36 -0
- package/src/shared/components/InlineInteractionRenderer.svelte +124 -0
- package/src/shared/components/MatchDragDrop.svelte +434 -0
- package/src/shared/components/MathContent.svelte +18 -0
- package/src/shared/components/ModalFeedbackDisplay.svelte +81 -0
- package/src/shared/components/RichTextEditor.svelte +316 -0
- package/src/shared/components/ShadowBaseStyles.svelte +391 -0
- package/src/shared/components/SortableList.svelte +297 -0
- package/src/shared/extensions/MathLiveEditor.ts +304 -0
- package/src/shared/index.ts +17 -0
- package/src/shared/styles/shared.css +16 -0
- package/src/shared/utils/eventHelpers.ts +36 -0
- package/src/shared/utils/pairHelpers.ts +86 -0
- package/src/shared/utils/touchDragHelper.ts +211 -0
- package/src/shared/utils/webComponentHelpers.ts +27 -0
- package/src/svelte-shims.d.ts +9 -0
- package/svelte.config.js +9 -0
- package/tests/index.test.ts +8 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
|
|
3
|
+
import { Editor } from '@tiptap/core';
|
|
4
|
+
import { Mathematics } from '@tiptap/extension-mathematics';
|
|
5
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
6
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
7
|
+
import { untrack } from 'svelte';
|
|
8
|
+
import type { I18nProvider } from '@pie-qti/i18n';
|
|
9
|
+
import { openMathLiveEditor } from '../extensions/MathLiveEditor.js';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
value?: string;
|
|
13
|
+
editable?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
minHeight?: number;
|
|
16
|
+
i18n?: I18nProvider;
|
|
17
|
+
onChange?: (html: string) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
value = '',
|
|
22
|
+
editable = true,
|
|
23
|
+
placeholder = '',
|
|
24
|
+
minHeight = 200,
|
|
25
|
+
i18n,
|
|
26
|
+
onChange,
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
// Translations
|
|
30
|
+
const translations = $derived({
|
|
31
|
+
bold: i18n?.t('interactions.extendedText.bold') ?? 'interactions.extendedText.bold',
|
|
32
|
+
italic: i18n?.t('interactions.extendedText.italic') ?? 'interactions.extendedText.italic',
|
|
33
|
+
insertInlineMath: i18n?.t('interactions.extendedText.insertInlineMath') ?? 'interactions.extendedText.insertInlineMath',
|
|
34
|
+
insertBlockMath: i18n?.t('interactions.extendedText.insertBlockMath') ?? 'interactions.extendedText.insertBlockMath',
|
|
35
|
+
editorLabel: placeholder || (i18n?.t('interactions.extendedText.placeholder') ?? 'interactions.extendedText.placeholder'),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let el: HTMLDivElement | null = $state(null);
|
|
39
|
+
let editor: Editor | null = $state(null);
|
|
40
|
+
// Use a regular variable (not $state) to track last emitted value
|
|
41
|
+
// This prevents circular dependencies in $effect
|
|
42
|
+
let lastEmitted = '';
|
|
43
|
+
// Track if we're currently programmatically updating to avoid loops
|
|
44
|
+
let isProgrammaticUpdate = false;
|
|
45
|
+
|
|
46
|
+
function emit(html: string) {
|
|
47
|
+
// Don't emit changes that we're causing programmatically
|
|
48
|
+
if (isProgrammaticUpdate) return;
|
|
49
|
+
lastEmitted = html;
|
|
50
|
+
onChange?.(html);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function insertInlineMath() {
|
|
54
|
+
if (!editor) return;
|
|
55
|
+
openMathLiveEditor({
|
|
56
|
+
initialLatex: '\\frac{a}{b}',
|
|
57
|
+
isBlock: false,
|
|
58
|
+
i18n,
|
|
59
|
+
onConfirm: (latex) => {
|
|
60
|
+
editor?.commands.insertInlineMath({ latex });
|
|
61
|
+
editor?.commands.focus();
|
|
62
|
+
},
|
|
63
|
+
onCancel: () => {
|
|
64
|
+
editor?.commands.focus();
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function insertBlockMath() {
|
|
70
|
+
if (!editor) return;
|
|
71
|
+
openMathLiveEditor({
|
|
72
|
+
initialLatex: '\\frac{a}{b}',
|
|
73
|
+
isBlock: true,
|
|
74
|
+
i18n,
|
|
75
|
+
onConfirm: (latex) => {
|
|
76
|
+
editor?.commands.insertBlockMath({ latex });
|
|
77
|
+
editor?.commands.focus();
|
|
78
|
+
},
|
|
79
|
+
onCancel: () => {
|
|
80
|
+
editor?.commands.focus();
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Initialize editor once when element is available
|
|
86
|
+
// Only tracks 'el' as a dependency, use untrack for other props to prevent recreation
|
|
87
|
+
$effect(() => {
|
|
88
|
+
if (!el) return;
|
|
89
|
+
|
|
90
|
+
// Capture initial values without tracking them as dependencies
|
|
91
|
+
const initialValue = untrack(() => value?.trim() ? value : '<p></p>');
|
|
92
|
+
const initialPlaceholder = untrack(() => placeholder);
|
|
93
|
+
const initialMinHeight = untrack(() => minHeight);
|
|
94
|
+
const initialEditable = untrack(() => editable);
|
|
95
|
+
const initialEditorLabel = untrack(() => translations.editorLabel);
|
|
96
|
+
const initialI18n = untrack(() => i18n);
|
|
97
|
+
|
|
98
|
+
const ed = new Editor({
|
|
99
|
+
element: el,
|
|
100
|
+
extensions: [
|
|
101
|
+
StarterKit.configure({
|
|
102
|
+
// keep these minimal, but sensible for extended response editing
|
|
103
|
+
codeBlock: false,
|
|
104
|
+
}),
|
|
105
|
+
Placeholder.configure({
|
|
106
|
+
placeholder: initialPlaceholder,
|
|
107
|
+
}),
|
|
108
|
+
Mathematics.configure({
|
|
109
|
+
inlineOptions: {
|
|
110
|
+
onClick: (node, pos) => {
|
|
111
|
+
openMathLiveEditor({
|
|
112
|
+
initialLatex: node.attrs?.latex || '',
|
|
113
|
+
isBlock: false,
|
|
114
|
+
i18n: initialI18n,
|
|
115
|
+
onConfirm: (latex) => {
|
|
116
|
+
ed.chain().setNodeSelection(pos).updateInlineMath({ latex }).focus().run();
|
|
117
|
+
},
|
|
118
|
+
onCancel: () => {
|
|
119
|
+
ed.commands.focus();
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
blockOptions: {
|
|
125
|
+
onClick: (node, pos) => {
|
|
126
|
+
openMathLiveEditor({
|
|
127
|
+
initialLatex: node.attrs?.latex || '',
|
|
128
|
+
isBlock: true,
|
|
129
|
+
i18n: initialI18n,
|
|
130
|
+
onConfirm: (latex) => {
|
|
131
|
+
ed.chain().setNodeSelection(pos).updateBlockMath({ latex }).focus().run();
|
|
132
|
+
},
|
|
133
|
+
onCancel: () => {
|
|
134
|
+
ed.commands.focus();
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
katexOptions: {
|
|
140
|
+
throwOnError: false,
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
],
|
|
144
|
+
content: initialValue,
|
|
145
|
+
editable: initialEditable,
|
|
146
|
+
editorProps: {
|
|
147
|
+
attributes: {
|
|
148
|
+
// Stable hook for theming. The host app's DaisyUI theme vars cascade here.
|
|
149
|
+
class: 'pie-tiptap tiptap-prose',
|
|
150
|
+
style: `min-height: ${initialMinHeight}px`,
|
|
151
|
+
role: 'textbox',
|
|
152
|
+
'aria-multiline': 'true',
|
|
153
|
+
'aria-label': initialEditorLabel,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
onUpdate: ({ editor: ed }) => {
|
|
157
|
+
const html = ed.getHTML();
|
|
158
|
+
// Only emit if content actually changed
|
|
159
|
+
if (html !== lastEmitted) {
|
|
160
|
+
emit(html);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
editor = ed;
|
|
166
|
+
lastEmitted = ed.getHTML();
|
|
167
|
+
|
|
168
|
+
return () => {
|
|
169
|
+
editor?.destroy();
|
|
170
|
+
editor = null;
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Keep editable in sync (without re-creating the editor)
|
|
175
|
+
$effect(() => {
|
|
176
|
+
if (editor) {
|
|
177
|
+
editor.setEditable(editable);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// External value updates (avoid stomping over active edits)
|
|
182
|
+
$effect(() => {
|
|
183
|
+
if (!editor) return;
|
|
184
|
+
// Only react to value prop changes
|
|
185
|
+
const next = value || '';
|
|
186
|
+
// Skip if this value was just emitted by us
|
|
187
|
+
if (next === lastEmitted) return;
|
|
188
|
+
// Don't interrupt active editing
|
|
189
|
+
if (editor.isFocused) return;
|
|
190
|
+
// Set flag to prevent emit from firing during programmatic update
|
|
191
|
+
isProgrammaticUpdate = true;
|
|
192
|
+
try {
|
|
193
|
+
// Update editor content without triggering onUpdate callback
|
|
194
|
+
editor.commands.setContent(next || '<p></p>', { emitUpdate: false });
|
|
195
|
+
// Track what we set so we don't react to our own updates
|
|
196
|
+
lastEmitted = editor.getHTML();
|
|
197
|
+
} finally {
|
|
198
|
+
isProgrammaticUpdate = false;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
</script>
|
|
202
|
+
|
|
203
|
+
<div part="root" class="richtext-editor" data-readonly={editable ? 'false' : 'true'}>
|
|
204
|
+
<div part="toolbar" class="rte-toolbar">
|
|
205
|
+
<button
|
|
206
|
+
part="toolbar-button"
|
|
207
|
+
class="btn btn-sm"
|
|
208
|
+
type="button"
|
|
209
|
+
disabled={!editor || !editable}
|
|
210
|
+
onclick={() => editor?.chain().focus().toggleBold().run()}
|
|
211
|
+
aria-label={translations.bold}
|
|
212
|
+
>
|
|
213
|
+
<strong>B</strong>
|
|
214
|
+
</button>
|
|
215
|
+
<button
|
|
216
|
+
part="toolbar-button"
|
|
217
|
+
class="btn btn-sm"
|
|
218
|
+
type="button"
|
|
219
|
+
disabled={!editor || !editable}
|
|
220
|
+
onclick={() => editor?.chain().focus().toggleItalic().run()}
|
|
221
|
+
aria-label={translations.italic}
|
|
222
|
+
>
|
|
223
|
+
<em>I</em>
|
|
224
|
+
</button>
|
|
225
|
+
<div part="toolbar-divider" class="divider divider-horizontal mx-0"></div>
|
|
226
|
+
<button
|
|
227
|
+
part="toolbar-button"
|
|
228
|
+
class="btn btn-sm"
|
|
229
|
+
type="button"
|
|
230
|
+
disabled={!editor || !editable}
|
|
231
|
+
onclick={() => insertInlineMath()}
|
|
232
|
+
aria-label={translations.insertInlineMath}
|
|
233
|
+
>
|
|
234
|
+
{translations.insertInlineMath}
|
|
235
|
+
</button>
|
|
236
|
+
<button
|
|
237
|
+
part="toolbar-button"
|
|
238
|
+
class="btn btn-sm"
|
|
239
|
+
type="button"
|
|
240
|
+
disabled={!editor || !editable}
|
|
241
|
+
onclick={() => insertBlockMath()}
|
|
242
|
+
aria-label={translations.insertBlockMath}
|
|
243
|
+
>
|
|
244
|
+
{translations.insertBlockMath}
|
|
245
|
+
</button>
|
|
246
|
+
</div>
|
|
247
|
+
|
|
248
|
+
<div part="editor" class="tiptap-editor-container" bind:this={el}></div>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<style>
|
|
252
|
+
.richtext-editor {
|
|
253
|
+
display: flex;
|
|
254
|
+
flex-direction: column;
|
|
255
|
+
gap: 0.5rem;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.rte-toolbar {
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
gap: 0.25rem;
|
|
262
|
+
flex-wrap: wrap;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.tiptap-editor-container {
|
|
266
|
+
background: var(--color-base-100, oklch(100% 0 0));
|
|
267
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
268
|
+
border-radius: 0.5rem;
|
|
269
|
+
padding: 0.75rem;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.tiptap-editor-container:focus-within {
|
|
273
|
+
border-color: var(--color-primary, oklch(45% 0.24 277));
|
|
274
|
+
box-shadow: 0 0 0 2px color-mix(in oklch, var(--color-primary, oklch(45% 0.24 277)) 20%, transparent);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.richtext-editor[data-readonly='true'] .tiptap-editor-container {
|
|
278
|
+
background: var(--color-base-200, oklch(98% 0 0));
|
|
279
|
+
cursor: not-allowed;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* Prose content styling (scoped to our stable hook) */
|
|
283
|
+
:global(.pie-tiptap) {
|
|
284
|
+
outline: none;
|
|
285
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
:global(.pie-tiptap p) {
|
|
289
|
+
margin: 0 0 0.5rem 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
:global(.pie-tiptap p:last-child) {
|
|
293
|
+
margin-bottom: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* Placeholder */
|
|
297
|
+
:global(.pie-tiptap p.is-editor-empty:first-child::before) {
|
|
298
|
+
content: attr(data-placeholder);
|
|
299
|
+
float: left;
|
|
300
|
+
color: color-mix(in oklch, var(--color-base-content, oklch(21% 0 0)) 45%, transparent);
|
|
301
|
+
pointer-events: none;
|
|
302
|
+
height: 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* Mathematics extension (KaTeX) */
|
|
306
|
+
:global(.pie-tiptap .katex) {
|
|
307
|
+
font-size: 1em;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
:global(.pie-tiptap .katex-display) {
|
|
311
|
+
margin: 1rem 0;
|
|
312
|
+
text-align: center;
|
|
313
|
+
}
|
|
314
|
+
</style>
|
|
315
|
+
|
|
316
|
+
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Shared baseline styles for Shadow DOM web components.
|
|
3
|
+
|
|
4
|
+
Purpose:
|
|
5
|
+
- Provide minimal, readable styling when the host does NOT load DaisyUI/Tailwind CSS.
|
|
6
|
+
- Still allow host theming via DaisyUI-like CSS variables (e.g. --p, --b1, --bc).
|
|
7
|
+
|
|
8
|
+
Notes:
|
|
9
|
+
- Uses :global(...) so these styles apply within the component's shadow root.
|
|
10
|
+
- Intentionally minimal: interaction components may still add their own layout CSS.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
/* Import KaTeX CSS for math rendering in Shadow DOM */
|
|
15
|
+
@import url('https://cdn.jsdelivr.net/npm/katex@0.16.27/dist/katex.min.css');
|
|
16
|
+
/* Buttons */
|
|
17
|
+
:global(.btn) {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
gap: 0.5rem;
|
|
22
|
+
padding: 0.5rem 0.75rem;
|
|
23
|
+
border-radius: 0.75rem;
|
|
24
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
25
|
+
background: var(--color-base-200, oklch(98% 0 0));
|
|
26
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
27
|
+
font: inherit;
|
|
28
|
+
line-height: 1.1;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
user-select: none;
|
|
31
|
+
transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
|
|
32
|
+
}
|
|
33
|
+
:global(.btn:hover:not(:disabled)) {
|
|
34
|
+
background: var(--color-base-300, oklch(95% 0 0));
|
|
35
|
+
border-color: var(--color-base-content, oklch(21% 0 0));
|
|
36
|
+
}
|
|
37
|
+
:global(.btn:active:not(:disabled)) {
|
|
38
|
+
transform: scale(0.97);
|
|
39
|
+
}
|
|
40
|
+
:global(.btn:focus-visible) {
|
|
41
|
+
outline: 2px solid var(--color-primary, oklch(45% 0.24 277));
|
|
42
|
+
outline-offset: 2px;
|
|
43
|
+
}
|
|
44
|
+
:global(.btn:disabled),
|
|
45
|
+
:global(.btn.btn-disabled) {
|
|
46
|
+
opacity: 0.55;
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
}
|
|
49
|
+
:global(.btn-primary) {
|
|
50
|
+
border-color: var(--color-primary, oklch(45% 0.24 277));
|
|
51
|
+
background: color-mix(in oklch, var(--color-primary, oklch(45% 0.24 277)) 12%, transparent);
|
|
52
|
+
}
|
|
53
|
+
:global(.btn-secondary) {
|
|
54
|
+
border-color: var(--color-secondary, oklch(65% 0.241 354.308));
|
|
55
|
+
background: color-mix(in oklch, var(--color-secondary, oklch(65% 0.241 354.308)) 12%, transparent);
|
|
56
|
+
}
|
|
57
|
+
:global(.btn-accent) {
|
|
58
|
+
border-color: var(--color-accent, oklch(77% 0.152 181.912));
|
|
59
|
+
background: color-mix(in oklch, var(--color-accent, oklch(77% 0.152 181.912)) 12%, transparent);
|
|
60
|
+
}
|
|
61
|
+
:global(.btn-success) {
|
|
62
|
+
border-color: var(--color-success, oklch(76% 0.177 163.223));
|
|
63
|
+
background: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 12%, transparent);
|
|
64
|
+
}
|
|
65
|
+
:global(.btn-warning) {
|
|
66
|
+
border-color: var(--color-warning, oklch(82% 0.189 84.429));
|
|
67
|
+
background: color-mix(in oklch, var(--color-warning, oklch(82% 0.189 84.429)) 12%, transparent);
|
|
68
|
+
}
|
|
69
|
+
:global(.btn-error) {
|
|
70
|
+
border-color: var(--color-error, oklch(71% 0.194 13.428));
|
|
71
|
+
background: color-mix(in oklch, var(--color-error, oklch(71% 0.194 13.428)) 12%, transparent);
|
|
72
|
+
}
|
|
73
|
+
:global(.btn-ghost) {
|
|
74
|
+
background: transparent;
|
|
75
|
+
border-color: transparent;
|
|
76
|
+
}
|
|
77
|
+
:global(.btn-ghost:hover:not(:disabled)) {
|
|
78
|
+
background: var(--color-base-200, oklch(98% 0 0));
|
|
79
|
+
border-color: var(--color-base-300, oklch(95% 0 0));
|
|
80
|
+
}
|
|
81
|
+
:global(.btn-outline) {
|
|
82
|
+
background: transparent;
|
|
83
|
+
}
|
|
84
|
+
:global(.btn-sm) {
|
|
85
|
+
padding: 0.35rem 0.6rem;
|
|
86
|
+
border-radius: 0.6rem;
|
|
87
|
+
font-size: 0.875rem;
|
|
88
|
+
}
|
|
89
|
+
:global(.btn-xs) {
|
|
90
|
+
padding: 0.25rem 0.45rem;
|
|
91
|
+
border-radius: 0.5rem;
|
|
92
|
+
font-size: 0.75rem;
|
|
93
|
+
}
|
|
94
|
+
:global(.btn-circle) {
|
|
95
|
+
border-radius: 9999px;
|
|
96
|
+
padding: 0;
|
|
97
|
+
width: 2rem;
|
|
98
|
+
height: 2rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Badges */
|
|
102
|
+
:global(.badge) {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
padding: 0 0.5rem;
|
|
107
|
+
height: 1.25rem;
|
|
108
|
+
border-radius: 9999px;
|
|
109
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
110
|
+
background: var(--color-base-100, oklch(100% 0 0));
|
|
111
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
112
|
+
font-size: 0.75rem;
|
|
113
|
+
font-weight: 600;
|
|
114
|
+
}
|
|
115
|
+
:global(.badge-sm) {
|
|
116
|
+
height: 1.1rem;
|
|
117
|
+
font-size: 0.7rem;
|
|
118
|
+
}
|
|
119
|
+
:global(.badge-lg) {
|
|
120
|
+
height: 1.5rem;
|
|
121
|
+
font-size: 0.85rem;
|
|
122
|
+
}
|
|
123
|
+
:global(.badge-primary) {
|
|
124
|
+
border-color: var(--color-primary, oklch(45% 0.24 277));
|
|
125
|
+
background: color-mix(in oklch, var(--color-primary, oklch(45% 0.24 277)) 12%, transparent);
|
|
126
|
+
}
|
|
127
|
+
:global(.badge-success) {
|
|
128
|
+
border-color: var(--color-success, oklch(76% 0.177 163.223));
|
|
129
|
+
background: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 12%, transparent);
|
|
130
|
+
}
|
|
131
|
+
:global(.badge-warning) {
|
|
132
|
+
border-color: var(--color-warning, oklch(82% 0.189 84.429));
|
|
133
|
+
background: color-mix(in oklch, var(--color-warning, oklch(82% 0.189 84.429)) 12%, transparent);
|
|
134
|
+
}
|
|
135
|
+
:global(.badge-error) {
|
|
136
|
+
border-color: var(--color-error, oklch(71% 0.194 13.428));
|
|
137
|
+
background: color-mix(in oklch, var(--color-error, oklch(71% 0.194 13.428)) 12%, transparent);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Alerts */
|
|
141
|
+
:global(.alert) {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
gap: 0.5rem;
|
|
145
|
+
padding: 0.75rem 1rem;
|
|
146
|
+
border-radius: 0.75rem;
|
|
147
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
148
|
+
background: var(--color-base-200, oklch(98% 0 0));
|
|
149
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
150
|
+
}
|
|
151
|
+
:global(.alert-info) {
|
|
152
|
+
border-color: var(--color-info, oklch(74% 0.16 232.661));
|
|
153
|
+
background: color-mix(in oklch, var(--color-info, oklch(74% 0.16 232.661)) 8%, transparent);
|
|
154
|
+
}
|
|
155
|
+
:global(.alert-success) {
|
|
156
|
+
border-color: var(--color-success, oklch(76% 0.177 163.223));
|
|
157
|
+
background: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 8%, transparent);
|
|
158
|
+
}
|
|
159
|
+
:global(.alert-warning) {
|
|
160
|
+
border-color: var(--color-warning, oklch(82% 0.189 84.429));
|
|
161
|
+
background: color-mix(in oklch, var(--color-warning, oklch(82% 0.189 84.429)) 8%, transparent);
|
|
162
|
+
}
|
|
163
|
+
:global(.alert-error) {
|
|
164
|
+
border-color: var(--color-error, oklch(71% 0.194 13.428));
|
|
165
|
+
background: color-mix(in oklch, var(--color-error, oklch(71% 0.194 13.428)) 8%, transparent);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* Correct answer indicators */
|
|
169
|
+
:global(.qti-correct-indicator) {
|
|
170
|
+
display: inline-flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
gap: 0.25rem;
|
|
173
|
+
padding: 0.25rem 0.5rem;
|
|
174
|
+
background: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 8%, transparent);
|
|
175
|
+
border: 1px solid var(--color-success, oklch(76% 0.177 163.223));
|
|
176
|
+
border-radius: 0.5rem;
|
|
177
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
178
|
+
font-size: 0.875rem;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
:global(.qti-correct-highlight) {
|
|
182
|
+
background-color: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 8%, transparent);
|
|
183
|
+
border: 2px solid var(--color-success, oklch(76% 0.177 163.223));
|
|
184
|
+
border-radius: 0.5rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:global(.border-success) {
|
|
188
|
+
border-color: var(--color-success, oklch(76% 0.177 163.223));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
:global(.text-success) {
|
|
192
|
+
color: var(--color-success, oklch(76% 0.177 163.223));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Cards */
|
|
196
|
+
:global(.card) {
|
|
197
|
+
border-radius: 0.75rem;
|
|
198
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
199
|
+
background: var(--color-base-100, oklch(100% 0 0));
|
|
200
|
+
}
|
|
201
|
+
:global(.card-body) {
|
|
202
|
+
padding: 1rem;
|
|
203
|
+
}
|
|
204
|
+
:global(.card-title) {
|
|
205
|
+
font-weight: 700;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Divider */
|
|
209
|
+
:global(.divider) {
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
gap: 0.75rem;
|
|
213
|
+
margin: 0.75rem 0;
|
|
214
|
+
color: color-mix(in oklch, var(--color-base-content, oklch(21% 0 0)) 65%, transparent);
|
|
215
|
+
font-size: 0.875rem;
|
|
216
|
+
}
|
|
217
|
+
:global(.divider::before),
|
|
218
|
+
:global(.divider::after) {
|
|
219
|
+
content: '';
|
|
220
|
+
flex: 1 1 auto;
|
|
221
|
+
height: 1px;
|
|
222
|
+
background: var(--color-base-300, oklch(95% 0 0));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Form controls */
|
|
226
|
+
:global(.select),
|
|
227
|
+
:global(.textarea) {
|
|
228
|
+
border-radius: 0.6rem;
|
|
229
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
230
|
+
background: var(--color-base-100, oklch(100% 0 0));
|
|
231
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
232
|
+
padding: 0.35rem 0.6rem;
|
|
233
|
+
font: inherit;
|
|
234
|
+
}
|
|
235
|
+
:global(.select-sm) {
|
|
236
|
+
font-size: 0.85rem;
|
|
237
|
+
padding: 0.25rem 0.5rem;
|
|
238
|
+
}
|
|
239
|
+
:global(.textarea) {
|
|
240
|
+
padding: 0.5rem 0.75rem;
|
|
241
|
+
}
|
|
242
|
+
:global(.radio),
|
|
243
|
+
:global(.checkbox) {
|
|
244
|
+
accent-color: var(--color-primary, oklch(45% 0.24 277));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* Tailwind utilities for canvas drawing */
|
|
248
|
+
:global(.touch-none) {
|
|
249
|
+
touch-action: none;
|
|
250
|
+
}
|
|
251
|
+
:global(.absolute) {
|
|
252
|
+
position: absolute;
|
|
253
|
+
}
|
|
254
|
+
:global(.relative) {
|
|
255
|
+
position: relative;
|
|
256
|
+
}
|
|
257
|
+
:global(.inset-0) {
|
|
258
|
+
top: 0;
|
|
259
|
+
right: 0;
|
|
260
|
+
bottom: 0;
|
|
261
|
+
left: 0;
|
|
262
|
+
}
|
|
263
|
+
:global(.inline-block) {
|
|
264
|
+
display: inline-block;
|
|
265
|
+
}
|
|
266
|
+
:global(.inline-flex) {
|
|
267
|
+
display: inline-flex;
|
|
268
|
+
}
|
|
269
|
+
:global(.flex) {
|
|
270
|
+
display: flex;
|
|
271
|
+
}
|
|
272
|
+
:global(.items-center) {
|
|
273
|
+
align-items: center;
|
|
274
|
+
}
|
|
275
|
+
:global(.items-start) {
|
|
276
|
+
align-items: flex-start;
|
|
277
|
+
}
|
|
278
|
+
:global(.justify-between) {
|
|
279
|
+
justify-content: space-between;
|
|
280
|
+
}
|
|
281
|
+
:global(.gap-2) {
|
|
282
|
+
gap: 0.5rem;
|
|
283
|
+
}
|
|
284
|
+
:global(.gap-4) {
|
|
285
|
+
gap: 1rem;
|
|
286
|
+
}
|
|
287
|
+
:global(.space-y-2 > * + *) {
|
|
288
|
+
margin-top: 0.5rem;
|
|
289
|
+
}
|
|
290
|
+
:global(.space-y-3 > * + *) {
|
|
291
|
+
margin-top: 0.75rem;
|
|
292
|
+
}
|
|
293
|
+
:global(.overflow-hidden) {
|
|
294
|
+
overflow: hidden;
|
|
295
|
+
}
|
|
296
|
+
:global(.rounded) {
|
|
297
|
+
border-radius: 0.25rem;
|
|
298
|
+
}
|
|
299
|
+
:global(.border) {
|
|
300
|
+
border-width: 1px;
|
|
301
|
+
}
|
|
302
|
+
:global(.border-base-300) {
|
|
303
|
+
border-color: var(--color-base-300, oklch(95% 0 0));
|
|
304
|
+
}
|
|
305
|
+
:global(.bg-base-100) {
|
|
306
|
+
background-color: var(--color-base-100, oklch(100% 0 0));
|
|
307
|
+
}
|
|
308
|
+
:global(.bg-base-content\/70) {
|
|
309
|
+
background-color: color-mix(in oklch, var(--color-base-content, oklch(21% 0 0)) 70%, transparent);
|
|
310
|
+
}
|
|
311
|
+
:global(.text-xs) {
|
|
312
|
+
font-size: 0.75rem;
|
|
313
|
+
line-height: 1rem;
|
|
314
|
+
}
|
|
315
|
+
:global(.text-sm) {
|
|
316
|
+
font-size: 0.875rem;
|
|
317
|
+
line-height: 1.25rem;
|
|
318
|
+
}
|
|
319
|
+
:global(.font-semibold) {
|
|
320
|
+
font-weight: 600;
|
|
321
|
+
}
|
|
322
|
+
:global(.text-base-content\/70) {
|
|
323
|
+
color: color-mix(in oklch, var(--color-base-content, oklch(21% 0 0)) 70%, transparent);
|
|
324
|
+
}
|
|
325
|
+
:global(.mb-2) {
|
|
326
|
+
margin-bottom: 0.5rem;
|
|
327
|
+
}
|
|
328
|
+
:global(.mb-3) {
|
|
329
|
+
margin-bottom: 0.75rem;
|
|
330
|
+
}
|
|
331
|
+
:global(.mr-2) {
|
|
332
|
+
margin-right: 0.5rem;
|
|
333
|
+
}
|
|
334
|
+
:global(.w-full) {
|
|
335
|
+
width: 100%;
|
|
336
|
+
}
|
|
337
|
+
:global(.w-auto) {
|
|
338
|
+
width: auto;
|
|
339
|
+
}
|
|
340
|
+
:global(.h-6) {
|
|
341
|
+
height: 1.5rem;
|
|
342
|
+
}
|
|
343
|
+
:global(.w-6) {
|
|
344
|
+
width: 1.5rem;
|
|
345
|
+
}
|
|
346
|
+
:global(.shrink-0) {
|
|
347
|
+
flex-shrink: 0;
|
|
348
|
+
}
|
|
349
|
+
:global(.stroke-current) {
|
|
350
|
+
stroke: currentColor;
|
|
351
|
+
}
|
|
352
|
+
:global(.sr-only) {
|
|
353
|
+
position: absolute;
|
|
354
|
+
width: 1px;
|
|
355
|
+
height: 1px;
|
|
356
|
+
padding: 0;
|
|
357
|
+
margin: -1px;
|
|
358
|
+
overflow: hidden;
|
|
359
|
+
clip: rect(0, 0, 0, 0);
|
|
360
|
+
white-space: nowrap;
|
|
361
|
+
border-width: 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/* Form inputs */
|
|
365
|
+
:global(.file-input) {
|
|
366
|
+
border-radius: 0.6rem;
|
|
367
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
368
|
+
background: var(--color-base-100, oklch(100% 0 0));
|
|
369
|
+
color: var(--color-base-content, oklch(21% 0 0));
|
|
370
|
+
padding: 0.35rem 0.6rem;
|
|
371
|
+
font: inherit;
|
|
372
|
+
}
|
|
373
|
+
:global(.file-input-bordered) {
|
|
374
|
+
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
375
|
+
}
|
|
376
|
+
:global(.label) {
|
|
377
|
+
display: flex;
|
|
378
|
+
user-select: none;
|
|
379
|
+
padding: 0.25rem 0;
|
|
380
|
+
}
|
|
381
|
+
:global(.label-text) {
|
|
382
|
+
font-size: 0.875rem;
|
|
383
|
+
line-height: 1.25rem;
|
|
384
|
+
}
|
|
385
|
+
:global(.form-control) {
|
|
386
|
+
display: flex;
|
|
387
|
+
flex-direction: column;
|
|
388
|
+
}
|
|
389
|
+
</style>
|
|
390
|
+
|
|
391
|
+
|