@digabi/exam-engine-core 23.13.4 → 23.13.6

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 (43) hide show
  1. package/dist/__tests__/annotations.test.d.ts +2 -0
  2. package/dist/__tests__/annotations.test.d.ts.map +1 -0
  3. package/dist/__tests__/annotations.test.js +217 -0
  4. package/dist/__tests__/annotations.test.js.map +1 -0
  5. package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
  6. package/dist/assets/NotoMono.ttf +0 -0
  7. package/dist/assets/NotoSans-Bold.ttf +0 -0
  8. package/dist/assets/NotoSans-BoldItalic.ttf +0 -0
  9. package/dist/assets/NotoSans-Italic.ttf +0 -0
  10. package/dist/assets/NotoSans-Light.ttf +0 -0
  11. package/dist/assets/NotoSans-LightItalic.ttf +0 -0
  12. package/dist/assets/NotoSans-Regular.ttf +0 -0
  13. package/dist/assets/NotoSans-SemiBold.ttf +0 -0
  14. package/dist/assets/NotoSans-SemiBoldItalic.ttf +0 -0
  15. package/dist/assets/closeButton.svg +1 -0
  16. package/dist/assets/collapse.svg +12 -0
  17. package/dist/assets/expand.svg +12 -0
  18. package/dist/assets/helpButton.svg +9 -0
  19. package/dist/assets/redoButton.svg +5 -0
  20. package/dist/assets/undoButton.svg +5 -0
  21. package/dist/components/exam/ExamineExam.d.ts +5 -0
  22. package/dist/components/exam/ExamineExam.d.ts.map +1 -0
  23. package/dist/components/exam/ExamineExam.js +20 -0
  24. package/dist/components/exam/ExamineExam.js.map +1 -0
  25. package/dist/components/grading/examAnnotationUtils.d.ts +4 -0
  26. package/dist/components/grading/examAnnotationUtils.d.ts.map +1 -0
  27. package/dist/components/grading/examAnnotationUtils.js +51 -0
  28. package/dist/components/grading/examAnnotationUtils.js.map +1 -0
  29. package/dist/components/shared/AnnotatableText.d.ts +7 -0
  30. package/dist/components/shared/AnnotatableText.d.ts.map +1 -0
  31. package/dist/components/shared/AnnotatableText.js +73 -0
  32. package/dist/components/shared/AnnotatableText.js.map +1 -0
  33. package/dist/components/shared/AnnotationPopup.d.ts +3 -0
  34. package/dist/components/shared/AnnotationPopup.d.ts.map +1 -0
  35. package/dist/components/shared/AnnotationPopup.js +74 -0
  36. package/dist/components/shared/AnnotationPopup.js.map +1 -0
  37. package/dist/components/surround.d.ts +8 -0
  38. package/dist/components/surround.d.ts.map +1 -0
  39. package/dist/components/surround.js +19 -0
  40. package/dist/components/surround.js.map +1 -0
  41. package/dist/main-bundle.js +366 -5081
  42. package/dist/store/cas/sagas.d.ts +3 -3
  43. package/package.json +2 -2
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30" viewBox="0 0 30 30"><defs><clipPath id="clip-path"><path d="M141.57-89.324v-2.34H143.2v2.34A2.3,2.3,0,0,1,140.9-87.03H130.1a2.3,2.3,0,0,1-2.292-2.294v-17.029a2.294,2.294,0,0,1,2.292-2.292h10.8a2.3,2.3,0,0,1,2.295,2.292v2.342H141.57v-2.342a.669.669,0,0,0-.67-.667H130.1a.667.667,0,0,0-.667.667v17.029a.668.668,0,0,0,.667.669h10.8A.67.67,0,0,0,141.57-89.324Zm3.271-13.579a1.069,1.069,0,0,1,1.825-.755l5.065,5.065a1.065,1.065,0,0,1,0,1.511l-5.065,5.067a1.07,1.07,0,0,1-1.825-.757v-2.412h-6.633a2.3,2.3,0,0,1-2.3-2.3v-.7a2.3,2.3,0,0,1,2.3-2.3h6.633V-102.9" fill="none" clip-rule="evenodd"/></clipPath><clipPath id="clip-path-2"><ellipse cx="10" cy="-29.606" rx="15" ry="14.933" fill="none"/></clipPath></defs><title>closeButton</title><rect width="30" height="30" fill="#fff" opacity="0"/><line x1="25" y1="5" x2="5" y2="25" fill="none" stroke="#6d6d6d" stroke-miterlimit="10" stroke-width="3"/><line x1="5" y1="5" x2="25" y2="25" fill="none" stroke="#6d6d6d" stroke-miterlimit="10" stroke-width="3"/></svg>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="19px" height="12px" viewBox="0 0 19 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
4
+ <title>Page 1</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Kuuntelu-kokelas-painaa-nappia-Copy-18" transform="translate(-1068.000000, -19.000000)" stroke-width="3" stroke="#359BB7">
9
+ <polyline id="Page-1" transform="translate(1077.999981, 26.000000) rotate(180.000000) translate(-1077.999981, -26.000000) " points="1085.99996 22 1077.99996 30 1070 22"></polyline>
10
+ </g>
11
+ </g>
12
+ </svg>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="18px" height="12px" viewBox="0 0 18 12" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
4
+ <title>Page 1</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Kuuntelu-kokelas-painaa-nappia-Copy-18" transform="translate(-1069.000000, -21.000000)" stroke-width="3" stroke="#359BB7">
9
+ <polyline id="Page-1" points="1085.99996 22 1077.99996 30 1070 22"></polyline>
10
+ </g>
11
+ </g>
12
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg version="1.1"
2
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
3
+ x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
4
+ <path fill="#359BB7" d="M10,20C4.48,20,0,15.52,0,10C0,4.48,4.48,0,10,0s10,4.48,10,10C20,15.52,15.52,20,10,20z M5.57,5.88
5
+ c-0.14,0.21-0.09,0.5,0.11,0.66l1.4,1.06c0.21,0.16,0.51,0.12,0.67-0.09c0.72-0.91,1.21-1.44,2.31-1.44c0.82,0,1.84,0.53,1.84,1.33
6
+ c0,0.6-0.5,0.91-1.31,1.37c-0.95,0.53-2.2,1.19-2.2,2.85v0.16c0,0.27,0.22,0.48,0.48,0.48h2.26c0.27,0,0.48-0.22,0.48-0.48v-0.05
7
+ c0-1.15,3.35-1.2,3.35-4.3c0-2.34-2.43-4.11-4.7-4.11C8.07,3.31,6.67,4.23,5.57,5.88z M8.15,15.16c0,1.02,0.83,1.85,1.85,1.85
8
+ s1.85-0.83,1.85-1.85s-0.83-1.85-1.85-1.85S8.15,14.14,8.15,15.16z"/>
9
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20px" height="20px" viewBox="0 0 20 20" version="1.1">
2
+ <g id="surface1">
3
+ <path fill="#359BB7" d="M 18.316406 1.253906 C 18.859375 1.253906 19.378906 1.675781 19.378906 2.3125 L 19.378906 8.007812 C 19.378906 8.421875 19.042969 8.757812 18.628906 8.757812 L 12.9375 8.757812 C 12.300781 8.757812 11.882812 8.238281 11.882812 7.695312 C 11.882812 7.4375 11.976562 7.171875 12.191406 6.957031 L 13.953125 5.195312 C 12.851562 4.289062 11.460938 3.761719 9.996094 3.761719 C 6.554688 3.761719 3.753906 6.5625 3.753906 10.003906 C 3.753906 13.449219 6.554688 16.246094 9.996094 16.246094 C 12.851562 16.246094 13.488281 14.75 14.492188 14.75 C 15.214844 14.75 15.742188 15.335938 15.742188 15.996094 C 15.742188 17.367188 12.554688 18.75 10 18.75 C 5.179688 18.75 1.253906 14.824219 1.253906 10.003906 C 1.253906 5.183594 5.179688 1.265625 10 1.265625 C 12.132812 1.265625 14.148438 2.0625 15.71875 3.425781 L 17.578125 1.566406 C 17.792969 1.351562 18.058594 1.253906 18.316406 1.253906 Z M 18.316406 1.253906 "/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20px" height="20px" viewBox="0 0 20 20" version="1.1">
2
+ <g id="surface1">
3
+ <path fill="#359BB7" d="M 18.75 10 C 18.75 14.820312 14.824219 18.746094 10.003906 18.746094 C 8.097656 18.746094 6.285156 18.136719 4.761719 16.992188 C 4.210938 16.578125 4.097656 15.796875 4.511719 15.242188 C 4.925781 14.691406 5.707031 14.582031 6.261719 14.996094 C 7.351562 15.8125 8.644531 16.242188 10.007812 16.242188 C 13.449219 16.242188 16.25 13.441406 16.25 10 C 16.25 6.558594 13.449219 3.757812 10.007812 3.757812 C 8.542969 3.757812 7.152344 4.285156 6.050781 5.1875 L 7.8125 6.953125 C 8.476562 7.617188 8.007812 8.753906 7.066406 8.753906 L 1.375 8.753906 C 0.960938 8.753906 0.625 8.417969 0.625 8.003906 L 0.625 2.304688 C 0.625 1.367188 1.761719 0.898438 2.425781 1.5625 L 4.285156 3.421875 C 5.855469 2.058594 7.871094 1.253906 10.003906 1.253906 C 14.824219 1.253906 18.75 5.179688 18.75 10 Z M 18.75 10 "/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare function ExamineExam(): React.JSX.Element;
3
+ declare const _default: React.MemoExoticComponent<typeof ExamineExam>;
4
+ export default _default;
5
+ //# sourceMappingURL=ExamineExam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExamineExam.d.ts","sourceRoot":"","sources":["../../../src/components/exam/ExamineExam.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAKzC,iBAAS,WAAW,sBA4BnB;;AAED,wBAAsC"}
@@ -0,0 +1,20 @@
1
+ import React, { useContext } from 'react';
2
+ import { useExamTranslation } from '../../i18n';
3
+ import { ExamContext } from '../context/ExamContext';
4
+ function ExamineExam() {
5
+ const { examServerApi } = useContext(ExamContext);
6
+ const { examineExam } = examServerApi;
7
+ const { t } = useExamTranslation();
8
+ const goToInspectAnswers = () => {
9
+ if (!examineExam) {
10
+ return;
11
+ }
12
+ examineExam();
13
+ window.scrollTo(0, 0);
14
+ };
15
+ return (React.createElement("div", { className: "e-examine-exam" },
16
+ React.createElement("button", { className: "e-button", id: "examineExam", onClick: goToInspectAnswers, "aria-describedby": "examineExamInstructions" }, t('examine-exam.examine')),
17
+ React.createElement("div", { className: "e-examine-exam-instructions", id: "examineExamInstructions" }, t('examine-exam.instructions'))));
18
+ }
19
+ export default React.memo(ExamineExam);
20
+ //# sourceMappingURL=ExamineExam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExamineExam.js","sourceRoot":"","sources":["../../../src/components/exam/ExamineExam.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,SAAS,WAAW;IAClB,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACjD,MAAM,EAAE,WAAW,EAAE,GAAkB,aAAa,CAAA;IACpD,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAElC,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QACD,WAAW,EAAE,CAAA;QACb,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACvB,CAAC,CAAA;IAED,OAAO,CACL,6BAAK,SAAS,EAAC,gBAAgB;QAC7B,gCACE,SAAS,EAAC,UAAU,EACpB,EAAE,EAAC,aAAa,EAChB,OAAO,EAAE,kBAAkB,sBACV,yBAAyB,IAEzC,CAAC,CAAC,sBAAsB,CAAC,CACnB;QACT,6BAAK,SAAS,EAAC,6BAA6B,EAAC,EAAE,EAAC,yBAAyB,IACtE,CAAC,CAAC,2BAA2B,CAAC,CAC3B,CACF,CACP,CAAA;AACH,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare function onMouseDownForAnnotation(e: React.MouseEvent, mouseUpCallback: (e: any) => void): void;
3
+ export declare function hasTextSelectedInAnswerText(): boolean;
4
+ //# sourceMappingURL=examAnnotationUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examAnnotationUtils.d.ts","sourceRoot":"","sources":["../../../src/components/grading/examAnnotationUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,QAuB9F;AAED,wBAAgB,2BAA2B,IAAI,OAAO,CAoCrD"}
@@ -0,0 +1,51 @@
1
+ import { textAnnotationFromRange } from './editAnnotations';
2
+ export function onMouseDownForAnnotation(e, mouseUpCallback) {
3
+ function onMouseUpAfterAnswerMouseDown(e) {
4
+ const target = e.target;
5
+ window.removeEventListener('mouseup', onMouseUpAfterAnswerMouseDown);
6
+ // Text annotation
7
+ const selection = window.getSelection();
8
+ if (selection && hasTextSelectedInAnswerText()) {
9
+ const range = selection.getRangeAt(0);
10
+ const position = textAnnotationFromRange(target, range);
11
+ if (!position) {
12
+ return;
13
+ }
14
+ const selectedText = selection.toString();
15
+ mouseUpCallback({ ...position, selectedText });
16
+ }
17
+ }
18
+ // Do annotations only with left mouse buttons
19
+ if (e.button !== 0) {
20
+ return;
21
+ }
22
+ window.addEventListener('mouseup', onMouseUpAfterAnswerMouseDown);
23
+ }
24
+ export function hasTextSelectedInAnswerText() {
25
+ const selection = window.getSelection();
26
+ return (selection !== null &&
27
+ selectionInAnswerText(selection) &&
28
+ (isRangeSelection(selection) || textSelectedInRange(selection)));
29
+ function selectionInAnswerText(sel) {
30
+ if (sel.type === 'None' || sel.type === 'Caret' || sel.rangeCount === 0) {
31
+ return false;
32
+ }
33
+ const startContainer = sel.getRangeAt(0).startContainer;
34
+ const endContainer = sel.getRangeAt(0).endContainer;
35
+ const startParent = startContainer.parentElement;
36
+ const endParent = endContainer.parentElement;
37
+ const visibleMarkTagExistsInSelection = Array.from(sel.getRangeAt(0).cloneContents().children).some(child => child.tagName === 'MARK' && child.getAttribute('data-hidden') === 'false');
38
+ return (sel.rangeCount > 0 &&
39
+ startParent === endParent &&
40
+ (startParent === null || startParent === void 0 ? void 0 : startParent.tagName) !== 'MARK' &&
41
+ !visibleMarkTagExistsInSelection);
42
+ }
43
+ function isRangeSelection(sel) {
44
+ return (sel === null || sel === void 0 ? void 0 : sel.type) === 'Range';
45
+ }
46
+ function textSelectedInRange(sel) {
47
+ const range = sel === null || sel === void 0 ? void 0 : sel.getRangeAt(0);
48
+ return !!sel.rangeCount && range.toString().length > 0;
49
+ }
50
+ }
51
+ //# sourceMappingURL=examAnnotationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examAnnotationUtils.js","sourceRoot":"","sources":["../../../src/components/grading/examAnnotationUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,UAAU,wBAAwB,CAAC,CAAmB,EAAE,eAAiC;IAC7F,SAAS,6BAA6B,CAAC,CAAa;QAClD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAqB,CAAA;QACtC,MAAM,CAAC,mBAAmB,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AC,CAAC,YAAY,CAAA;QACnD,MAAM,WAAW,GAAG,cAAc,CAAC,aAAa,CAAA;QAChD,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAA;QAC5C,MAAM,+BAA+B,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CACjG,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,OAAO,CACnF,CAAA;QACD,OAAO,CACL,GAAG,CAAC,UAAU,GAAG,CAAC;YAClB,WAAW,KAAK,SAAS;YACzB,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,MAAK,MAAM;YAC/B,CAAC,+BAA+B,CACjC,CAAA;IACH,CAAC;IAED,SAAS,gBAAgB,CAAC,GAAc;QACtC,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,MAAK,OAAO,CAAA;IAC9B,CAAC;IAED,SAAS,mBAAmB,CAAC,GAAc;QACzC,MAAM,KAAK,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAC,CAAC,CAAC,CAAA;QAChC,OAAO,CAAC,CAAC,GAAG,CAAC,UAAU,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,CAAC,CAAA;IACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { AnnotationContextType } from '../context/AnnotationProvider';
3
+ export declare const AnnotatableText: ({ node, annotationContextData }: {
4
+ node: Node;
5
+ annotationContextData: AnnotationContextType;
6
+ }) => React.JSX.Element;
7
+ //# sourceMappingURL=AnnotatableText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotatableText.d.ts","sourceRoot":"","sources":["../../../src/components/shared/AnnotatableText.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAGhD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAMrE,eAAO,MAAM,eAAe,oCAGzB;IACD,IAAI,EAAE,IAAI,CAAA;IACV,qBAAqB,EAAE,qBAAqB,CAAA;CAC7C,sBAqGA,CAAA"}
@@ -0,0 +1,73 @@
1
+ import { partition } from 'lodash-es';
2
+ import React, { useEffect, useRef } from 'react';
3
+ import { getElementPath, queryAncestors } from '../../dom-utils';
4
+ import { onMouseDownForAnnotation } from '../grading/examAnnotationUtils';
5
+ const isExamAnnotation = (annotation) => 'annotationId' in annotation;
6
+ export const AnnotatableText = ({ node, annotationContextData }) => {
7
+ const { annotations, onClickAnnotation, setNewAnnotation, setNewAnnotationRef, newAnnotation } = annotationContextData;
8
+ const path = getElementPath(node);
9
+ const newAnnotationForThisNode = (newAnnotation === null || newAnnotation === void 0 ? void 0 : newAnnotation.annotationAnchor) === path ? newAnnotation : null;
10
+ const thisNodeAnnotations = [
11
+ ...((annotations === null || annotations === void 0 ? void 0 : annotations[path]) || []),
12
+ ...(newAnnotationForThisNode ? [newAnnotationForThisNode] : [])
13
+ ];
14
+ const mouseUpCallback = (annotation) => {
15
+ var _a;
16
+ const displayNumber = ((_a = queryAncestors(node.parentElement, 'question')) === null || _a === void 0 ? void 0 : _a.getAttribute('display-number')) || '';
17
+ setNewAnnotation({ ...annotation, annotationAnchor: path, displayNumber });
18
+ };
19
+ function onMouseDown(e) {
20
+ const target = e.target;
21
+ const clickIsInPopup = target.closest('.annotation-popup');
22
+ if (!clickIsInPopup) {
23
+ setNewAnnotation(null);
24
+ }
25
+ onMouseDownForAnnotation(e, mouseUpCallback);
26
+ }
27
+ return (React.createElement("span", { onMouseDown: onMouseDown, className: "e-annotatable", key: path }, (thisNodeAnnotations === null || thisNodeAnnotations === void 0 ? void 0 : thisNodeAnnotations.length) > 0 ? markText(node.textContent, thisNodeAnnotations) : node.textContent));
28
+ function markText(text, annotations) {
29
+ if (annotations.length === 0) {
30
+ return [text];
31
+ }
32
+ function getMarkedText(annotation) {
33
+ return text.substring(annotation.startIndex, annotation.startIndex + annotation.length);
34
+ }
35
+ const nodes = [];
36
+ let lastIndex = 0;
37
+ annotations.sort((a, b) => a.startIndex - b.startIndex);
38
+ const [validAnnotations, invalidAnnotations] = partition(annotations, annotation => annotation.startIndex >= 0 && annotation.length > 0 && annotation.selectedText === getMarkedText(annotation));
39
+ if (invalidAnnotations.length > 0) {
40
+ console.error('Invalid annotations:', invalidAnnotations, invalidAnnotations.map(a => `selectedText (${a.selectedText}) does not match text picked by startIndex and length (${getMarkedText(a)})`));
41
+ }
42
+ for (const annotation of validAnnotations) {
43
+ const markedText = getMarkedText(annotation);
44
+ // Add unmarked text before this mark
45
+ if (annotation.startIndex > lastIndex) {
46
+ nodes.push(text.substring(lastIndex, annotation.startIndex));
47
+ }
48
+ // Add marked text
49
+ const key = isExamAnnotation(annotation) ? annotation.annotationId : annotation.startIndex;
50
+ nodes.push(annotation.hidden ? (React.createElement("mark", { key: key, className: "e-annotation", "data-annotation-id": isExamAnnotation(annotation) ? annotation.annotationId : '', "data-hidden": "true" })) : (React.createElement(Mark, { key: key, annotation: annotation, markedText: markedText, onClickAnnotation: onClickAnnotation, setNewAnnotationRef: setNewAnnotationRef })));
51
+ // if annotation is hidden and it starts inside another annotation, we must not increment lastIndex (actually it would be decremented)
52
+ const hiddenAnnotationInsideCurrentAnnotation = annotation.startIndex < lastIndex && annotation.hidden;
53
+ if (!hiddenAnnotationInsideCurrentAnnotation) {
54
+ lastIndex = annotation.startIndex + (annotation.hidden ? 0 : annotation.length);
55
+ }
56
+ }
57
+ // Add remaining unmarked text
58
+ nodes.push(text.substring(lastIndex));
59
+ return nodes;
60
+ }
61
+ };
62
+ const Mark = ({ annotation, markedText, onClickAnnotation, setNewAnnotationRef }) => {
63
+ const markRef = useRef(null);
64
+ useEffect(() => {
65
+ if (markRef.current && !isExamAnnotation(annotation)) {
66
+ setNewAnnotationRef(markRef.current);
67
+ }
68
+ }, []);
69
+ return (React.createElement("mark", { ref: markRef, className: "e-annotation", "data-annotation-id": isExamAnnotation(annotation) ? annotation.annotationId : '', "data-hidden": "false", onClick: e => (isExamAnnotation(annotation) ? onClickAnnotation(e, annotation) : undefined) },
70
+ markedText,
71
+ (annotation === null || annotation === void 0 ? void 0 : annotation.markNumber) && React.createElement("sup", { className: "e-annotation", "data-content": annotation === null || annotation === void 0 ? void 0 : annotation.markNumber })));
72
+ };
73
+ //# sourceMappingURL=AnnotatableText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotatableText.js","sourceRoot":"","sources":["../../../src/components/shared/AnnotatableText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAEzE,MAAM,gBAAgB,GAAG,CAAC,UAA8C,EAAgC,EAAE,CACxG,cAAc,IAAI,UAAU,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,IAAI,EACJ,qBAAqB,EAItB,EAAE,EAAE;IACH,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,qBAAqB,CAAA;IAEtH,MAAM,IAAI,GAAG,cAAc,CAAC,IAAe,CAAC,CAAA;IAC5C,MAAM,wBAAwB,GAAG,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,gBAAgB,MAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAA;IAChG,MAAM,mBAAmB,GAAG;QAC1B,GAAG,CAAC,CAAA,WAAW,a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CAAC,CAAA;IACN,OAAO,CACL,8BACE,GAAG,EAAE,OAAO,EACZ,SAAS,EAAC,cAAc,wBACJ,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,iBACnE,OAAO,EACnB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,UAAU;QACV,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,KAAI,6BAAK,SAAS,EAAC,cAAc,kBAAe,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,UAAU,GAAI,CAC5F,CACR,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare function AnnotationPopup(): React.JSX.Element | null;
3
+ //# sourceMappingURL=AnnotationPopup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationPopup.d.ts","sourceRoot":"","sources":["../../../src/components/shared/AnnotationPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0C,MAAM,OAAO,CAAA;AAK9D,wBAAgB,eAAe,6BA8E9B"}
@@ -0,0 +1,74 @@
1
+ import React, { useContext, useEffect, useState } from 'react';
2
+ import { makeRichText } from 'rich-text-editor';
3
+ import { AnnotationContext } from '../context/AnnotationProvider';
4
+ export function AnnotationPopup() {
5
+ const popupRef = React.createRef();
6
+ const textAreaRef = React.createRef();
7
+ const { newAnnotation, setNewAnnotation, newAnnotationRef, onSaveAnnotation } = useContext(AnnotationContext);
8
+ const [comment, setComment] = useState('');
9
+ const [saveEnabled, setSaveEnabled] = useState(false);
10
+ useEffect(() => {
11
+ if (newAnnotationRef && textAreaRef.current) {
12
+ showAndPositionElement(newAnnotationRef, popupRef);
13
+ textAreaRef.current.innerHTML = comment;
14
+ makeRichText(textAreaRef.current, {
15
+ locale: 'FI',
16
+ screenshotSaver: () => Promise.resolve('')
17
+ }, value => {
18
+ setComment(value.answerHTML);
19
+ setSaveEnabled(value.answerHTML.trim().length > 0);
20
+ });
21
+ textAreaRef.current.focus();
22
+ }
23
+ }, [newAnnotationRef]);
24
+ if (!newAnnotation) {
25
+ if (comment) {
26
+ setComment('');
27
+ }
28
+ return null;
29
+ }
30
+ const closeEditor = () => {
31
+ setNewAnnotation(null);
32
+ closeMathEditor(textAreaRef.current);
33
+ };
34
+ function updateComment(annotation, comment) {
35
+ onSaveAnnotation({ ...annotation, message: comment });
36
+ closeEditor();
37
+ }
38
+ return (React.createElement("div", { className: "annotation-popup", style: { position: 'absolute', opacity: 0 }, ref: popupRef, "data-testid": "annotation-popup" },
39
+ React.createElement("div", { className: "comment-content", "data-testid": "edit-comment", role: "textbox", "aria-multiline": "true", ref: textAreaRef }),
40
+ React.createElement("span", { className: "comment-button-area" },
41
+ React.createElement("span", null,
42
+ React.createElement("button", { className: "button", onClick: e => {
43
+ e.stopPropagation();
44
+ closeMathEditor(textAreaRef.current);
45
+ updateComment(newAnnotation, comment);
46
+ }, "data-testid": "save-comment", disabled: !saveEnabled }, "Vastaa"),
47
+ React.createElement("button", { className: "button text-button", onClick: closeEditor }, "Peru")))));
48
+ }
49
+ function showAndPositionElement(mark, popupRef) {
50
+ const popup = popupRef.current;
51
+ if (mark && popup) {
52
+ const style = popup.style;
53
+ const markRect = mark === null || mark === void 0 ? void 0 : mark.getBoundingClientRect();
54
+ const popupRect = popup.getBoundingClientRect();
55
+ const top = markRect.height + markRect.top + window.scrollY;
56
+ const windowWidth = window.innerWidth;
57
+ style.top = `${String(top)}px`;
58
+ style.opacity = '1';
59
+ const popupHitsWindowRight = markRect.left + popupRect.width > windowWidth;
60
+ if (popupHitsWindowRight) {
61
+ style.left = `${markRect.right - popupRect.width}px`;
62
+ }
63
+ else {
64
+ style.left = `${markRect.left}px`;
65
+ }
66
+ }
67
+ }
68
+ function closeMathEditor(element) {
69
+ // rich-text-editor does not properly support several rich-text-editor instances created at different times.
70
+ // In order to close math editor that is open, we need to dispatch events like this.
71
+ element.dispatchEvent(new Event('focus', { bubbles: true, cancelable: true }));
72
+ element.dispatchEvent(new Event('blur', { bubbles: true, cancelable: true }));
73
+ }
74
+ //# sourceMappingURL=AnnotationPopup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationPopup.js","sourceRoot":"","sources":["../../../src/components/shared/AnnotationPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAA;IAClD,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAA;IACrD,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7G,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAA;IAClD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAA;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,gBAAgB,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YAC5C,sBAAsB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAA;YAClD,WAAW,CAAC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAA;YACvC,YAAY,CACV,WAAW,CAAC,OAAO,EACnB;gBACE,MAAM,EAAE,IAAI;gBACZ,eAAe,EAAE,GAAG,EAAE,C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IACpF,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC9E,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ExamComponentProps } from '../createRenderChildNodes';
3
+ /** Surrounds an Exam component with a static HTML element.
4
+ *
5
+ * @example surround(Question, 'div', {className: 'foobar'})
6
+ */
7
+ export default function surround<K extends keyof JSX.IntrinsicElements>(Component: React.ComponentType<ExamComponentProps>, Tag: K, props?: JSX.IntrinsicElements[K]): React.ComponentType<ExamComponentProps>;
8
+ //# sourceMappingURL=surround.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surround.d.ts","sourceRoot":"","sources":["../../src/components/surround.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,EACpE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAClD,GAAG,EAAE,CAAC,EACN,KAAK,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAC/B,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAczC"}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { getDisplayName } from '../getDisplayName';
3
+ /** Surrounds an Exam component with a static HTML element.
4
+ *
5
+ * @example surround(Question, 'div', {className: 'foobar'})
6
+ */
7
+ export default function surround(Component, Tag, props) {
8
+ const Wrapped = (componentProps) => {
9
+ // Can't seem to be able to limit the type to HTML elements that accept children.
10
+ // So as a hack, type them as any inside the function to make the compiler happy.
11
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
12
+ const TagAsAny = Tag;
13
+ return (React.createElement(TagAsAny, { ...props },
14
+ React.createElement(Component, { ...componentProps })));
15
+ };
16
+ Wrapped.displayName = `Surround(${getDisplayName(Component)})`;
17
+ return Wrapped;
18
+ }
19
+ //# sourceMappingURL=surround.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surround.js","sourceRoot":"","sources":["../../src/components/surround.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,SAAkD,EAClD,GAAM,EACN,KAAgC;IAEhC,MAAM,OAAO,GAAG,CAAC,cAAkC,EAAE,EAAE;QACrD,iFAAiF;QACjF,iFAAiF;QACjF,mEAAmE;QACnE,MAAM,QAAQ,GAAG,GAAU,CAAA;QAC3B,OAAO,CACL,oBAAC,QAAQ,OAAK,KAAK;YACjB,oBAAC,SAAS,OAAK,cAAc,GAAI,CACxB,CACZ,CAAA;IACH,CAAC,CAAA;IACD,OAAO,CAAC,WAAW,GAAG,YAAY,cAAc,CAAC,SAAS,CAAC,GAAG,CAAA;IAC9D,OAAO,OAAO,CAAA;AAChB,CAAC"}