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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/__tests__/EditableGradingInstruction.test.d.ts +2 -0
  2. package/dist/__tests__/EditableGradingInstruction.test.d.ts.map +1 -0
  3. package/dist/__tests__/EditableGradingInstruction.test.js +178 -0
  4. package/dist/__tests__/EditableGradingInstruction.test.js.map +1 -0
  5. package/dist/__tests__/FormatButton.test.d.ts +2 -0
  6. package/dist/__tests__/FormatButton.test.d.ts.map +1 -0
  7. package/dist/__tests__/FormatButton.test.js +94 -0
  8. package/dist/__tests__/FormatButton.test.js.map +1 -0
  9. package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
  10. package/dist/__tests__/utils/ProseMirrorWrapper.d.ts +8 -0
  11. package/dist/__tests__/utils/ProseMirrorWrapper.d.ts.map +1 -0
  12. package/dist/__tests__/utils/ProseMirrorWrapper.js +44 -0
  13. package/dist/__tests__/utils/ProseMirrorWrapper.js.map +1 -0
  14. package/dist/__tests__/utils/prosemirror.d.ts +3 -0
  15. package/dist/__tests__/utils/prosemirror.d.ts.map +1 -0
  16. package/dist/__tests__/utils/prosemirror.js +38 -0
  17. package/dist/__tests__/utils/prosemirror.js.map +1 -0
  18. package/dist/components/grading-instructions/AnswerGradingInstruction.d.ts.map +1 -1
  19. package/dist/components/grading-instructions/AnswerGradingInstruction.js +1 -1
  20. package/dist/components/grading-instructions/AnswerGradingInstruction.js.map +1 -1
  21. package/dist/components/grading-instructions/EditableGradingInstruction.d.ts +3 -2
  22. package/dist/components/grading-instructions/EditableGradingInstruction.d.ts.map +1 -1
  23. package/dist/components/grading-instructions/EditableGradingInstruction.js +37 -22
  24. package/dist/components/grading-instructions/EditableGradingInstruction.js.map +1 -1
  25. package/dist/components/grading-instructions/ExamGradingInstruction.d.ts.map +1 -1
  26. package/dist/components/grading-instructions/ExamGradingInstruction.js +1 -1
  27. package/dist/components/grading-instructions/ExamGradingInstruction.js.map +1 -1
  28. package/dist/components/grading-instructions/editor/FormatButton.d.ts +8 -0
  29. package/dist/components/grading-instructions/editor/FormatButton.d.ts.map +1 -0
  30. package/dist/components/grading-instructions/editor/FormatButton.js +23 -0
  31. package/dist/components/grading-instructions/editor/FormatButton.js.map +1 -0
  32. package/dist/components/grading-instructions/editor/Table.d.ts +5 -0
  33. package/dist/components/grading-instructions/editor/Table.d.ts.map +1 -0
  34. package/dist/components/grading-instructions/editor/Table.js +181 -0
  35. package/dist/components/grading-instructions/editor/Table.js.map +1 -0
  36. package/dist/main-bundle.js +1 -1
  37. package/dist/main.css +1 -1
  38. package/package.json +9 -2
@@ -0,0 +1,8 @@
1
+ import React, { ReactNode } from 'react';
2
+ interface WrapperProps {
3
+ children?: ReactNode;
4
+ innerHtml?: string;
5
+ }
6
+ declare const ProseMirrorWrapper: React.FC<WrapperProps>;
7
+ export default ProseMirrorWrapper;
8
+ //# sourceMappingURL=ProseMirrorWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProseMirrorWrapper.d.ts","sourceRoot":"","sources":["../../../__tests__/utils/ProseMirrorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAA;AAMlD,UAAU,YAAY;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAmB9C,CAAA;AAED,eAAe,kBAAkB,CAAA"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const react_prosemirror_1 = require("@nytimes/react-prosemirror");
28
+ const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
29
+ const prosemirror_model_1 = require("prosemirror-model");
30
+ const prosemirror_state_1 = require("prosemirror-state");
31
+ const ProseMirrorWrapper = ({ children, innerHtml = '' }) => {
32
+ const [mount, setMount] = (0, react_1.useState)(null);
33
+ const container = document.createElement('div');
34
+ container.innerHTML = innerHtml;
35
+ const doc = prosemirror_model_1.DOMParser.fromSchema(prosemirror_schema_basic_1.schema).parse(container);
36
+ const [state, setState] = (0, react_1.useState)(prosemirror_state_1.EditorState.create({ schema: prosemirror_schema_basic_1.schema, doc }));
37
+ return (react_1.default.createElement(react_prosemirror_1.ProseMirror, { state: state, mount: mount, dispatchTransaction: tr => {
38
+ setState(s => s.apply(tr));
39
+ } },
40
+ react_1.default.createElement("div", { ref: setMount }),
41
+ children));
42
+ };
43
+ exports.default = ProseMirrorWrapper;
44
+ //# sourceMappingURL=ProseMirrorWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProseMirrorWrapper.js","sourceRoot":"","sources":["../../../__tests__/utils/ProseMirrorWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,kEAAwD;AACxD,uEAAiD;AACjD,yDAA+D;AAC/D,yDAA+C;AAO/C,MAAM,kBAAkB,GAA2B,CAAC,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IAClF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqB,IAAI,CAAC,CAAA;IAC5D,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC/C,SAAS,CAAC,SAAS,GAAG,SAAS,CAAA;IAC/B,MAAM,GAAG,GAAG,6BAAc,CAAC,UAAU,CAAC,iCAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAC9D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,+BAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAN,iCAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IAEvE,OAAO,CACL,8BAAC,+BAAW,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;QAC5B,CAAC;QAED,uCAAK,GAAG,EAAE,QAAQ,GAAI;QACrB,QAAQ,CACG,CACf,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare function mockCreateRange(): () => () => Range;
2
+ export declare function promisifiedFireEventInput(element: Element, options: object): Promise<void>;
3
+ //# sourceMappingURL=prosemirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosemirror.d.ts","sourceRoot":"","sources":["../../../__tests__/utils/prosemirror.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,sBA2B9B;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAK1E"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockCreateRange = mockCreateRange;
4
+ exports.promisifiedFireEventInput = promisifiedFireEventInput;
5
+ const react_1 = require("@testing-library/react");
6
+ function mockCreateRange() {
7
+ const originalCreateRange = global.window.document.createRange;
8
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
+ // @ts-expect-error
10
+ global.Range = function Range() { };
11
+ const createContextualFragment = (html) => {
12
+ const div = document.createElement('div');
13
+ div.innerHTML = html;
14
+ return div.children[0];
15
+ };
16
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
+ // @ts-expect-error
18
+ Range.prototype.createContextualFragment = (html) => createContextualFragment(html);
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-expect-error
21
+ global.window.document.createRange = function createRange() {
22
+ return {
23
+ setEnd: () => { },
24
+ setStart: () => { },
25
+ getBoundingClientRect: () => ({ right: 0 }),
26
+ getClientRects: () => [],
27
+ createContextualFragment
28
+ };
29
+ };
30
+ return () => (global.window.document.createRange = originalCreateRange);
31
+ }
32
+ function promisifiedFireEventInput(element, options) {
33
+ return new Promise(resolve => {
34
+ react_1.fireEvent.input(element, options);
35
+ resolve();
36
+ });
37
+ }
38
+ //# sourceMappingURL=prosemirror.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prosemirror.js","sourceRoot":"","sources":["../../../__tests__/utils/prosemirror.ts"],"names":[],"mappings":";;AAEA,0CA2BC;AAED,8DAKC;AApCD,kDAAkD;AAElD,SAAgB,eAAe;IAC7B,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAA;IAC9D,6DAA6D;IAC7D,mBAAmB;IACnB,MAAM,CAAC,KAAK,GAAG,SAAS,KAAK,KAAI,CAAC,CAAA;IAElC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;QAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACzC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAA;QACpB,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC,CAAA;IACD,6DAA6D;IAC7D,mBAAmB;IACnB,KAAK,CAAC,SAAS,CAAC,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAA;IAE3F,6DAA6D;IAC7D,mBAAmB;IACnB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,SAAS,WAAW;QACvD,OAAO;YACL,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;YAChB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;YAClB,qBAAqB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;YAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;YACxB,wBAAwB;SACzB,CAAA;IACH,CAAC,CAAA;IACD,OAAO,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,mBAAmB,CAAC,CAAA;AACzE,CAAC;AAED,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,OAAe;IACzE,OAAO,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;QACjC,iBAAS,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACjC,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -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;AA0BnD,iBAAS,0BAA0B,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,qBAyBpE;AAED,eAAe,0BAA0B,CAAA"}
@@ -1,26 +1,41 @@
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 as baseSchema } from 'prosemirror-schema-basic';
3
+ import { EditorState } from 'prosemirror-state';
4
+ import { 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 } from '@nytimes/react-prosemirror';
7
+ import { DOMParser as ProseDOMParser, DOMSerializer, Schema } from 'prosemirror-model';
8
+ import { keymap } from 'prosemirror-keymap';
9
+ import { TableMenu, tableSchema } from './editor/Table';
10
+ import FormatButton from './editor/FormatButton';
11
+ const schema = new Schema({
12
+ nodes: baseSchema.spec.nodes.append(tableSchema),
13
+ marks: baseSchema.spec.marks
14
+ });
15
+ function Menu() {
16
+ return (React.createElement(React.Fragment, null,
17
+ React.createElement(FormatButton, { markName: "strong", displayName: "Bold" }),
18
+ React.createElement(FormatButton, { markName: "em", displayName: "Italic" }),
19
+ React.createElement(TableMenu, null)));
20
+ }
21
+ function EditableGradingInstruction({ element }) {
22
+ const { onContentChange } = useContext(GradingInstructionContext);
23
+ const doc = ProseDOMParser.fromSchema(schema).parse(element);
24
+ const [mount, setMount] = useState(null);
25
+ const [state, setState] = useState(EditorState.create({ schema, doc, plugins: [keymap(baseKeymap)] }));
26
+ return (React.createElement(ProseMirror, { mount: mount, state: state, dispatchTransaction: tr => {
27
+ var _a;
28
+ setState(s => s.apply(tr));
29
+ const fragment = DOMSerializer.fromSchema(state.schema).serializeFragment(tr.doc.content);
30
+ const div = document.createElement('div');
31
+ div.appendChild(fragment);
14
32
  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
- };
33
+ if (onContentChange) {
34
+ onContentChange(div.innerHTML, path);
35
+ }
36
+ } },
37
+ React.createElement(Menu, null),
38
+ React.createElement("div", { ref: setMount })));
39
+ }
25
40
  export default EditableGradingInstruction;
26
41
  //# 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,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,YAAY,MAAM,uBAAuB,CAAA;AAEhD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;IAC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G,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,IAAI,OAAG;QACR,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"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ markName: string;
4
+ displayName: string;
5
+ }
6
+ declare function FormatButton({ markName, displayName }: Props): React.JSX.Element;
7
+ export default FormatButton;
8
+ //# sourceMappingURL=FormatButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatButton.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/FormatButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,UAAU,KAAK;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAID,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,KAAK,qBAuBrD;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { useEditorEventCallback, useEditorState } from '@nytimes/react-prosemirror';
2
+ import { toggleMark } from 'prosemirror-commands';
3
+ import React, { useEffect, useState } from 'react';
4
+ const getMarkType = (state, markName) => state.schema.marks[markName];
5
+ function FormatButton({ markName, displayName }) {
6
+ const editorState = useEditorState();
7
+ const [isActive, setIsActive] = useState(false);
8
+ const onClick = useEditorEventCallback(view => {
9
+ const { state } = view;
10
+ const toggleFormatMark = toggleMark(getMarkType(state, markName));
11
+ toggleFormatMark(state, view.dispatch, view);
12
+ view.focus();
13
+ });
14
+ useEffect(() => {
15
+ const isTextFormatActive = editorState.storedMarks
16
+ ? getMarkType(editorState, markName).isInSet(editorState.storedMarks) // is next input going to be marked?
17
+ : getMarkType(editorState, markName).isInSet(editorState.selection.$to.marks()); // is current input marked?
18
+ setIsActive(!!isTextFormatActive);
19
+ }, [editorState]);
20
+ return (React.createElement("button", { onClick: onClick, style: { fontWeight: isActive ? 'bold' : 'normal' } }, displayName));
21
+ }
22
+ export default FormatButton;
23
+ //# sourceMappingURL=FormatButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatButton.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/FormatButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAOlD,MAAM,WAAW,GAAG,CAAC,KAAkB,EAAE,QAAgB,EAAY,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AAEpG,SAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAS;IACpD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE/C,MAAM,OAAO,GAAG,sBAAsB,CAAC,IAAI,CAAC,EAAE;QAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QACtB,MAAM,gBAAgB,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;QACjE,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAC5C,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,kBAAkB,GAAG,WAAW,CAAC,WAAW;YAChD,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,oCAAoC;YAC1G,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAA,CAAC,2BAA2B;QAC7G,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAA;IACnC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,OAAO,CACL,gCAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,IAC1E,WAAW,CACL,CACV,CAAA;AACH,CAAC;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { NodeSpec } from 'prosemirror-model';
2
+ import React from 'react';
3
+ export declare const tableSchema: NodeSpec;
4
+ export declare function TableMenu(): React.JSX.Element;
5
+ //# sourceMappingURL=Table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/Table.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAmB,MAAM,OAAO,CAAA;AAavC,eAAO,MAAM,WAAW,EAAE,QAmCzB,CAAA;AAED,wBAAgB,SAAS,sBAqHxB"}
@@ -0,0 +1,181 @@
1
+ import { addColumnAfter, addRowAfter, deleteColumn, deleteRow, deleteTable, tableNodes } from 'prosemirror-tables';
2
+ import { Fragment } from 'prosemirror-model';
3
+ import React, { useState } from 'react';
4
+ import { useEditorEventCallback } from '@nytimes/react-prosemirror';
5
+ import { TextSelection } from 'prosemirror-state';
6
+ import { faTable } from '@fortawesome/free-solid-svg-icons';
7
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
+ const defaultSchema = tableNodes({
9
+ tableGroup: 'block',
10
+ cellContent: 'block+',
11
+ cellAttributes: { class: { default: '' } }
12
+ });
13
+ export const tableSchema = {
14
+ ...defaultSchema,
15
+ table: {
16
+ ...defaultSchema.table,
17
+ parseDOM: [
18
+ {
19
+ tag: 'table',
20
+ getAttrs: (dom) => ({ class: dom.getAttribute('class') })
21
+ }
22
+ ],
23
+ attrs: { class: { default: '' } },
24
+ toDOM(node) {
25
+ const classNames = node.attrs.class || undefined;
26
+ return [
27
+ 'table',
28
+ {
29
+ class: classNames
30
+ },
31
+ ['tbody', 0]
32
+ ];
33
+ }
34
+ },
35
+ table_cell: {
36
+ ...defaultSchema.table_cell,
37
+ parseDOM: [
38
+ {
39
+ tag: 'td',
40
+ getAttrs: (dom) => ({ class: dom.getAttribute('class') })
41
+ }
42
+ ],
43
+ toDOM(node) {
44
+ const classNames = node.attrs.class || undefined;
45
+ return ['td', { class: classNames }, 0];
46
+ }
47
+ }
48
+ };
49
+ export function TableMenu() {
50
+ const withFocus = (view, action) => {
51
+ const result = action(view.state, view.dispatch);
52
+ view.focus();
53
+ return result;
54
+ };
55
+ const menuOptions = {
56
+ addTable: {
57
+ title: 'Lisää taulukko',
58
+ onClick: useEditorEventCallback(view => {
59
+ const offset = view.state.selection.anchor + 1;
60
+ const transaction = view.state.tr;
61
+ const cell = view.state.schema.nodes.table_cell.createAndFill(null, Fragment.empty);
62
+ const row = view.state.schema.nodes.table_row.create(null, Fragment.fromArray([cell, cell]));
63
+ const table = view.state.schema.nodes.table.create({ class: 'e-table e-width-half' }, Fragment.fromArray([row, row]));
64
+ if (view.dispatch) {
65
+ view.dispatch(transaction
66
+ .replaceSelectionWith(table)
67
+ .scrollIntoView()
68
+ .setSelection(TextSelection.near(transaction.doc.resolve(offset))));
69
+ view.focus();
70
+ }
71
+ return true;
72
+ })
73
+ },
74
+ addColumnAfter: {
75
+ title: 'Lisää sarake',
76
+ onClick: useEditorEventCallback(view => withFocus(view, addColumnAfter))
77
+ },
78
+ addRowAfter: {
79
+ title: 'Lisää rivi',
80
+ onClick: useEditorEventCallback(view => withFocus(view, addRowAfter))
81
+ },
82
+ deleteColumn: {
83
+ title: 'Poista sarake',
84
+ onClick: useEditorEventCallback(view => withFocus(view, deleteColumn))
85
+ },
86
+ deleteRow: {
87
+ title: 'Poista rivi',
88
+ onClick: useEditorEventCallback(view => withFocus(view, deleteRow))
89
+ },
90
+ deleteTable: {
91
+ title: 'Poista taulukko',
92
+ onClick: useEditorEventCallback(view => withFocus(view, deleteTable))
93
+ },
94
+ setFullWidth: {
95
+ title: 'Täysi leveys',
96
+ onClick: useEditorEventCallback(view => changeWidthClass(view, 'e-width-full'))
97
+ },
98
+ setHalfWidth: {
99
+ title: 'Puolikas leveys',
100
+ onClick: useEditorEventCallback(view => changeWidthClass(view, 'e-width-half'))
101
+ },
102
+ removeBorder: {
103
+ title: 'Poista reunat',
104
+ onClick: useEditorEventCallback(view => addClass(view, 'e-table--borderless'))
105
+ },
106
+ addBorder: {
107
+ title: 'Lisää reunat',
108
+ onClick: useEditorEventCallback(view => removeClass(view, 'e-table--borderless'))
109
+ },
110
+ removeZebra: {
111
+ title: 'Poista kuviointi',
112
+ onClick: useEditorEventCallback(view => removeClass(view, 'e-table--zebra'))
113
+ },
114
+ addZebra: {
115
+ title: 'Lisää kuviointi',
116
+ onClick: useEditorEventCallback(view => addClass(view, 'e-table--zebra'))
117
+ }
118
+ };
119
+ const [isOpen, setIsOpen] = useState(false);
120
+ const Option = ({ title, onClick }) => (React.createElement("li", { onClick: () => {
121
+ onClick();
122
+ setIsOpen(false);
123
+ } }, title));
124
+ return (React.createElement(React.Fragment, null,
125
+ React.createElement("span", { className: "e-menu-dropdown" },
126
+ React.createElement("button", { onClick: () => setIsOpen(!isOpen) },
127
+ React.createElement(FontAwesomeIcon, { size: "sm", icon: faTable, fixedWidth: true })),
128
+ React.createElement("ul", { className: "e-menu-dropdown-menu", style: { display: isOpen ? 'block' : 'none' } },
129
+ React.createElement(Option, { ...menuOptions.addTable }),
130
+ React.createElement(Option, { ...menuOptions.addRowAfter }),
131
+ React.createElement(Option, { ...menuOptions.addColumnAfter }),
132
+ React.createElement(Option, { ...menuOptions.deleteRow }),
133
+ React.createElement(Option, { ...menuOptions.deleteColumn }),
134
+ React.createElement(Option, { ...menuOptions.deleteTable }),
135
+ React.createElement(Option, { ...menuOptions.setFullWidth }),
136
+ React.createElement(Option, { ...menuOptions.setHalfWidth }),
137
+ React.createElement(Option, { ...menuOptions.removeBorder }),
138
+ React.createElement(Option, { ...menuOptions.addBorder }),
139
+ React.createElement(Option, { ...menuOptions.removeZebra }),
140
+ React.createElement(Option, { ...menuOptions.addZebra })))));
141
+ }
142
+ function changeWidthClass(view, className) {
143
+ return changeClasses(view, className, swapWidthClass);
144
+ }
145
+ function addClass(view, className) {
146
+ return changeClasses(view, className, addClassToExistingClasses);
147
+ }
148
+ function removeClass(view, className) {
149
+ return changeClasses(view, className, removeClassFromExistingClasses);
150
+ }
151
+ function addClassToExistingClasses(classes, newClass) {
152
+ return classes ? [...classes.split(' ').filter(c => c !== newClass), newClass].join(' ') : newClass;
153
+ }
154
+ function removeClassFromExistingClasses(classes, classToRemove) {
155
+ return classes
156
+ ? classes
157
+ .split(' ')
158
+ .filter(c => c !== classToRemove)
159
+ .join(' ')
160
+ : '';
161
+ }
162
+ function swapWidthClass(classes, newClass) {
163
+ return classes ? [...classes.split(' ').filter(c => !c.startsWith('e-width')), newClass].join(' ') : newClass;
164
+ }
165
+ function changeClasses(view, className, convertClasses) {
166
+ const from = view.state.selection.$from;
167
+ for (let depth = from.depth; depth > 0; depth--) {
168
+ const node = from.node(depth);
169
+ if (node.type.spec.tableRole == 'table') {
170
+ if (view.dispatch) {
171
+ view.dispatch(view.state.tr.setNodeMarkup(from.before(depth), null, {
172
+ ...node.attrs,
173
+ ...{ class: convertClasses(node.attrs.class, className) }
174
+ }));
175
+ }
176
+ view.focus();
177
+ return true;
178
+ }
179
+ }
180
+ }
181
+ //# sourceMappingURL=Table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAClH,OAAO,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAe,aAAa,EAAe,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAGhE,MAAM,aAAa,GAAG,UAAU,CAAC;IAC/B,UAAU,EAAE,OAAO;IACnB,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE;CAC3C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,WAAW,GAAa;IACnC,GAAG,aAAa;IAChB,KAAK,EAAE;QACL,GAAG,aAAa,CAAC,KAAK;QACtB,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,OAAO;gBACZ,QAAQ,EAAE,CAAC,GAAgB,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;aACvE;SACF;QACD,KAAK,EAAE,EAAE,KA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