@pie-qti/item-player 0.1.8 → 0.1.10
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/README.md +17 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts +13 -2
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.d.ts +4 -2
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/components/utils/index.d.ts +1 -2
- package/dist/components/utils/index.d.ts.map +1 -1
- package/dist/components/utils/index.js +1 -2
- package/dist/core/ComponentRegistry.d.ts +10 -1
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +42 -1
- package/dist/core/Player.d.ts +10 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +54 -46
- package/dist/document/AssessmentItemDocument.d.ts +1 -1
- package/dist/element.d.ts +15 -0
- package/dist/element.js +1921 -1785
- package/dist/element.js.map +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +1 -1
- package/dist/extraction/createContext.d.ts +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +1 -1
- package/dist/extraction/interactionSecurity.d.ts +1 -1
- package/dist/extraction/types.d.ts +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +54 -0
- package/dist/presentation/itemPresentationPlan.d.ts.map +1 -0
- package/dist/presentation/itemPresentationPlan.js +98 -0
- package/dist/types/index.d.ts +17 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -3
- package/dist/web-components/QTIInteractionBase.d.ts +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +1 -1
- package/package.json +10 -12
- package/src/__tests__/catalog.test.ts +0 -267
- package/src/__tests__/fixtures/pci/echo-pci.js +0 -49
- package/src/__tests__/pci.test.ts +0 -353
- package/src/__tests__/qti3-attribute-extraction.test.ts +0 -174
- package/src/__tests__/qti3-debug.test.ts +0 -140
- package/src/__tests__/qti3-extraction.test.ts +0 -309
- package/src/catalog/applyGlossaryTriggers.ts +0 -372
- package/src/catalog/catalogExtractor.ts +0 -130
- package/src/catalog/catalogLookup.ts +0 -53
- package/src/catalog/glossaryAction.ts +0 -38
- package/src/catalog/types.ts +0 -37
- package/src/components/ItemBody.svelte +0 -363
- package/src/components/ItemPlayer.svelte +0 -163
- package/src/components/ModalFeedbackDisplay.svelte +0 -97
- package/src/components/actions/typesetAction.ts +0 -74
- package/src/components/index.ts +0 -22
- package/src/components/utils/assignProps.ts +0 -2
- package/src/components/utils/feedbackUtils.ts +0 -140
- package/src/components/utils/index.ts +0 -13
- package/src/components/utils/stimulusRender.ts +0 -93
- package/src/components/utils/stylesheetRender.ts +0 -58
- package/src/core/ComponentRegistry.ts +0 -248
- package/src/core/Player.ts +0 -1618
- package/src/core/Plugin.ts +0 -123
- package/src/core/PluginManager.ts +0 -182
- package/src/core/constants.ts +0 -117
- package/src/core/declarations.ts +0 -171
- package/src/core/parsingLimits.ts +0 -62
- package/src/core/random.ts +0 -24
- package/src/core/rolePolicy.ts +0 -34
- package/src/core/sanitizer.ts +0 -305
- package/src/core/trustedTypes.ts +0 -63
- package/src/core/urlPolicy.ts +0 -98
- package/src/document/AssessmentItemDocument.ts +0 -247
- package/src/element.ts +0 -128
- package/src/extensions/MathLiveEditor.ts +0 -313
- package/src/extraction/ExtractionRegistry.ts +0 -335
- package/src/extraction/createContext.ts +0 -52
- package/src/extraction/extractors/associateExtractor.ts +0 -1
- package/src/extraction/extractors/choiceExtractor.ts +0 -1
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +0 -239
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +0 -82
- package/src/extraction/extractors/conformance.test.ts +0 -208
- package/src/extraction/extractors/customExtractor.ts +0 -1
- package/src/extraction/extractors/drawingExtractor.ts +0 -1
- package/src/extraction/extractors/endAttemptExtractor.ts +0 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +0 -1
- package/src/extraction/extractors/gapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicAssociateExtractor.ts +0 -1
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicOrderExtractor.ts +0 -1
- package/src/extraction/extractors/hotspotExtractor.ts +0 -1
- package/src/extraction/extractors/hottextExtractor.ts +0 -1
- package/src/extraction/extractors/index.ts +0 -9
- package/src/extraction/extractors/inlineChoiceExtractor.ts +0 -1
- package/src/extraction/extractors/matchExtractor.ts +0 -1
- package/src/extraction/extractors/mediaExtractor.ts +0 -1
- package/src/extraction/extractors/orderExtractor.ts +0 -1
- package/src/extraction/extractors/portableCustomExtractor.ts +0 -1
- package/src/extraction/extractors/positionObjectExtractor.ts +0 -1
- package/src/extraction/extractors/selectPointExtractor.ts +0 -1
- package/src/extraction/extractors/sliderExtractor.ts +0 -1
- package/src/extraction/extractors/textEntryExtractor.ts +0 -1
- package/src/extraction/extractors/uploadExtractor.ts +0 -1
- package/src/extraction/index.ts +0 -108
- package/src/extraction/interactionExtractionPipeline.ts +0 -70
- package/src/extraction/interactionSecurity.ts +0 -60
- package/src/extraction/types.ts +0 -246
- package/src/extraction/utils.ts +0 -243
- package/src/iframe/IFramePlayerHost.ts +0 -265
- package/src/iframe/index.ts +0 -11
- package/src/iframe/protocol.ts +0 -137
- package/src/index.ts +0 -101
- package/src/interactions/associate/extractor.ts +0 -133
- package/src/interactions/associate/index.ts +0 -2
- package/src/interactions/associate/types.ts +0 -1
- package/src/interactions/choice/extractor.ts +0 -121
- package/src/interactions/choice/index.ts +0 -2
- package/src/interactions/choice/types.ts +0 -1
- package/src/interactions/custom/extractor.ts +0 -72
- package/src/interactions/custom/index.ts +0 -2
- package/src/interactions/custom/types.ts +0 -1
- package/src/interactions/drawing/extractor.ts +0 -113
- package/src/interactions/drawing/index.ts +0 -2
- package/src/interactions/drawing/types.ts +0 -1
- package/src/interactions/end-attempt/extractor.ts +0 -74
- package/src/interactions/end-attempt/index.ts +0 -2
- package/src/interactions/end-attempt/types.ts +0 -1
- package/src/interactions/extended-text/extractor.ts +0 -92
- package/src/interactions/extended-text/index.ts +0 -2
- package/src/interactions/extended-text/types.ts +0 -1
- package/src/interactions/gap-match/extractor.ts +0 -193
- package/src/interactions/gap-match/index.ts +0 -2
- package/src/interactions/gap-match/types.ts +0 -1
- package/src/interactions/graphic-associate/extractor.ts +0 -192
- package/src/interactions/graphic-associate/index.ts +0 -2
- package/src/interactions/graphic-associate/types.ts +0 -1
- package/src/interactions/graphic-gap-match/extractor.ts +0 -257
- package/src/interactions/graphic-gap-match/index.ts +0 -2
- package/src/interactions/graphic-gap-match/types.ts +0 -1
- package/src/interactions/graphic-order/extractor.ts +0 -162
- package/src/interactions/graphic-order/index.ts +0 -2
- package/src/interactions/graphic-order/types.ts +0 -1
- package/src/interactions/hotspot/extractor.ts +0 -208
- package/src/interactions/hotspot/index.ts +0 -2
- package/src/interactions/hotspot/types.ts +0 -1
- package/src/interactions/hottext/extractor.ts +0 -163
- package/src/interactions/hottext/index.ts +0 -2
- package/src/interactions/hottext/types.ts +0 -1
- package/src/interactions/index.ts +0 -52
- package/src/interactions/inline/index.ts +0 -1
- package/src/interactions/inline/render-plan.ts +0 -105
- package/src/interactions/inline-choice/InlineChoice.svelte +0 -57
- package/src/interactions/inline-choice/extractor.ts +0 -105
- package/src/interactions/inline-choice/index.ts +0 -2
- package/src/interactions/inline-choice/types.ts +0 -1
- package/src/interactions/match/extractor.ts +0 -187
- package/src/interactions/match/index.ts +0 -2
- package/src/interactions/match/types.ts +0 -1
- package/src/interactions/media/extractor.ts +0 -168
- package/src/interactions/media/index.ts +0 -2
- package/src/interactions/media/types.ts +0 -1
- package/src/interactions/modules.ts +0 -111
- package/src/interactions/order/extractor.ts +0 -120
- package/src/interactions/order/index.ts +0 -2
- package/src/interactions/order/types.ts +0 -1
- package/src/interactions/portable-custom/extractor.ts +0 -122
- package/src/interactions/portable-custom/index.ts +0 -2
- package/src/interactions/portable-custom/types.ts +0 -1
- package/src/interactions/position-object/extractor.ts +0 -243
- package/src/interactions/position-object/index.ts +0 -2
- package/src/interactions/position-object/types.ts +0 -1
- package/src/interactions/select-point/extractor.ts +0 -143
- package/src/interactions/select-point/index.ts +0 -2
- package/src/interactions/select-point/types.ts +0 -1
- package/src/interactions/shared/index.ts +0 -1
- package/src/interactions/shared/types.ts +0 -430
- package/src/interactions/slider/extractor.ts +0 -102
- package/src/interactions/slider/index.ts +0 -2
- package/src/interactions/slider/types.ts +0 -1
- package/src/interactions/text-entry/InlineTextEntry.svelte +0 -75
- package/src/interactions/text-entry/extractor.ts +0 -79
- package/src/interactions/text-entry/index.ts +0 -2
- package/src/interactions/text-entry/types.ts +0 -1
- package/src/interactions/upload/extractor.ts +0 -81
- package/src/interactions/upload/index.ts +0 -2
- package/src/interactions/upload/types.ts +0 -1
- package/src/pci/PciHost.ts +0 -138
- package/src/pci/types.ts +0 -70
- package/src/pnp/applyPnp.ts +0 -29
- package/src/pnp/parsePnpXml.ts +0 -215
- package/src/pnp/types.ts +0 -75
- package/src/server.ts +0 -14
- package/src/types/index.ts +0 -388
- package/src/types/interactions.ts +0 -8
- package/src/types/responseValidation.ts +0 -29
- package/src/types/xmldom.d.ts +0 -12
- package/src/utils/PerformanceMonitor.ts +0 -335
- package/src/utils/drawingUtils.ts +0 -73
- package/src/utils/responseUtils.ts +0 -51
- package/src/utils/touchDragHelper.ts +0 -1
- package/src/web-components/QTIInteractionBase.ts +0 -303
- package/src/web-components/QTIInteractionElement.ts +0 -125
- package/src/web-components/index.ts +0 -22
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import type { AttributeNameMapper, ElementNameMapper } from '@pie-qti/qti-common';
|
|
2
|
-
import {
|
|
3
|
-
findAssessmentItem,
|
|
4
|
-
findDescendants,
|
|
5
|
-
findFirstDescendant,
|
|
6
|
-
parseXml,
|
|
7
|
-
serializeXml,
|
|
8
|
-
} from '@pie-qti/qti-processing';
|
|
9
|
-
import { parse } from 'node-html-parser';
|
|
10
|
-
import { enforceItemXmlLimits } from '../core/parsingLimits.js';
|
|
11
|
-
import { normalizeInteractionTypeFromTagName } from '../interactions/modules.js';
|
|
12
|
-
import type { PlayerSecurityConfig } from '../types/index.js';
|
|
13
|
-
import type { QTIElement } from '../types/interactions.js';
|
|
14
|
-
|
|
15
|
-
export type ProcessingKind = 'template' | 'response' | 'outcome';
|
|
16
|
-
|
|
17
|
-
export interface DiscoveredInteractionElement {
|
|
18
|
-
element: QTIElement;
|
|
19
|
-
contextRoot: QTIElement;
|
|
20
|
-
responseIdentifier: string;
|
|
21
|
-
normalizedType: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface AssessmentItemDocumentInput {
|
|
25
|
-
itemXml: string;
|
|
26
|
-
elementNameMapper: ElementNameMapper;
|
|
27
|
-
attributeNameMapper: AttributeNameMapper;
|
|
28
|
-
security?: PlayerSecurityConfig;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class AssessmentItemDocument {
|
|
32
|
-
private readonly itemXml: string;
|
|
33
|
-
private readonly security?: PlayerSecurityConfig;
|
|
34
|
-
private readonly mathMlPrefixes: Set<string>;
|
|
35
|
-
readonly elementNameMapper: ElementNameMapper;
|
|
36
|
-
readonly attributeNameMapper: AttributeNameMapper;
|
|
37
|
-
private readonly xmlDocument: Document;
|
|
38
|
-
private readonly assessmentItem: Element;
|
|
39
|
-
private extractionDocument: QTIElement | null = null;
|
|
40
|
-
private extractionRoot: QTIElement | null = null;
|
|
41
|
-
|
|
42
|
-
constructor({
|
|
43
|
-
itemXml,
|
|
44
|
-
elementNameMapper,
|
|
45
|
-
attributeNameMapper,
|
|
46
|
-
security,
|
|
47
|
-
}: AssessmentItemDocumentInput) {
|
|
48
|
-
this.itemXml = itemXml;
|
|
49
|
-
this.security = security;
|
|
50
|
-
this.mathMlPrefixes = findMathMlPrefixes(itemXml);
|
|
51
|
-
this.elementNameMapper = elementNameMapper;
|
|
52
|
-
this.attributeNameMapper = attributeNameMapper;
|
|
53
|
-
|
|
54
|
-
enforceItemXmlLimits(this.itemXml, this.security);
|
|
55
|
-
this.xmlDocument = parseXml(this.itemXml);
|
|
56
|
-
this.assessmentItem = findAssessmentItem(this.xmlDocument);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getAssessmentItem(): Element {
|
|
60
|
-
return this.assessmentItem;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getProcessingElement(kind: ProcessingKind): Element | null {
|
|
64
|
-
const tagName =
|
|
65
|
-
kind === 'template'
|
|
66
|
-
? 'templateprocessing'
|
|
67
|
-
: kind === 'response'
|
|
68
|
-
? 'responseprocessing'
|
|
69
|
-
: 'outcomeprocessing';
|
|
70
|
-
return findFirstDescendant(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
serializeItemBodyChildren(): string {
|
|
74
|
-
const itemBody = this.getItemBodyElement();
|
|
75
|
-
if (!itemBody) return '';
|
|
76
|
-
return this.serializeChildren(itemBody);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
findRubricElements(): Element[] {
|
|
80
|
-
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('rubricblock'));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
findModalFeedbackElements(): Element[] {
|
|
84
|
-
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative('modalfeedback'));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
findDeclarationElements(kind: 'response' | 'outcome' | 'template'): Element[] {
|
|
88
|
-
const tagName =
|
|
89
|
-
kind === 'response'
|
|
90
|
-
? 'responsedeclaration'
|
|
91
|
-
: kind === 'outcome'
|
|
92
|
-
? 'outcomedeclaration'
|
|
93
|
-
: 'templatedeclaration';
|
|
94
|
-
return findDescendants(this.assessmentItem, this.elementNameMapper.toNative(tagName));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getAssessmentItemAttribute(name: string): string | null {
|
|
98
|
-
return this.assessmentItem.getAttribute(this.attributeNameMapper.toNative(name));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
serializeChildren(element: Element): string {
|
|
102
|
-
return normalizeMathMlPrefixes(
|
|
103
|
-
unwrapCdataSections(this.serializeChildNodes(element)),
|
|
104
|
-
this.mathMlPrefixes
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
findExtractionElements(elementTypes: Iterable<string>): DiscoveredInteractionElement[] {
|
|
109
|
-
const root = this.getExtractionRoot();
|
|
110
|
-
if (!root) return [];
|
|
111
|
-
|
|
112
|
-
const canonicalTypes = new Set(
|
|
113
|
-
[...elementTypes].map((elementType) => this.elementNameMapper.toCanonical(elementType))
|
|
114
|
-
);
|
|
115
|
-
const elements: DiscoveredInteractionElement[] = [];
|
|
116
|
-
|
|
117
|
-
this.walkExtractionChildren(root, (element) => {
|
|
118
|
-
const rawTagName = element.rawTagName;
|
|
119
|
-
if (!rawTagName) return;
|
|
120
|
-
if (!canonicalTypes.has(this.elementNameMapper.toCanonical(rawTagName))) return;
|
|
121
|
-
|
|
122
|
-
const responseIdentifier = this.getExtractionResponseIdentifier(element);
|
|
123
|
-
if (!responseIdentifier) return;
|
|
124
|
-
|
|
125
|
-
elements.push({
|
|
126
|
-
element,
|
|
127
|
-
contextRoot: root,
|
|
128
|
-
responseIdentifier,
|
|
129
|
-
normalizedType: normalizeInteractionTypeFromTagName(rawTagName),
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return elements;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
private getExtractionRoot(): QTIElement | null {
|
|
137
|
-
if (this.extractionRoot) return this.extractionRoot;
|
|
138
|
-
|
|
139
|
-
const docRoot = this.getExtractionDocument();
|
|
140
|
-
const itemBodyTag = this.elementNameMapper.toNative('itembody').toLowerCase();
|
|
141
|
-
this.extractionRoot = (docRoot.querySelector?.(itemBodyTag) as QTIElement | null) ?? null;
|
|
142
|
-
return this.extractionRoot;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private getExtractionDocument(): QTIElement {
|
|
146
|
-
if (!this.extractionDocument) {
|
|
147
|
-
enforceItemXmlLimits(this.itemXml, this.security);
|
|
148
|
-
this.extractionDocument = parse(this.serializeItemBodyForExtraction(), {
|
|
149
|
-
lowerCaseTagName: false,
|
|
150
|
-
comment: false,
|
|
151
|
-
}) as unknown as QTIElement;
|
|
152
|
-
}
|
|
153
|
-
return this.extractionDocument;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private getItemBodyElement(): Element | null {
|
|
157
|
-
return findFirstDescendant(
|
|
158
|
-
this.assessmentItem,
|
|
159
|
-
this.elementNameMapper.toNative('itembody')
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private serializeItemBodyForExtraction(): string {
|
|
164
|
-
const itemBodyTag = this.elementNameMapper.toNative('itembody');
|
|
165
|
-
const itemBody = this.getItemBodyElement();
|
|
166
|
-
const itemBodyChildren = itemBody ? this.serializeChildren(itemBody) : '';
|
|
167
|
-
|
|
168
|
-
return `<assessmentItem><${itemBodyTag}>${itemBodyChildren}</${itemBodyTag}></assessmentItem>`;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
private serializeChildNodes(element: Element): string {
|
|
172
|
-
const children = (element as any).childNodes as NodeListOf<Node> | undefined;
|
|
173
|
-
if (!children) return '';
|
|
174
|
-
|
|
175
|
-
const serialized: string[] = [];
|
|
176
|
-
for (let index = 0; index < children.length; index++) {
|
|
177
|
-
const child = children[index];
|
|
178
|
-
if (child) {
|
|
179
|
-
serialized.push(serializeXml(child));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return serialized.join('');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
private walkExtractionChildren(root: QTIElement, visit: (element: QTIElement) => void): void {
|
|
187
|
-
for (const child of root.childNodes ?? []) {
|
|
188
|
-
const element = child as QTIElement;
|
|
189
|
-
if (!element.rawTagName) continue;
|
|
190
|
-
visit(element);
|
|
191
|
-
this.walkExtractionChildren(element, visit);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private getExtractionResponseIdentifier(element: QTIElement): string {
|
|
196
|
-
const nativeName = this.attributeNameMapper.toNative('responseIdentifier');
|
|
197
|
-
return (
|
|
198
|
-
element.getAttribute?.('responseIdentifier') ||
|
|
199
|
-
element.getAttribute?.(nativeName) ||
|
|
200
|
-
element.getAttribute?.('response-identifier') ||
|
|
201
|
-
element.getAttribute?.('responseidentifier') ||
|
|
202
|
-
''
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function parseAssessmentItemDocument(input: AssessmentItemDocumentInput): AssessmentItemDocument {
|
|
208
|
-
return new AssessmentItemDocument(input);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function unwrapCdataSections(xml: string): string {
|
|
212
|
-
return xml.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, (_match, content: string) => content);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function findMathMlPrefixes(xml: string): Set<string> {
|
|
216
|
-
const prefixes = new Set<string>();
|
|
217
|
-
for (const match of xml.matchAll(
|
|
218
|
-
/\sxmlns:([A-Za-z_][\w.-]*)=(["'])http:\/\/www\.w3\.org\/1998\/Math\/MathML\2/g
|
|
219
|
-
)) {
|
|
220
|
-
const prefix = match[1];
|
|
221
|
-
if (prefix) {
|
|
222
|
-
prefixes.add(prefix);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return prefixes;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function normalizeMathMlPrefixes(xml: string, prefixes: Set<string>): string {
|
|
229
|
-
let normalized = xml;
|
|
230
|
-
for (const prefix of prefixes) {
|
|
231
|
-
const escapedPrefix = escapeRegExp(prefix);
|
|
232
|
-
normalized = normalized
|
|
233
|
-
.replace(new RegExp(`(<\\/?)${escapedPrefix}:([A-Za-z][\\w.-]*)(?=[\\s>/])`, 'g'), '$1$2')
|
|
234
|
-
.replace(
|
|
235
|
-
new RegExp(
|
|
236
|
-
`\\sxmlns:${escapedPrefix}=(["'])http:\\/\\/www\\.w3\\.org\\/1998\\/Math\\/MathML\\1`,
|
|
237
|
-
'g'
|
|
238
|
-
),
|
|
239
|
-
''
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
return normalized;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function escapeRegExp(value: string): string {
|
|
246
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
247
|
-
}
|
package/src/element.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pie-qti-item-player custom element.
|
|
3
|
-
*
|
|
4
|
-
* Side-effect import that registers <pie-qti-item-player>:
|
|
5
|
-
* import '@pie-qti/item-player/element';
|
|
6
|
-
*
|
|
7
|
-
* String/boolean props map to HTML attributes (item-xml, role, disabled).
|
|
8
|
-
* Complex props (typeset, i18n, security, onResponseChange, onSubmit, onComplete)
|
|
9
|
-
* are JS-only properties — set them on the element instance directly.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { mount, unmount } from 'svelte';
|
|
13
|
-
import ItemPlayer from './components/ItemPlayer.svelte';
|
|
14
|
-
import type { AdaptiveAttemptResult, PlayerSecurityConfig, QTIRole } from './types/index.js';
|
|
15
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
16
|
-
|
|
17
|
-
const TAG = 'pie-qti-item-player';
|
|
18
|
-
|
|
19
|
-
class PieQtiItemPlayerElement extends HTMLElement {
|
|
20
|
-
static observedAttributes = ['item-xml', 'role', 'disabled'];
|
|
21
|
-
|
|
22
|
-
#container: HTMLDivElement | null = null;
|
|
23
|
-
#instance: any = null;
|
|
24
|
-
|
|
25
|
-
// Attribute-backed props
|
|
26
|
-
#itemXml = '';
|
|
27
|
-
#role: QTIRole = 'candidate';
|
|
28
|
-
#disabled = false;
|
|
29
|
-
|
|
30
|
-
// JS-only props
|
|
31
|
-
#typeset: ((el: HTMLElement) => void) | undefined;
|
|
32
|
-
#i18n: I18nProvider | undefined;
|
|
33
|
-
#security: PlayerSecurityConfig | undefined;
|
|
34
|
-
#onResponseChange: ((id: string, value: unknown) => void) | undefined;
|
|
35
|
-
#onSubmit: ((responses: Record<string, unknown>, result: unknown) => void) | undefined;
|
|
36
|
-
#onComplete: ((result: AdaptiveAttemptResult) => void) | undefined;
|
|
37
|
-
|
|
38
|
-
// --- JS-only property accessors ---
|
|
39
|
-
|
|
40
|
-
get typeset() { return this.#typeset; }
|
|
41
|
-
set typeset(v: ((el: HTMLElement) => void) | undefined) { this.#typeset = v; this.#update(); }
|
|
42
|
-
|
|
43
|
-
get i18n() { return this.#i18n; }
|
|
44
|
-
set i18n(v: I18nProvider | undefined) { this.#i18n = v; this.#update(); }
|
|
45
|
-
|
|
46
|
-
get security() { return this.#security; }
|
|
47
|
-
set security(v: PlayerSecurityConfig | undefined) { this.#security = v; this.#update(); }
|
|
48
|
-
|
|
49
|
-
get onResponseChange() { return this.#onResponseChange; }
|
|
50
|
-
set onResponseChange(v: ((id: string, value: unknown) => void) | undefined) { this.#onResponseChange = v; this.#update(); }
|
|
51
|
-
|
|
52
|
-
get onSubmit() { return this.#onSubmit; }
|
|
53
|
-
set onSubmit(v: ((responses: Record<string, unknown>, result: unknown) => void) | undefined) { this.#onSubmit = v; this.#update(); }
|
|
54
|
-
|
|
55
|
-
get onComplete() { return this.#onComplete; }
|
|
56
|
-
set onComplete(v: ((result: AdaptiveAttemptResult) => void) | undefined) { this.#onComplete = v; this.#update(); }
|
|
57
|
-
|
|
58
|
-
// --- Lifecycle ---
|
|
59
|
-
|
|
60
|
-
connectedCallback() {
|
|
61
|
-
this.#mount();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
disconnectedCallback() {
|
|
65
|
-
this.#teardown();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
attributeChangedCallback(name: string, _old: string | null, value: string | null) {
|
|
69
|
-
if (name === 'item-xml') this.#itemXml = value ?? '';
|
|
70
|
-
else if (name === 'role') this.#role = (value ?? 'candidate') as QTIRole;
|
|
71
|
-
else if (name === 'disabled') this.#disabled = value !== null;
|
|
72
|
-
this.#update();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// --- Private helpers ---
|
|
76
|
-
|
|
77
|
-
#getProps() {
|
|
78
|
-
return {
|
|
79
|
-
itemXml: this.#itemXml,
|
|
80
|
-
role: this.#role,
|
|
81
|
-
disabled: this.#disabled,
|
|
82
|
-
typeset: this.#typeset,
|
|
83
|
-
i18n: this.#i18n,
|
|
84
|
-
security: this.#security,
|
|
85
|
-
onResponseChange: this.#onResponseChange,
|
|
86
|
-
onSubmit: this.#onSubmit,
|
|
87
|
-
onComplete: this.#onComplete,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
#mount() {
|
|
92
|
-
if (this.#instance) return;
|
|
93
|
-
if (!this.#container) {
|
|
94
|
-
this.#container = document.createElement('div');
|
|
95
|
-
this.#container.style.display = 'contents';
|
|
96
|
-
this.appendChild(this.#container);
|
|
97
|
-
}
|
|
98
|
-
this.#instance = mount(ItemPlayer, { target: this.#container, props: this.#getProps() });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
#update() {
|
|
102
|
-
if (!this.#instance) return;
|
|
103
|
-
if (typeof this.#instance.$set === 'function') {
|
|
104
|
-
this.#instance.$set(this.#getProps());
|
|
105
|
-
} else {
|
|
106
|
-
// Svelte 5 runes components: remount with new props
|
|
107
|
-
this.#teardown();
|
|
108
|
-
this.#mount();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
#teardown() {
|
|
113
|
-
if (this.#instance) {
|
|
114
|
-
try { unmount(this.#instance); } catch { /* ignore */ }
|
|
115
|
-
this.#instance = null;
|
|
116
|
-
}
|
|
117
|
-
if (this.#container) {
|
|
118
|
-
this.#container.remove();
|
|
119
|
-
this.#container = null;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!customElements.get(TAG)) {
|
|
125
|
-
customElements.define(TAG, PieQtiItemPlayerElement);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { PieQtiItemPlayerElement };
|
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MathLive Editor Extension for TipTap
|
|
3
|
-
*
|
|
4
|
-
* Integrates MathLive (visual math editor) with TipTap's Mathematics extension.
|
|
5
|
-
* Provides a modal dialog with MathLive mathfield for editing LaTeX formulas.
|
|
6
|
-
*
|
|
7
|
-
* Note: MathLive CSS is loaded dynamically to avoid build issues with package exports.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { MathfieldElement } from 'mathlive';
|
|
11
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
12
|
-
|
|
13
|
-
// Import MathLive CSS from the local package
|
|
14
|
-
import 'mathlive/mathlive-static.css';
|
|
15
|
-
|
|
16
|
-
const DEFAULT_MATHLIVE_CSS_URL = ''; // No longer needed - CSS is imported above
|
|
17
|
-
|
|
18
|
-
// Dynamically import MathLive to register the custom element
|
|
19
|
-
let mathLiveLoaded: Promise<void> | null = null;
|
|
20
|
-
|
|
21
|
-
async function ensureMathLiveLoaded(cssUrl: string = DEFAULT_MATHLIVE_CSS_URL): Promise<void> {
|
|
22
|
-
if (!mathLiveLoaded && typeof window !== 'undefined') {
|
|
23
|
-
mathLiveLoaded = (async () => {
|
|
24
|
-
// Import MathLive to register the <math-field> custom element
|
|
25
|
-
await import('mathlive');
|
|
26
|
-
|
|
27
|
-
// CSS is already imported at the top of this file, but allow custom URL if provided
|
|
28
|
-
if (cssUrl && !document.querySelector('link[href*="mathlive"]')) {
|
|
29
|
-
const link = document.createElement('link');
|
|
30
|
-
link.rel = 'stylesheet';
|
|
31
|
-
link.href = cssUrl;
|
|
32
|
-
document.head.appendChild(link);
|
|
33
|
-
}
|
|
34
|
-
})();
|
|
35
|
-
}
|
|
36
|
-
return mathLiveLoaded || Promise.resolve();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface MathLiveEditorOptions {
|
|
40
|
-
/** Called when user confirms the LaTeX input */
|
|
41
|
-
onConfirm: (latex: string) => void;
|
|
42
|
-
/** Called when user cancels */
|
|
43
|
-
onCancel: () => void;
|
|
44
|
-
/** Initial LaTeX value */
|
|
45
|
-
initialLatex?: string;
|
|
46
|
-
/** Whether this is inline or block math */
|
|
47
|
-
isBlock?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Optional MathLive stylesheet URL. Defaults to jsdelivr CDN.
|
|
50
|
-
* Useful for CSP-restricted deployments (serve from your own domain).
|
|
51
|
-
*/
|
|
52
|
-
cssUrl?: string;
|
|
53
|
-
/** Optional i18n provider for translations */
|
|
54
|
-
i18n?: I18nProvider;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Opens a modal dialog with MathLive editor for LaTeX input
|
|
59
|
-
*/
|
|
60
|
-
export async function openMathLiveEditor(options: MathLiveEditorOptions): Promise<() => void> {
|
|
61
|
-
const { onConfirm, onCancel, initialLatex = '', isBlock = false, cssUrl = DEFAULT_MATHLIVE_CSS_URL, i18n } = options;
|
|
62
|
-
|
|
63
|
-
// Ensure MathLive is loaded and registered before creating the mathfield
|
|
64
|
-
await ensureMathLiveLoaded(cssUrl);
|
|
65
|
-
|
|
66
|
-
// Create modal overlay - use DaisyUI modal classes
|
|
67
|
-
const overlay = document.createElement('div');
|
|
68
|
-
overlay.className = 'modal modal-open';
|
|
69
|
-
overlay.style.cssText = `
|
|
70
|
-
position: fixed;
|
|
71
|
-
top: 0;
|
|
72
|
-
left: 0;
|
|
73
|
-
right: 0;
|
|
74
|
-
bottom: 0;
|
|
75
|
-
background: rgba(0, 0, 0, 0.5);
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
z-index: 9999;
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
// Create modal dialog - use DaisyUI modal-box class
|
|
83
|
-
const modal = document.createElement('div');
|
|
84
|
-
modal.className = 'modal-box max-w-2xl';
|
|
85
|
-
modal.style.cssText = `
|
|
86
|
-
padding: 1.5rem;
|
|
87
|
-
position: relative;
|
|
88
|
-
z-index: 10000;
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
// Create header - use DaisyUI font-bold text-lg
|
|
92
|
-
const header = document.createElement('h3');
|
|
93
|
-
header.textContent = isBlock
|
|
94
|
-
? (i18n?.t('interactions.extendedText.insertBlockMath') ?? 'Insert Block Math')
|
|
95
|
-
: (i18n?.t('interactions.extendedText.insertInlineMath') ?? 'Insert Inline Math');
|
|
96
|
-
header.className = 'font-bold text-lg mb-4';
|
|
97
|
-
|
|
98
|
-
// Create form control wrapper
|
|
99
|
-
const formControl = document.createElement('div');
|
|
100
|
-
formControl.className = 'form-control';
|
|
101
|
-
|
|
102
|
-
// Create label for mathfield
|
|
103
|
-
const label = document.createElement('label');
|
|
104
|
-
label.className = 'label';
|
|
105
|
-
const labelText = document.createElement('span');
|
|
106
|
-
labelText.className = 'label-text';
|
|
107
|
-
labelText.textContent = 'Enter your math expression:';
|
|
108
|
-
label.appendChild(labelText);
|
|
109
|
-
|
|
110
|
-
// Create MathLive mathfield - style like DaisyUI input
|
|
111
|
-
const mathfield = document.createElement('math-field') as MathfieldElement;
|
|
112
|
-
mathfield.value = initialLatex;
|
|
113
|
-
mathfield.className = 'input input-bordered w-full';
|
|
114
|
-
mathfield.style.cssText = `
|
|
115
|
-
display: block;
|
|
116
|
-
min-height: 100px;
|
|
117
|
-
padding: 0.75rem;
|
|
118
|
-
font-size: 1.125rem;
|
|
119
|
-
`;
|
|
120
|
-
|
|
121
|
-
// Set MathLive options for better UX via attributes
|
|
122
|
-
// Use 'manual' mode so keyboard only shows when explicitly requested
|
|
123
|
-
mathfield.setAttribute('virtual-keyboard-mode', 'manual');
|
|
124
|
-
mathfield.setAttribute('smart-mode', 'on');
|
|
125
|
-
// Explicitly enable virtual keyboard
|
|
126
|
-
mathfield.setAttribute('use-shared-virtual-keyboard', 'true');
|
|
127
|
-
// Hide the built-in virtual keyboard toggle
|
|
128
|
-
mathfield.setAttribute('virtual-keyboard-toggle-glyph', '');
|
|
129
|
-
|
|
130
|
-
// Inject CSS to ensure virtual keyboard appears above modal and accepts clicks
|
|
131
|
-
const style = document.createElement('style');
|
|
132
|
-
style.textContent = `
|
|
133
|
-
/* Ensure MathLive virtual keyboard appears above the modal and is clickable */
|
|
134
|
-
.ML__keyboard {
|
|
135
|
-
z-index: 10001 !important;
|
|
136
|
-
pointer-events: auto !important;
|
|
137
|
-
}
|
|
138
|
-
/* Hide the built-in keyboard toggle button in the mathfield - try multiple selectors */
|
|
139
|
-
.ML__virtual-keyboard-toggle,
|
|
140
|
-
.ML__keyboard-toggle,
|
|
141
|
-
math-field::part(virtual-keyboard-toggle) {
|
|
142
|
-
display: none !important;
|
|
143
|
-
visibility: hidden !important;
|
|
144
|
-
opacity: 0 !important;
|
|
145
|
-
pointer-events: none !important;
|
|
146
|
-
}
|
|
147
|
-
`;
|
|
148
|
-
document.head.appendChild(style);
|
|
149
|
-
|
|
150
|
-
// Create LaTeX preview label
|
|
151
|
-
const previewLabel = document.createElement('label');
|
|
152
|
-
previewLabel.className = 'label';
|
|
153
|
-
const previewLabelText = document.createElement('span');
|
|
154
|
-
previewLabelText.className = 'label-text';
|
|
155
|
-
previewLabelText.textContent = 'LaTeX source:';
|
|
156
|
-
previewLabel.appendChild(previewLabelText);
|
|
157
|
-
|
|
158
|
-
// Create LaTeX preview/source - use alert info styling
|
|
159
|
-
const latexPreview = document.createElement('div');
|
|
160
|
-
latexPreview.className = 'alert alert-info';
|
|
161
|
-
latexPreview.style.cssText = `
|
|
162
|
-
font-family: 'Monaco', 'Courier New', monospace;
|
|
163
|
-
font-size: 0.875rem;
|
|
164
|
-
word-break: break-all;
|
|
165
|
-
margin-bottom: 1rem;
|
|
166
|
-
`;
|
|
167
|
-
latexPreview.textContent = initialLatex || '(LaTeX will appear here)';
|
|
168
|
-
|
|
169
|
-
// Update preview when mathfield changes
|
|
170
|
-
mathfield.addEventListener('input', () => {
|
|
171
|
-
const latex = mathfield.value;
|
|
172
|
-
latexPreview.textContent = latex || '(LaTeX will appear here)';
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Create button container - use DaisyUI modal-action class
|
|
176
|
-
const buttons = document.createElement('div');
|
|
177
|
-
buttons.className = 'modal-action';
|
|
178
|
-
buttons.style.cssText = 'justify-content: space-between;';
|
|
179
|
-
|
|
180
|
-
// Create left-side buttons (keyboard toggle)
|
|
181
|
-
const leftButtons = document.createElement('div');
|
|
182
|
-
leftButtons.style.cssText = 'display: flex; gap: 0.5rem;';
|
|
183
|
-
|
|
184
|
-
// Create Keyboard Toggle button
|
|
185
|
-
const keyboardBtn = document.createElement('button');
|
|
186
|
-
keyboardBtn.textContent = '⌨️ Keyboard';
|
|
187
|
-
keyboardBtn.type = 'button';
|
|
188
|
-
keyboardBtn.className = 'btn btn-sm btn-outline';
|
|
189
|
-
keyboardBtn.onclick = () => {
|
|
190
|
-
if (mathfield.executeCommand) {
|
|
191
|
-
mathfield.executeCommand('toggleVirtualKeyboard');
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
leftButtons.appendChild(keyboardBtn);
|
|
196
|
-
|
|
197
|
-
// Create right-side buttons (Cancel/Insert)
|
|
198
|
-
const rightButtons = document.createElement('div');
|
|
199
|
-
rightButtons.style.cssText = 'display: flex; gap: 0.5rem;';
|
|
200
|
-
|
|
201
|
-
// Create Cancel button - use DaisyUI classes
|
|
202
|
-
const cancelBtn = document.createElement('button');
|
|
203
|
-
cancelBtn.textContent = 'Cancel';
|
|
204
|
-
cancelBtn.type = 'button';
|
|
205
|
-
cancelBtn.className = 'btn btn-ghost';
|
|
206
|
-
|
|
207
|
-
// Create Insert button - use DaisyUI classes
|
|
208
|
-
const insertBtn = document.createElement('button');
|
|
209
|
-
insertBtn.textContent = initialLatex ? 'Update' : 'Insert';
|
|
210
|
-
insertBtn.type = 'button';
|
|
211
|
-
insertBtn.className = 'btn btn-primary';
|
|
212
|
-
|
|
213
|
-
rightButtons.appendChild(cancelBtn);
|
|
214
|
-
rightButtons.appendChild(insertBtn);
|
|
215
|
-
|
|
216
|
-
// Assemble modal
|
|
217
|
-
buttons.appendChild(leftButtons);
|
|
218
|
-
buttons.appendChild(rightButtons);
|
|
219
|
-
|
|
220
|
-
// Assemble form-control
|
|
221
|
-
formControl.appendChild(label);
|
|
222
|
-
formControl.appendChild(mathfield);
|
|
223
|
-
formControl.appendChild(previewLabel);
|
|
224
|
-
formControl.appendChild(latexPreview);
|
|
225
|
-
|
|
226
|
-
modal.appendChild(header);
|
|
227
|
-
modal.appendChild(formControl);
|
|
228
|
-
modal.appendChild(buttons);
|
|
229
|
-
|
|
230
|
-
overlay.appendChild(modal);
|
|
231
|
-
|
|
232
|
-
// Cleanup function
|
|
233
|
-
const cleanup = () => {
|
|
234
|
-
// Remove event listeners to prevent memory leaks
|
|
235
|
-
cancelBtn.removeEventListener('click', handleCancel);
|
|
236
|
-
insertBtn.removeEventListener('click', handleConfirm);
|
|
237
|
-
document.removeEventListener('keydown', handleEscape);
|
|
238
|
-
overlay.removeEventListener('click', handleOverlayClick);
|
|
239
|
-
|
|
240
|
-
// Hide virtual keyboard before cleanup
|
|
241
|
-
if (mathfield.executeCommand) {
|
|
242
|
-
mathfield.executeCommand('hideVirtualKeyboard');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Remove DOM elements
|
|
246
|
-
overlay.remove();
|
|
247
|
-
style.remove();
|
|
248
|
-
|
|
249
|
-
// Restore body scroll
|
|
250
|
-
document.body.style.overflow = '';
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
// Event handlers
|
|
254
|
-
const handleCancel = () => {
|
|
255
|
-
cleanup();
|
|
256
|
-
onCancel();
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const handleConfirm = () => {
|
|
260
|
-
const latex = mathfield.value;
|
|
261
|
-
cleanup();
|
|
262
|
-
onConfirm(latex);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const handleEscape = (e: KeyboardEvent) => {
|
|
266
|
-
if (e.key === 'Escape') {
|
|
267
|
-
handleCancel();
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
const handleOverlayClick = (e: MouseEvent) => {
|
|
272
|
-
// Don't close if clicking on the modal content or virtual keyboard
|
|
273
|
-
const target = e.target as HTMLElement;
|
|
274
|
-
|
|
275
|
-
// Check if click is on overlay background (not modal or keyboard)
|
|
276
|
-
if (target === overlay) {
|
|
277
|
-
// Additional check: don't close if virtual keyboard is open
|
|
278
|
-
// MathLive virtual keyboard has class 'ML__keyboard'
|
|
279
|
-
const virtualKeyboard = document.querySelector('.ML__keyboard');
|
|
280
|
-
if (!virtualKeyboard) {
|
|
281
|
-
handleCancel();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
// Attach event listeners
|
|
287
|
-
cancelBtn.addEventListener('click', handleCancel);
|
|
288
|
-
insertBtn.addEventListener('click', handleConfirm);
|
|
289
|
-
document.addEventListener('keydown', handleEscape);
|
|
290
|
-
overlay.addEventListener('click', handleOverlayClick);
|
|
291
|
-
|
|
292
|
-
// Prevent body scroll when modal is open
|
|
293
|
-
document.body.style.overflow = 'hidden';
|
|
294
|
-
|
|
295
|
-
// Add to DOM
|
|
296
|
-
document.body.appendChild(overlay);
|
|
297
|
-
|
|
298
|
-
// Focus the mathfield (but don't auto-show keyboard)
|
|
299
|
-
setTimeout(() => {
|
|
300
|
-
mathfield.focus();
|
|
301
|
-
// Try to programmatically disable the built-in toggle via options
|
|
302
|
-
try {
|
|
303
|
-
(mathfield as any).setOptions({
|
|
304
|
-
virtualKeyboardToggleGlyph: '',
|
|
305
|
-
});
|
|
306
|
-
} catch (e) {
|
|
307
|
-
// Silently ignore if this API doesn't exist
|
|
308
|
-
}
|
|
309
|
-
}, 100);
|
|
310
|
-
|
|
311
|
-
// Return cleanup function
|
|
312
|
-
return cleanup;
|
|
313
|
-
}
|