@digabi/exam-engine-core 22.1.3-alpha.1 → 22.1.3-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/grading-instructions/EditableGradingInstruction.d.ts.map +1 -1
- package/dist/components/grading-instructions/EditableGradingInstruction.js +26 -5
- package/dist/components/grading-instructions/EditableGradingInstruction.js.map +1 -1
- package/dist/components/grading-instructions/editor/CurrentElement.d.ts +2 -0
- package/dist/components/grading-instructions/editor/CurrentElement.d.ts.map +1 -0
- package/dist/components/grading-instructions/editor/CurrentElement.js +8 -0
- package/dist/components/grading-instructions/editor/CurrentElement.js.map +1 -0
- package/dist/components/grading-instructions/editor/CurrentLocalization.d.ts +5 -0
- package/dist/components/grading-instructions/editor/CurrentLocalization.d.ts.map +1 -0
- package/dist/components/grading-instructions/editor/CurrentLocalization.js +17 -0
- package/dist/components/grading-instructions/editor/CurrentLocalization.js.map +1 -0
- package/dist/main-bundle.js +1 -1
- package/dist/main.css +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EditableGradingInstruction.d.ts","sourceRoot":"","sources":["../../../src/components/grading-instructions/EditableGradingInstruction.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,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;AA8CnD,iBAAS,0BAA0B,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,qBAkEpE;AAED,eAAe,0BAA0B,CAAA"}
|
@@ -13,6 +13,7 @@ import FormatButton from './editor/FormatButton';
|
|
13
13
|
import { NbspButton, nbspPlugin } from './editor/NBSP';
|
14
14
|
import { spanWithNowrap } from './editor/spanWithNowrap';
|
15
15
|
import { localization } from './editor/localization';
|
16
|
+
import { CurrentLocalization } from './editor/CurrentLocalization';
|
16
17
|
const schema = new Schema({
|
17
18
|
nodes: baseSchema.spec.nodes.append(formulaSchema).append(tableSchema),
|
18
19
|
marks: baseSchema.spec.marks.append(spanWithNowrap).append(localization(true))
|
@@ -21,13 +22,14 @@ const outputSchema = new Schema({
|
|
21
22
|
nodes: baseSchema.spec.nodes.append(formulaOutputSchema).append(tableSchema),
|
22
23
|
marks: baseSchema.spec.marks.append(spanWithNowrap).append(localization(false))
|
23
24
|
});
|
24
|
-
function Menu(
|
25
|
-
return (React.createElement(
|
25
|
+
function Menu({ setFormulaState, currentElement }) {
|
26
|
+
return (React.createElement("div", { className: "ProseMirror-menu" },
|
26
27
|
React.createElement(FormatButton, { markName: "strong", displayName: "Bold" }),
|
27
28
|
React.createElement(FormatButton, { markName: "em", displayName: "Italic" }),
|
28
29
|
React.createElement(TableMenu, null),
|
29
|
-
React.createElement(FormulaButton, { setFormulaState:
|
30
|
-
React.createElement(NbspButton, null)
|
30
|
+
React.createElement(FormulaButton, { setFormulaState: setFormulaState }),
|
31
|
+
React.createElement(NbspButton, null),
|
32
|
+
React.createElement(CurrentLocalization, { currentElement: currentElement })));
|
31
33
|
}
|
32
34
|
function EditableGradingInstruction({ element }) {
|
33
35
|
const { onContentChange } = useContext(GradingInstructionContext);
|
@@ -36,7 +38,26 @@ function EditableGradingInstruction({ element }) {
|
|
36
38
|
const [formulaState, setFormulaState] = useState(null);
|
37
39
|
const formulaPlugin = new FormulaPlugin(setFormulaState);
|
38
40
|
const [state, setState] = useState(EditorState.create({ schema, doc, plugins: [keymap(baseKeymap), formulaPlugin, nbspPlugin] }));
|
41
|
+
const [currentElement, setCurrentElement] = useState(null);
|
42
|
+
function findElementFromPosition(rootNode, pos) {
|
43
|
+
var _a;
|
44
|
+
if (rootNode == null) {
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
const node = rootNode.nodeAt(pos);
|
48
|
+
if (!node) {
|
49
|
+
return null;
|
50
|
+
}
|
51
|
+
const serializedNode = DOMSerializer.fromSchema(outputSchema).serializeNode(node);
|
52
|
+
const element = serializedNode;
|
53
|
+
if (((_a = element.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) == 'e:localization') {
|
54
|
+
return element;
|
55
|
+
}
|
56
|
+
const parent = serializedNode.parentNode;
|
57
|
+
return findElementFromPosition(parent, pos);
|
58
|
+
}
|
39
59
|
return (React.createElement(ProseMirror, { mount: mount, state: state, dispatchTransaction: tr => {
|
60
|
+
setCurrentElement(findElementFromPosition(tr.doc, tr.selection.from));
|
40
61
|
setState(s => {
|
41
62
|
var _a;
|
42
63
|
const newContent = s.apply(tr);
|
@@ -56,7 +77,7 @@ function EditableGradingInstruction({ element }) {
|
|
56
77
|
return newContent;
|
57
78
|
});
|
58
79
|
} },
|
59
|
-
React.createElement(Menu, { setFormulaState: setFormulaState }),
|
80
|
+
React.createElement(Menu, { setFormulaState: setFormulaState, currentElement: currentElement }),
|
60
81
|
React.createElement("div", { ref: setMount }),
|
61
82
|
formulaState && (React.createElement(FormulaPopup, { state: formulaState, onFinish: () => {
|
62
83
|
setFormulaState(null);
|
@@ -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,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,
|
1
|
+
{"version":3,"file":"EditableGradingInstruction.js","sourceRoot":"","s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AAC,CAAA;gBAC9B,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;oBAClB,MAAM,QAAQ,GAAG,aAAa,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;oBACzF,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;oBACzC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;oBACzB,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAA;oBAC/C,IAAI,eAAe,EAAE,CAAC;wBACpB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS;6BAC5B,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC;6BAC5B,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;6BACzB,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;wBAC5B,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;oBAClC,CAAC;gBACH,CAAC;gBACD,OAAO,UAAU,CAAA;YACnB,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,oBAAC,IAAI,IAAC,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,GAAI;QAC1E,6BAAK,GAAG,EAAE,QAAQ,GAAI;QAErB,YAAY,IAAI,CACf,oBAAC,YAAY,IACX,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,GAAG,EAAE;gBACb,eAAe,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC,GACD,CACH,CACW,CACf,CAAA;AACH,CAAC;AAED,eAAe,0BAA0B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CurrentElement.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/CurrentElement.tsx"],"names":[],"mappings":""}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
function CurrentElement({ currentElement }) {
|
3
|
+
return (React.createElement("div", null,
|
4
|
+
props.currentElement.getAttribute('lang'),
|
5
|
+
" ",
|
6
|
+
props.currentElement.getAttribute('exam-type')));
|
7
|
+
}
|
8
|
+
//# sourceMappingURL=CurrentElement.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CurrentElement.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/CurrentElement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,SAAS,cAAc,CAAC,EAAE,cAAc,EAAsC;IAC5E,OAAO,CACL;QACG,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC;;QAAG,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CACvF,CACP,CAAA;AACH,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CurrentLocalization.d.ts","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/CurrentLocalization.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,wBAAgB,mBAAmB,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,qBAYzF"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export function CurrentLocalization({ currentElement }) {
|
3
|
+
var _a;
|
4
|
+
const locale = currentElement === null || currentElement === void 0 ? void 0 : currentElement.getAttribute('lang');
|
5
|
+
const lang = (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
6
|
+
const examType = currentElement === null || currentElement === void 0 ? void 0 : currentElement.getAttribute('exam-type');
|
7
|
+
return (React.createElement("span", { className: "element-target" },
|
8
|
+
React.createElement("span", null, "Kohdennus:"),
|
9
|
+
React.createElement("span", { className: "enabled" }, lang ? `${lang} yleinen` : 'Yleinen'),
|
10
|
+
React.createElement("span", { className: examType == 'hearing-impaired' ? 'enabled' : 'disabled' },
|
11
|
+
lang,
|
12
|
+
" / KV"),
|
13
|
+
React.createElement("span", { className: examType == 'visually-impaired' ? 'enabled' : 'disabled' },
|
14
|
+
lang,
|
15
|
+
" / NV")));
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=CurrentLocalization.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CurrentLocalization.js","sourceRoot":"","sources":["../../../../src/components/grading-instructions/editor/CurrentLocalization.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,UAAU,mBAAmB,CAAC,EAAE,cAAc,EAAsC;;IACxF,MAAM,MAAM,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,YAAY,CAAC,MAAM,CAAC,CAAA;IACnD,MAAM,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,0CAAE,WAAW,EAAE,CAAA;IACjD,MAAM,QAAQ,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,YAAY,CAAC,WAAW,CAAC,CAAA;IAC1D,OAAO,CACL,8BAAM,SAAS,EAAC,gBAAgB;QAC9B,+CAAuB;QACvB,8BAAM,SAAS,EAAC,SAAS,IAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,CAAQ;QACvE,8BAAM,SAAS,EAAE,QAAQ,IAAI,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;YAAG,IAAI;oBAAa;QAC5F,8BAAM,SAAS,EAAE,QAAQ,IAAI,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;YAAG,IAAI;oBAAa,CACxF,CACR,CAAA;AACH,CAAC"}
|