@digabi/exam-engine-core 22.0.1-alpha.5 → 22.0.1-alpha.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"AnswerGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/AnswerGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAIjE,QAAA,MAAM,wBAAwB,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAWzE,CAAA;AAED,eAAe,wBAAwB,CAAA"}
1
+ {"version":3,"file":"AnswerGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/AnswerGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAIjE,QAAA,MAAM,wBAAwB,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAOzE,CAAA;AAED,eAAe,wBAAwB,CAAA"}
@@ -3,7 +3,7 @@ import { GradingInstructionContext } from '../context/GradingInstructionContext'
3
3
  import EditableGradingInstruction from './EditableGradingInstruction';
4
4
  const AnswerGradingInstruction = ({ element, renderChildNodes }) => {
5
5
  const { editable } = useContext(GradingInstructionContext);
6
- return (React.createElement("div", { className: "e-answer-grading-instruction e-multiline-results-text-answer e-mrg-b-2 e-pad-l-2" }, editable ? (React.createElement(EditableGradingInstruction, { element: element, renderChildNodes: renderChildNodes })) : (renderChildNodes(element))));
6
+ return (React.createElement("div", { className: "e-answer-grading-instruction e-multiline-results-text-answer e-mrg-b-2 e-pad-l-2" }, editable ? React.createElement(EditableGradingInstruction, { element: element }) : renderChildNodes(element)));
7
7
  };
8
8
  export default AnswerGradingInstruction;
9
9
  //# sourceMappingURL=AnswerGradingInstruction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AnswerGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/AnswerGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,0BAA0B,MAAM,8BAA8B,CAAA;AAErE,MAAM,wBAAwB,GAAgD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC9G,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAA;IAC1D,OAAO,CACL,6BAAK,SAAS,EAAC,kFAAkF,IAC9F,QAAQ,CAAC,CAAC,CAAC,CACV,oBAAC,0BAA0B,IAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CACrF,CAAC,CAAC,CAAC,CACF,gBAAgB,CAAC,OAAO,CAAC,CAC1B,CACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,wBAAwB,CAAA"}
1
+ {"version":3,"file":"AnswerGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/AnswerGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,0BAA0B,MAAM,8BAA8B,CAAA;AAErE,MAAM,wBAAwB,GAAgD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC9G,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAA;IAC1D,OAAO,CACL,6BAAK,SAAS,EAAC,kFAAkF,IAC9F,QAAQ,CAAC,CAAC,CAAC,oBAAC,0BAA0B,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CACpF,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,wBAAwB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { ExamComponentProps } from '../../createRenderChildNodes';
3
- declare const EditableGradingInstruction: React.FunctionComponent<ExamComponentProps>;
2
+ declare function EditableGradingInstruction({ element }: {
3
+ element: Element;
4
+ }): React.JSX.Element;
4
5
  export default EditableGradingInstruction;
5
6
  //# sourceMappingURL=EditableGradingInstruction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditableGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/EditableGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAK5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,QAAA,MAAM,0BAA0B,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAsB3E,CAAA;AAED,eAAe,0BAA0B,CAAA"}
1
+ {"version":3,"file":"EditableGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/EditableGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAA;AA2BnD,iBAAS,0BAA0B,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,qBA0BpE;AAED,eAAe,0BAA0B,CAAA"}
@@ -1,26 +1,44 @@
1
- import React, { useContext, useEffect, useRef } from 'react';
2
- import { makeRichText } from 'rich-text-editor';
1
+ import React, { useContext, useState } from 'react';
2
+ import { schema } from 'prosemirror-schema-basic';
3
+ import { EditorState } from 'prosemirror-state';
4
+ import { toggleMark, baseKeymap } from 'prosemirror-commands';
3
5
  import { GradingInstructionContext } from '../context/GradingInstructionContext';
4
- import { CommonExamContext } from '../context/CommonExamContext';
5
- import { QuestionContext } from '../context/QuestionContext';
6
- const EditableGradingInstruction = ({ element, renderChildNodes }) => {
7
- const { language, examType } = useContext(CommonExamContext);
8
- const { displayNumber } = useContext(QuestionContext);
9
- const { onContentChange, saveScreenshot } = useContext(GradingInstructionContext);
10
- const answerGradingInstructionDiv = useRef(null);
11
- useEffect(() => {
12
- var _a;
13
- if (answerGradingInstructionDiv.current) {
6
+ import { ProseMirror, useEditorEventCallback } from '@nytimes/react-prosemirror';
7
+ import { DOMParser as ProseDOMParser, DOMSerializer } from 'prosemirror-model';
8
+ import { keymap } from 'prosemirror-keymap';
9
+ function BoldButton() {
10
+ const onClick = useEditorEventCallback(view => {
11
+ const toggleBoldMark = toggleMark(view.state.schema.marks.strong);
12
+ toggleBoldMark(view.state, view.dispatch, view);
13
+ });
14
+ return React.createElement("button", { onClick: onClick }, "Bold");
15
+ }
16
+ function ItalicButton() {
17
+ const onClick = useEditorEventCallback(view => {
18
+ const toggleItalicMark = toggleMark(view.state.schema.marks.em);
19
+ toggleItalicMark(view.state, view.dispatch, view);
20
+ });
21
+ return React.createElement("button", { onClick: onClick }, "Italic");
22
+ }
23
+ function EditableGradingInstruction({ element }) {
24
+ const { onContentChange } = useContext(GradingInstructionContext);
25
+ const doc = ProseDOMParser.fromSchema(schema).parse(element);
26
+ const [mount, setMount] = useState(null);
27
+ const [state, setState] = useState(EditorState.create({ schema, doc, plugins: [keymap(baseKeymap)] }));
28
+ return (React.createElement(ProseMirror, { mount: mount, state: state, dispatchTransaction: tr => {
29
+ var _a;
30
+ setState(s => s.apply(tr));
31
+ const fragment = DOMSerializer.fromSchema(state.schema).serializeFragment(tr.doc.content);
32
+ const div = document.createElement('div');
33
+ div.appendChild(fragment);
14
34
  const path = (_a = element.getAttribute('path')) !== null && _a !== void 0 ? _a : '';
15
- makeRichText(answerGradingInstructionDiv.current, {
16
- locale: language.startsWith('sv') ? 'SV' : 'FI',
17
- screenshotSaver: saveScreenshot ? ({ type, data }) => saveScreenshot(type, data, displayNumber) : undefined,
18
- screenshotImageSelector: 'img[src^="data:image/png"], img[src^="data:image/jpeg"]',
19
- fileTypes: ['image/png', 'image/jpeg']
20
- }, ({ answerHTML }) => (onContentChange ? onContentChange(answerHTML, path) : () => { }));
21
- }
22
- }, [language, examType]);
23
- return React.createElement("div", { ref: answerGradingInstructionDiv }, renderChildNodes(element));
24
- };
35
+ if (onContentChange) {
36
+ onContentChange(div.innerHTML, path);
37
+ }
38
+ } },
39
+ React.createElement(BoldButton, null),
40
+ React.createElement(ItalicButton, null),
41
+ React.createElement("div", { ref: setMount })));
42
+ }
25
43
  export default EditableGradingInstruction;
26
44
  //# sourceMappingURL=EditableGradingInstruction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditableGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/EditableGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,MAAM,0BAA0B,GAAgD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAChH,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC5D,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IACrD,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAA;IACjF,MAAM,2BAA2B,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IAEhE,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,2BAA2B,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAA;YAC/C,YAAY,CACV,2BAA2B,CAAC,OAAO,EACnC;gBACE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;gBAC/C,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC3G,uBAAuB,EAAE,yDAAyD;gBAClF,SAAS,EAAE,CAAC,WAAW,EAAE,YAAY,CAAC;aACvC,EACD,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CACrF,CAAA;QACH,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;IACxB,OAAO,6BAAK,GAAG,EAAE,2BAA2B,IAAG,gBAAgB,CAAC,OAAO,CAAC,CAAO,CAAA;AACjF,CAAC,CAAA;AAED,eAAe,0BAA0B,CAAA"}
1
+ {"version":3,"file":"EditableGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/EditableGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OA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,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAEtG,OAAO,CACL,oBAAC,WAAW,IACV,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,EAAE,CAAC,EAAE;;YACxB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,MAAM,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzF,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;YACzC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;YACzB,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAA;YAC/C,IAAI,eAAe,EAAE,CAAC;gBACpB,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QAED,oBAAC,UAAU,OAAG;QACd,oBAAC,YAAY,OAAG;QAChB,6BAAK,GAAG,EAAE,QAAQ,GAAI,CACV,CACf,CAAA;AACH,CAAC;AAED,eAAe,0BAA0B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExamGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/ExamGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAIjE,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAYvE,CAAA;AACD,eAAe,sBAAsB,CAAA"}
1
+ {"version":3,"file":"ExamGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/ExamGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAIjE,QAAA,MAAM,sBAAsB,EAAE,KAAK,CAAC,iBAAiB,CAAC,kBAAkB,CAQvE,CAAA;AACD,eAAe,sBAAsB,CAAA"}
@@ -3,7 +3,7 @@ import { GradingInstructionContext } from '../context/GradingInstructionContext'
3
3
  import EditableGradingInstruction from './EditableGradingInstruction';
4
4
  const ExamGradingInstruction = ({ element, renderChildNodes }) => {
5
5
  const { editable } = useContext(GradingInstructionContext);
6
- return (React.createElement("div", { className: "e-exam-grading-instruction notification e-pad-4", "data-annotation-anchor": "exam-grading-instruction" }, editable ? (React.createElement(EditableGradingInstruction, { element: element, renderChildNodes: renderChildNodes })) : (renderChildNodes(element))));
6
+ return (React.createElement("div", { className: "e-exam-grading-instruction notification e-pad-4", "data-annotation-anchor": "exam-grading-instruction" }, editable ? React.createElement(EditableGradingInstruction, { element: element }) : renderChildNodes(element)));
7
7
  };
8
8
  export default ExamGradingInstruction;
9
9
  //# sourceMappingURL=ExamGradingInstruction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExamGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/ExamGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,0BAA0B,MAAM,8BAA8B,CAAA;AAErE,MAAM,sBAAsB,GAAgD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC5G,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAA;IAE1D,OAAO,CACL,6BAAK,SAAS,EAAC,iDAAiD,4BAAwB,0BAA0B,IAC/G,QAAQ,CAAC,CAAC,CAAC,CACV,oBAAC,0BAA0B,IAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CACrF,CAAC,CAAC,CAAC,CACF,gBAAgB,CAAC,OAAO,CAAC,CAC1B,CACG,CACP,CAAA;AACH,CAAC,CAAA;AACD,eAAe,sBAAsB,CAAA"}
1
+ {"version":3,"file":"ExamGradingInstruction.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/ExamGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,0BAA0B,MAAM,8BAA8B,CAAA;AAErE,MAAM,sBAAsB,GAAgD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC5G,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,yBAAyB,CAAC,CAAA;IAE1D,OAAO,CACL,6BAAK,SAAS,EAAC,iDAAiD,4BAAwB,0BAA0B,IAC/G,QAAQ,CAAC,CAAC,CAAC,oBAAC,0BAA0B,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CACpF,CACP,CAAA;AACH,CAAC,CAAA;AACD,eAAe,sBAAsB,CAAA"}