@digabi/exam-engine-core 22.1.1-alpha.0 → 22.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
- package/dist/components/context/AttachmentContext.d.ts.map +1 -1
- package/dist/components/context/ExamContext.d.ts.map +1 -1
- package/dist/components/context/GradingInstructionContext.d.ts +6 -11
- package/dist/components/context/GradingInstructionContext.d.ts.map +1 -1
- package/dist/components/context/GradingInstructionContext.js.map +1 -1
- package/dist/components/context/QuestionContext.d.ts.map +1 -1
- package/dist/components/context/ResultsContext.d.ts.map +1 -1
- package/dist/components/context/SectionContext.d.ts.map +1 -1
- package/dist/components/exam/DragAndDrop.d.ts +3 -0
- package/dist/components/exam/DragAndDrop.d.ts.map +1 -0
- package/dist/components/exam/DragAndDrop.js +7 -0
- package/dist/components/exam/DragAndDrop.js.map +1 -0
- package/dist/components/exam/NativeDND.d.ts +3 -0
- package/dist/components/exam/NativeDND.d.ts.map +1 -0
- package/dist/components/exam/NativeDND.js +75 -0
- package/dist/components/exam/NativeDND.js.map +1 -0
- package/dist/components/grading/AnnotatableGradingAnswer.d.ts +4 -0
- package/dist/components/grading/AnnotatableGradingAnswer.d.ts.map +1 -0
- package/dist/components/grading/AnnotatableGradingAnswer.js +24 -0
- package/dist/components/grading/AnnotatableGradingAnswer.js.map +1 -0
- package/dist/components/grading/GradingAnswer.d.ts.map +1 -1
- package/dist/components/grading/GradingAnswer.js +38 -16
- package/dist/components/grading/GradingAnswer.js.map +1 -1
- package/dist/components/grading-instructions/AnswerGradingInstruction.d.ts.map +1 -1
- package/dist/components/grading-instructions/AnswerGradingInstruction.js +4 -3
- package/dist/components/grading-instructions/AnswerGradingInstruction.js.map +1 -1
- package/dist/components/grading-instructions/ExamGradingInstruction.d.ts.map +1 -1
- package/dist/components/grading-instructions/ExamGradingInstruction.js +2 -7
- package/dist/components/grading-instructions/ExamGradingInstruction.js.map +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.d.ts +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.d.ts.map +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.js +1 -4
- package/dist/components/grading-instructions/GradingInstructionProvider.js.map +1 -1
- package/dist/components/grading-instructions/GradingInstructions.d.ts +6 -2
- package/dist/components/grading-instructions/GradingInstructions.d.ts.map +1 -1
- package/dist/components/grading-instructions/GradingInstructions.js +2 -3
- package/dist/components/grading-instructions/GradingInstructions.js.map +1 -1
- package/dist/components/shared/AnnotationWrapper.d.ts +5 -0
- package/dist/components/shared/AnnotationWrapper.d.ts.map +1 -0
- package/dist/components/shared/AnnotationWrapper.js +24 -0
- package/dist/components/shared/AnnotationWrapper.js.map +1 -0
- package/dist/components/shared/Mark.d.ts +9 -0
- package/dist/components/shared/Mark.d.ts.map +1 -0
- package/dist/components/shared/Mark.js +14 -0
- package/dist/components/shared/Mark.js.map +1 -0
- package/dist/components/shared/Popup.js +2 -2
- package/dist/components/shared/Popup.js.map +1 -1
- package/dist/dom-utils.d.ts.map +1 -1
- package/dist/dom-utils.js +4 -2
- package/dist/dom-utils.js.map +1 -1
- package/dist/i18n/fi-FI.d.ts +1 -0
- package/dist/i18n/fi-FI.d.ts.map +1 -1
- package/dist/i18n/fi-FI.js +2 -1
- package/dist/i18n/fi-FI.js.map +1 -1
- package/dist/i18n/sv-FI.d.ts.map +1 -1
- package/dist/i18n/sv-FI.js +2 -1
- package/dist/i18n/sv-FI.js.map +1 -1
- package/dist/main-bundle.js +1 -1
- package/dist/main-bundle.js.LICENSE.txt +1 -1
- package/dist/main.css +1 -1
- package/package.json +4 -11
- package/dist/__tests__/EditableGradingInsatruction.test.d.ts +0 -1
- package/dist/__tests__/EditableGradingInsatruction.test.d.ts.map +0 -1
- package/dist/__tests__/EditableGradingInsatruction.test.js +0 -2
- package/dist/__tests__/EditableGradingInsatruction.test.js.map +0 -1
- package/dist/__tests__/EditableGradingInstruction.test.d.ts +0 -2
- package/dist/__tests__/EditableGradingInstruction.test.d.ts.map +0 -1
- package/dist/__tests__/EditableGradingInstruction.test.js +0 -171
- package/dist/__tests__/EditableGradingInstruction.test.js.map +0 -1
- package/dist/__tests__/FormatButton.test.d.ts +0 -2
- package/dist/__tests__/FormatButton.test.d.ts.map +0 -1
- package/dist/__tests__/FormatButton.test.js +0 -94
- package/dist/__tests__/FormatButton.test.js.map +0 -1
- package/dist/__tests__/editor/Formula.test.d.ts +0 -2
- package/dist/__tests__/editor/Formula.test.d.ts.map +0 -1
- package/dist/__tests__/editor/Formula.test.js +0 -43
- package/dist/__tests__/editor/Formula.test.js.map +0 -1
- package/dist/__tests__/editor/NBSP.test.d.ts +0 -2
- package/dist/__tests__/editor/NBSP.test.d.ts.map +0 -1
- package/dist/__tests__/editor/NBSP.test.js +0 -43
- package/dist/__tests__/editor/NBSP.test.js.map +0 -1
- package/dist/__tests__/editor/br.test.d.ts +0 -2
- package/dist/__tests__/editor/br.test.d.ts.map +0 -1
- package/dist/__tests__/editor/br.test.js +0 -43
- package/dist/__tests__/editor/br.test.js.map +0 -1
- package/dist/__tests__/editor/hr.test.d.ts +0 -2
- package/dist/__tests__/editor/hr.test.d.ts.map +0 -1
- package/dist/__tests__/editor/hr.test.js +0 -43
- package/dist/__tests__/editor/hr.test.js.map +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.d.ts +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.d.ts.map +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.js +0 -2
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.js.map +0 -1
- package/dist/__tests__/utils/ProseMirrorWrapper.d.ts +0 -8
- package/dist/__tests__/utils/ProseMirrorWrapper.d.ts.map +0 -1
- package/dist/__tests__/utils/ProseMirrorWrapper.js +0 -44
- package/dist/__tests__/utils/ProseMirrorWrapper.js.map +0 -1
- package/dist/__tests__/utils/prosemirror.d.ts +0 -3
- package/dist/__tests__/utils/prosemirror.d.ts.map +0 -1
- package/dist/__tests__/utils/prosemirror.js +0 -38
- package/dist/__tests__/utils/prosemirror.js.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstruction.d.ts +0 -2
- package/dist/__tests__/utils/renderEditableGradingInstruction.d.ts.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstruction.js +0 -16
- package/dist/__tests__/utils/renderEditableGradingInstruction.js.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.d.ts +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.d.ts.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.js +0 -2
- package/dist/__tests__/utils/renderEditableGradingInstructions.js.map +0 -1
- package/dist/components/LexicalEditor.d.ts +0 -3
- package/dist/components/LexicalEditor.d.ts.map +0 -1
- package/dist/components/LexicalEditor.js +0 -44
- package/dist/components/LexicalEditor.js.map +0 -1
- package/dist/components/RTE.d.ts +0 -3
- package/dist/components/RTE.d.ts.map +0 -1
- package/dist/components/RTE.js +0 -23
- package/dist/components/RTE.js.map +0 -1
- package/dist/components/TablePlugin.d.ts +0 -1
- package/dist/components/TablePlugin.d.ts.map +0 -1
- package/dist/components/TablePlugin.js +0 -2
- package/dist/components/TablePlugin.js.map +0 -1
- package/dist/components/ToolBarPlugin.d.ts +0 -10
- package/dist/components/ToolBarPlugin.d.ts.map +0 -1
- package/dist/components/ToolBarPlugin.js +0 -111
- package/dist/components/ToolBarPlugin.js.map +0 -1
- package/dist/components/context/AnnotationContext.d.ts +0 -8
- package/dist/components/context/AnnotationContext.d.ts.map +0 -1
- package/dist/components/context/AnnotationContext.js +0 -3
- package/dist/components/context/AnnotationContext.js.map +0 -1
- package/dist/components/exam/ExamineExam.d.ts +0 -5
- package/dist/components/exam/ExamineExam.d.ts.map +0 -1
- package/dist/components/exam/ExamineExam.js +0 -20
- package/dist/components/exam/ExamineExam.js.map +0 -1
- package/dist/components/exam/FinishExam.d.ts +0 -5
- package/dist/components/exam/FinishExam.d.ts.map +0 -1
- package/dist/components/exam/FinishExam.js +0 -17
- package/dist/components/exam/FinishExam.js.map +0 -1
- package/dist/components/grading/reactAnnotation.d.ts +0 -4
- package/dist/components/grading/reactAnnotation.d.ts.map +0 -1
- package/dist/components/grading/reactAnnotation.js +0 -54
- package/dist/components/grading/reactAnnotation.js.map +0 -1
- package/dist/components/grading-instructions/EditableGradingInstruction.d.ts +0 -6
- package/dist/components/grading-instructions/EditableGradingInstruction.d.ts.map +0 -1
- package/dist/components/grading-instructions/EditableGradingInstruction.js +0 -57
- package/dist/components/grading-instructions/EditableGradingInstruction.js.map +0 -1
- package/dist/components/grading-instructions/SlateTableEditor.d.ts +0 -22
- package/dist/components/grading-instructions/SlateTableEditor.d.ts.map +0 -1
- package/dist/components/grading-instructions/SlateTableEditor.js +0 -44
- package/dist/components/grading-instructions/SlateTableEditor.js.map +0 -1
- package/dist/components/grading-instructions/SlateUtils.d.ts +0 -5
- package/dist/components/grading-instructions/SlateUtils.d.ts.map +0 -1
- package/dist/components/grading-instructions/SlateUtils.js +0 -28
- package/dist/components/grading-instructions/SlateUtils.js.map +0 -1
- package/dist/components/grading-instructions/editor/FormatButton.d.ts +0 -8
- package/dist/components/grading-instructions/editor/FormatButton.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/FormatButton.js +0 -23
- package/dist/components/grading-instructions/editor/FormatButton.js.map +0 -1
- package/dist/components/grading-instructions/editor/Formula.d.ts +0 -17
- package/dist/components/grading-instructions/editor/Formula.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/Formula.js +0 -81
- package/dist/components/grading-instructions/editor/Formula.js.map +0 -1
- package/dist/components/grading-instructions/editor/FormulaPopup.d.ts +0 -7
- package/dist/components/grading-instructions/editor/FormulaPopup.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/FormulaPopup.js +0 -49
- package/dist/components/grading-instructions/editor/FormulaPopup.js.map +0 -1
- package/dist/components/grading-instructions/editor/MathPopup.d.ts +0 -10
- package/dist/components/grading-instructions/editor/MathPopup.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/MathPopup.js +0 -94
- package/dist/components/grading-instructions/editor/MathPopup.js.map +0 -1
- package/dist/components/grading-instructions/editor/Table.d.ts +0 -5
- package/dist/components/grading-instructions/editor/Table.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/Table.js +0 -181
- package/dist/components/grading-instructions/editor/Table.js.map +0 -1
- package/dist/components/grading-instructions/editor/math-svg.d.ts +0 -2
- package/dist/components/grading-instructions/editor/math-svg.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/math-svg.js +0 -22
- package/dist/components/grading-instructions/editor/math-svg.js.map +0 -1
- package/dist/components/grading-instructions/editor/math.d.ts +0 -4
- package/dist/components/grading-instructions/editor/math.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/math.js +0 -55
- package/dist/components/grading-instructions/editor/math.js.map +0 -1
- package/dist/components/grading-instructions/prosemirror.d.ts +0 -8
- package/dist/components/grading-instructions/prosemirror.d.ts.map +0 -1
- package/dist/components/grading-instructions/prosemirror.js +0 -108
- package/dist/components/grading-instructions/prosemirror.js.map +0 -1
- package/dist/components/results/isExamFinishPageHook.d.ts +0 -2
- package/dist/components/results/isExamFinishPageHook.d.ts.map +0 -1
- package/dist/components/results/isExamFinishPageHook.js +0 -7
- package/dist/components/results/isExamFinishPageHook.js.map +0 -1
- package/dist/components/shared/CreateAnnotationPopup.d.ts +0 -6
- package/dist/components/shared/CreateAnnotationPopup.d.ts.map +0 -1
- package/dist/components/shared/CreateAnnotationPopup.js +0 -11
- package/dist/components/shared/CreateAnnotationPopup.js.map +0 -1
- package/dist/components/shared/PopupUtils.d.ts +0 -4
- package/dist/components/shared/PopupUtils.d.ts.map +0 -1
- package/dist/components/shared/PopupUtils.js +0 -26
- package/dist/components/shared/PopupUtils.js.map +0 -1
- package/dist/store/listenerMiddleware.d.ts +0 -89
- package/dist/store/listenerMiddleware.d.ts.map +0 -1
- package/dist/store/listenerMiddleware.js +0 -6
- package/dist/store/listenerMiddleware.js.map +0 -1
@@ -1,44 +0,0 @@
|
|
1
|
-
import React, { useMemo, useCallback, useState } from 'react';
|
2
|
-
import { Slate, Editable, withReact } from 'slate-react';
|
3
|
-
import { createEditor } from 'slate';
|
4
|
-
import { withHistory } from 'slate-history';
|
5
|
-
import { insertTable, isTableActive, removeTable } from './SlateUtils';
|
6
|
-
export const SlateTableEditor = () => {
|
7
|
-
const editor = useMemo(() => withHistory(withReact(createEditor())), []);
|
8
|
-
const [value, setValue] = useState([
|
9
|
-
{
|
10
|
-
type: 'paragraph',
|
11
|
-
children: [{ text: 'This is a Slate editor with table functionalities.' }]
|
12
|
-
}
|
13
|
-
]);
|
14
|
-
const renderElement = useCallback((props) => {
|
15
|
-
switch (props.element.type) {
|
16
|
-
case 'table':
|
17
|
-
return React.createElement(Table, { ...props });
|
18
|
-
case 'table-row':
|
19
|
-
return React.createElement(TableRow, { ...props });
|
20
|
-
case 'table-cell':
|
21
|
-
return React.createElement(TableCell, { ...props });
|
22
|
-
default:
|
23
|
-
return React.createElement(DefaultElement, { ...props });
|
24
|
-
}
|
25
|
-
}, []);
|
26
|
-
const insertTableCallback = () => insertTable(editor, 3, 3); // Inserts a 3x3 table
|
27
|
-
const removeTableCallback = () => removeTable(editor);
|
28
|
-
return (React.createElement("div", null,
|
29
|
-
"hello",
|
30
|
-
React.createElement(Slate, { editor: editor, initialValue: value, onChange: newValue => {
|
31
|
-
console.log(newValue);
|
32
|
-
setValue(newValue);
|
33
|
-
} },
|
34
|
-
React.createElement("div", null,
|
35
|
-
React.createElement("button", { onClick: insertTableCallback }, "Insert Table"),
|
36
|
-
React.createElement("button", { onClick: removeTableCallback, disabled: !isTableActive(editor) }, "Remove Table")),
|
37
|
-
React.createElement(Editable, { renderElement: renderElement }))));
|
38
|
-
};
|
39
|
-
const Table = ({ attributes, children }) => (React.createElement("table", null,
|
40
|
-
React.createElement("tbody", { ...attributes }, children)));
|
41
|
-
const TableRow = ({ attributes, children }) => React.createElement("tr", { ...attributes }, children);
|
42
|
-
const TableCell = ({ attributes, children }) => React.createElement("td", { ...attributes }, children);
|
43
|
-
const DefaultElement = ({ attributes, children }) => React.createElement("p", { ...attributes }, children);
|
44
|
-
//# sourceMappingURL=SlateTableEditor.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SlateTableEditor.js","sourceRoot":"","sources":["../../../src/components/grading-instructions/SlateTableEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAe,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAsB,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,YAAY,EAA0B,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAetE,MAAM,CAAC,MAAM,gBAAgB,GAAa,GAAG,EAAE;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACxE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe;QAC/C;YACE,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,oDAAoD,EAAE,CAAC;SAC3E;KACF,CAAC,CAAA;IAEF,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,KAAyB,EAAE,EAAE;QAC9D,QAAQ,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,OAAO;gBACV,OAAO,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAA;YAC7B,KAAK,WAAW;gBACd,OAAO,oBAAC,QAAQ,OAAK,KAAK,GAAI,CAAA;YAChC,KAAK,YAAY;gBACf,OAAO,oBAAC,SAAS,OAA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AC,8BAAO,UAAU,IAAG,QAAQ,CAAK,CAAA"}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { Editor } from 'slate';
|
2
|
-
export declare const insertTable: (editor: Editor, rows: number, columns: number) => void;
|
3
|
-
export declare const isTableActive: (editor: Editor) => boolean;
|
4
|
-
export declare const removeTable: (editor: Editor) => void;
|
5
|
-
//# sourceMappingURL=SlateUtils.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SlateUtils.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/SlateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,OAAO,CAAA;AAG1C,eAAO,MAAM,WAAW,WAAY,MAAM,QAAQ,MAAM,WAAW,MAAM,SAcxE,CAAA;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,YAQ3C,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,SAEzC,CAAA"}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { Transforms, Editor } from 'slate';
|
2
|
-
export const insertTable = (editor, rows, columns) => {
|
3
|
-
const table = {
|
4
|
-
type: 'table',
|
5
|
-
children: Array.from({ length: rows }, () => ({
|
6
|
-
type: 'table-row',
|
7
|
-
children: Array.from({ length: columns }, () => ({
|
8
|
-
type: 'table-cell',
|
9
|
-
children: [{ text: '' }]
|
10
|
-
}))
|
11
|
-
}))
|
12
|
-
};
|
13
|
-
// @ts-expect-error
|
14
|
-
Transforms.insertNodes(editor, table);
|
15
|
-
};
|
16
|
-
export const isTableActive = (editor) => {
|
17
|
-
const [match] = Editor.nodes(editor, {
|
18
|
-
match: n => {
|
19
|
-
console.log(n, typeof n);
|
20
|
-
return n.type === 'table';
|
21
|
-
}
|
22
|
-
});
|
23
|
-
return !!match;
|
24
|
-
};
|
25
|
-
export const removeTable = (editor) => {
|
26
|
-
Transforms.removeNodes(editor, { match: n => n.type === 'table' });
|
27
|
-
};
|
28
|
-
//# sourceMappingURL=S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AAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAE,CAAmB,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAA;AACvF,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1,23 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
2
|
-
import { NodeSpec } from 'prosemirror-model';
|
3
|
-
import React from 'react';
|
4
|
-
export type FormulaEditorState = {
|
5
|
-
pos: number;
|
6
|
-
latex: string;
|
7
|
-
element: Element;
|
8
|
-
};
|
9
|
-
export declare const formulaSchema: NodeSpec;
|
10
|
-
export declare const formulaOutputSchema: NodeSpec;
|
11
|
-
export declare function FormulaButton(props: {
|
12
|
-
setFormulaState: (values: FormulaEditorState) => void;
|
13
|
-
}): React.JSX.Element;
|
14
|
-
export declare class FormulaPlugin extends Plugin {
|
15
|
-
constructor(updateFormulaState: (values: FormulaEditorState) => void);
|
16
|
-
}
|
17
|
-
//# sourceMappingURL=Formula.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Formula.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/Formula.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAiC,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,MAAM,kBAAkB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAA;AAEjF,eAAO,MAAM,aAAa,EAAE,QA6B3B,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,QASjC,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IAAE,eAAe,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;CAAE,qBAoB7F;AAED,qBAAa,aAAc,SAAQ,MAAM;gBAC3B,kBAAkB,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI;CAmBrE"}
|
@@ -1,81 +0,0 @@
|
|
1
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
2
|
-
import { Fragment } from 'prosemirror-model';
|
3
|
-
import { useEditorEventCallback } from '@nytimes/react-prosemirror';
|
4
|
-
import React from 'react';
|
5
|
-
export const formulaSchema = {
|
6
|
-
formula: {
|
7
|
-
inline: true,
|
8
|
-
group: 'inline',
|
9
|
-
atom: true,
|
10
|
-
attrs: {
|
11
|
-
latex: {},
|
12
|
-
mode: { default: '' }
|
13
|
-
},
|
14
|
-
parseDOM: [
|
15
|
-
{
|
16
|
-
tag: '[data-editor-id=e-formula]',
|
17
|
-
getAttrs(dom) {
|
18
|
-
return {
|
19
|
-
latex: dom.textContent,
|
20
|
-
mode: dom.getAttribute('mode')
|
21
|
-
};
|
22
|
-
}
|
23
|
-
}
|
24
|
-
],
|
25
|
-
toDOM(node) {
|
26
|
-
const container = document.createElement('img');
|
27
|
-
if (node.attrs.latex) {
|
28
|
-
container.setAttribute('alt', node.attrs.latex);
|
29
|
-
container.setAttribute('src', `/math.svg?latex=${encodeURIComponent(node.attrs.latex)}`);
|
30
|
-
}
|
31
|
-
return container;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
};
|
35
|
-
export const formulaOutputSchema = {
|
36
|
-
formula: {
|
37
|
-
...formulaSchema.formula,
|
38
|
-
toDOM(node) {
|
39
|
-
const container = document.createElement('span');
|
40
|
-
container.innerHTML = `<e:formula ${node.attrs.mode ? `mode="${node.attrs.mode}"` : ''}>${node.attrs.latex}</e:formula>`;
|
41
|
-
return container.firstElementChild;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
};
|
45
|
-
export function FormulaButton(props) {
|
46
|
-
const onClick = useEditorEventCallback(view => {
|
47
|
-
const transaction = view.state.tr;
|
48
|
-
const formula = view.state.schema.nodes.formula.create({ latex: '' }, Fragment.empty);
|
49
|
-
if (view.dispatch) {
|
50
|
-
view.dispatch(transaction.insert(view.state.selection.to, formula).scrollIntoView());
|
51
|
-
const pos = view.state.selection.to - formula.nodeSize;
|
52
|
-
const element = view.nodeDOM(pos);
|
53
|
-
if (element instanceof Element) {
|
54
|
-
props.setFormulaState({ pos, latex: '', element });
|
55
|
-
}
|
56
|
-
}
|
57
|
-
});
|
58
|
-
return (React.createElement("button", { onClick: onClick, "data-testid": "add-formula" }, "Lis\u00E4\u00E4 kaava"));
|
59
|
-
}
|
60
|
-
export class FormulaPlugin extends Plugin {
|
61
|
-
constructor(updateFormulaState) {
|
62
|
-
super({
|
63
|
-
key: new PluginKey('Formula'),
|
64
|
-
props: {
|
65
|
-
handleClick(view, pos) {
|
66
|
-
const { state } = view;
|
67
|
-
const node = state.doc.nodeAt(pos);
|
68
|
-
if (node && node.type.name === 'formula') {
|
69
|
-
const domNode = view.nodeDOM(pos);
|
70
|
-
if (domNode instanceof Element) {
|
71
|
-
updateFormulaState({ pos, element: domNode, latex: node.attrs.latex });
|
72
|
-
return true;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
return false;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
});
|
79
|
-
}
|
80
|
-
}
|
81
|
-
//# sourceMappingURL=Formula.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Formula.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/Formula.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAiB,Q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AAS,CAAC,SAAS,CAAC;YAC7B,KAAK,EAAE;gBACL,WAAW,CAAC,IAAgB,EAAE,GAAW;oBACvC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;oBACtB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;oBAClC,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;wBACzC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;wBACjC,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;4BAC/B,kBAAkB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAe,EAAE,CAAC,CAAA;4BAChF,OAAO,IAAI,CAAA;wBACb,CAAC;oBACH,CAAC;oBACD,OAAO,KAAK,CAAA;gBACd,CAAC;aACF;SACF,CAAC,CAAA;IACJ,CAAC;CACF"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormulaPopup.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/FormulaPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAG9C,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;CAAE,qBAmDpG"}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { useEditorEventCallback } from '@nytimes/react-prosemirror';
|
3
|
-
import { Popup } from '../../shared/Popup';
|
4
|
-
export function FormulaPopup({ state, onFinish }) {
|
5
|
-
const onValueChange = (text) => {
|
6
|
-
if (text.length && !containsOnlyOneImgTag(text)) {
|
7
|
-
return 'Ainoastaan yksi kaava sallittu';
|
8
|
-
}
|
9
|
-
return null;
|
10
|
-
};
|
11
|
-
const onContentChange = useEditorEventCallback((view, textField) => {
|
12
|
-
const node = view.state.doc.nodeAt(state.pos);
|
13
|
-
const latex = extractLatex(textField) || '';
|
14
|
-
const { schema } = view.state;
|
15
|
-
if (node) {
|
16
|
-
const tr = view.state.tr.replaceWith(state.pos, state.pos + node.nodeSize, schema.node('formula', { ...node.attrs, ...{ latex } }));
|
17
|
-
view.dispatch(tr);
|
18
|
-
}
|
19
|
-
onFinish();
|
20
|
-
});
|
21
|
-
const onDelete = useEditorEventCallback(view => {
|
22
|
-
const node = view.state.doc.nodeAt(state.pos);
|
23
|
-
if (node) {
|
24
|
-
const tr = view.state.tr.delete(state.pos, state.pos + node.nodeSize);
|
25
|
-
view.dispatch(tr);
|
26
|
-
}
|
27
|
-
onFinish();
|
28
|
-
});
|
29
|
-
return (React.createElement(Popup, { element: state.element, initialTextContent: state.latex.length ? `<img alt="${state.latex}" src="/math.svg?latex=${encodeURIComponent(state.latex)}">` : '', onValueChange: onValueChange, onValueSave: onContentChange, enableDelete: true, onDelete: onDelete, onCancel: () => {
|
30
|
-
if (!state.latex.length) {
|
31
|
-
onDelete();
|
32
|
-
}
|
33
|
-
onFinish();
|
34
|
-
} }));
|
35
|
-
}
|
36
|
-
function extractLatex(value) {
|
37
|
-
const latexPattern = /alt="([^&]+)" src=/;
|
38
|
-
const latexMatch = value.match(latexPattern);
|
39
|
-
if (!latexMatch || latexMatch.length < 2) {
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
return decodeURIComponent(latexMatch[1]);
|
43
|
-
}
|
44
|
-
function containsOnlyOneImgTag(htmlString) {
|
45
|
-
const imgTagPattern = /^<img\s+[^>]*>$/g;
|
46
|
-
const matches = htmlString.trim().match(imgTagPattern);
|
47
|
-
return matches && matches.length === 1;
|
48
|
-
}
|
49
|
-
//# sourceMappingURL=FormulaPopup.js.map
|
@@ -1 +0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C,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAkB;IAC/C,MAAM,aAAa,GAAG,kBAAkB,CAAA;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACtD,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAA;AACxC,CAAC"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { EditorView } from 'prosemirror-view';
|
3
|
-
export declare function MathPopup({ latex, update, pos, element, onCancel }: {
|
4
|
-
latex: string;
|
5
|
-
update: (view: EditorView, pos: number, latex: string) => void;
|
6
|
-
pos: number;
|
7
|
-
element: Element;
|
8
|
-
onCancel: () => void;
|
9
|
-
}): React.JSX.Element;
|
10
|
-
//# sourceMappingURL=MathPopup.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"MathPopup.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/MathPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9D,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,IAAI,CAAA;CACrB,qBAkGA"}
|
@@ -1,94 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
2
|
-
import { makeRichText } from 'rich-text-editor';
|
3
|
-
import { useEditorEventCallback } from '@nytimes/react-prosemirror';
|
4
|
-
export function MathPopup({ latex, update, pos, element, onCancel }) {
|
5
|
-
const popupRef = React.createRef();
|
6
|
-
const textAreaRef = React.createRef();
|
7
|
-
const initialValue = latex.length ? `<img alt="${latex}" src="/math.svg?latex=${latex}">` : '';
|
8
|
-
const [comment, setComment] = useState(initialValue);
|
9
|
-
const [saveEnabled, setSaveEnabled] = useState(false);
|
10
|
-
const [dataError, setDataError] = useState('');
|
11
|
-
useEffect(() => {
|
12
|
-
if (textAreaRef.current) {
|
13
|
-
textAreaRef.current.innerHTML = latex.length ? `<img alt="${latex}" src="/math.svg?latex=${latex}">` : '';
|
14
|
-
makeRichText(textAreaRef.current, {
|
15
|
-
locale: 'FI',
|
16
|
-
screenshotSaver: () => Promise.resolve('')
|
17
|
-
}, value => {
|
18
|
-
if (value.answerHTML.length && !containsOnlyOneImgTag(value.answerHTML)) {
|
19
|
-
setDataError('Vain kaavat sallitaan kaavaneditointinäkymässä');
|
20
|
-
}
|
21
|
-
else {
|
22
|
-
setDataError('');
|
23
|
-
}
|
24
|
-
setComment(value.answerHTML);
|
25
|
-
setSaveEnabled(value.answerHTML.trim().length > 0);
|
26
|
-
});
|
27
|
-
showAndPositionElement(element, popupRef);
|
28
|
-
}
|
29
|
-
}, [latex]);
|
30
|
-
const closeEditor = () => {
|
31
|
-
onCancel();
|
32
|
-
closeMathEditor(textAreaRef.current);
|
33
|
-
};
|
34
|
-
const extractLatex = (value) => {
|
35
|
-
const latexPattern = /alt="([^&]+)" src=/;
|
36
|
-
const latexMatch = value.match(latexPattern);
|
37
|
-
if (!latexMatch || latexMatch.length < 2) {
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
return decodeURIComponent(latexMatch[1]);
|
41
|
-
};
|
42
|
-
const onShit = useEditorEventCallback((view, dummy) => {
|
43
|
-
if (pos) {
|
44
|
-
const latex = dummy ? extractLatex(dummy) || '' : '';
|
45
|
-
update(view, pos, latex);
|
46
|
-
}
|
47
|
-
});
|
48
|
-
return (React.createElement("div", { className: "annotation-popup", style: { position: 'absolute', opacity: 1 }, ref: popupRef, "data-testid": "annotation-popup" },
|
49
|
-
React.createElement("div", { className: "comment-content", "data-testid": "edit-comment", role: "textbox", "aria-multiline": "true", ref: textAreaRef }),
|
50
|
-
dataError && React.createElement("span", null, dataError),
|
51
|
-
React.createElement("span", { className: "comment-button-area" },
|
52
|
-
React.createElement("span", null,
|
53
|
-
React.createElement("button", { className: "button", onClick: e => {
|
54
|
-
e.stopPropagation();
|
55
|
-
closeMathEditor(textAreaRef.current);
|
56
|
-
onShit(comment);
|
57
|
-
}, "data-testid": "save-comment", disabled: !saveEnabled }, "Tallenna"),
|
58
|
-
React.createElement("button", { className: "button text-button", onClick: closeEditor }, "Peru"),
|
59
|
-
React.createElement("button", { className: "button text-button", onClick: () => {
|
60
|
-
closeMathEditor(textAreaRef.current);
|
61
|
-
onShit('');
|
62
|
-
} }, "Poista")))));
|
63
|
-
}
|
64
|
-
function showAndPositionElement(mark, popupRef) {
|
65
|
-
const popup = popupRef.current;
|
66
|
-
if (mark && popup) {
|
67
|
-
const style = popup.style;
|
68
|
-
const markRect = mark === null || mark === void 0 ? void 0 : mark.getBoundingClientRect();
|
69
|
-
const popupRect = popup.getBoundingClientRect();
|
70
|
-
const top = markRect.height + markRect.top + window.scrollY;
|
71
|
-
const windowWidth = window.innerWidth;
|
72
|
-
style.top = `${String(top)}px`;
|
73
|
-
style.opacity = '1';
|
74
|
-
const popupHitsWindowRight = markRect.left + popupRect.width > windowWidth;
|
75
|
-
if (popupHitsWindowRight) {
|
76
|
-
style.left = `${markRect.right - popupRect.width}px`;
|
77
|
-
}
|
78
|
-
else {
|
79
|
-
style.left = `${markRect.left}px`;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
function closeMathEditor(element) {
|
84
|
-
// rich-text-editor does not properly support several rich-text-editor instances created at different times.
|
85
|
-
// In order to close math editor that is open, we need to dispatch events like this.
|
86
|
-
element.dispatchEvent(new Event('focus', { bubbles: true, cancelable: true }));
|
87
|
-
element.dispatchEvent(new Event('blur', { bubbles: true, cancelable: true }));
|
88
|
-
}
|
89
|
-
function containsOnlyOneImgTag(htmlString) {
|
90
|
-
const imgTagPattern = /^<img\s+[^>]*>$/g;
|
91
|
-
const matches = htmlString.trim().match(imgTagPattern);
|
92
|
-
return matches && matches.length === 1;
|
93
|
-
}
|
94
|
-
//# sourceMappingURL=MathPopup.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"MathPopup.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/MathPopup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAGnE,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EAOT;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAA;IAClD,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAA;IACrD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,KAAK,0BAA0B,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9F,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAS,YAAY,CAAC,CAAA;IAC5D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAA;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAS,EAAE,CAAC,CAAA;IACtD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,WAAW,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A;AAC/E,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAkB;IAC/C,MAAM,aAAa,GAAG,kBAAkB,CAAA;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IACtD,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAA;AACxC,CAAC"}
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1,181 +0,0 @@
|
|
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
|