@examind/block-editor 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +140 -16
- package/dist/index.mjs +140 -16
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3578,6 +3578,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3578
3578
|
node.__id,
|
|
3579
3579
|
node.__spaceType,
|
|
3580
3580
|
node.__matches,
|
|
3581
|
+
node.__useRegex,
|
|
3581
3582
|
node.__caseSensitive,
|
|
3582
3583
|
node.__errorsAllowed,
|
|
3583
3584
|
node.__minDecimals,
|
|
@@ -3593,6 +3594,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3593
3594
|
id,
|
|
3594
3595
|
matches,
|
|
3595
3596
|
spaceType,
|
|
3597
|
+
useRegex,
|
|
3596
3598
|
caseSensitive,
|
|
3597
3599
|
errorsAllowed,
|
|
3598
3600
|
minDecimals,
|
|
@@ -3604,6 +3606,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3604
3606
|
id,
|
|
3605
3607
|
spaceType,
|
|
3606
3608
|
matches,
|
|
3609
|
+
useRegex,
|
|
3607
3610
|
caseSensitive,
|
|
3608
3611
|
errorsAllowed,
|
|
3609
3612
|
minDecimals,
|
|
@@ -3611,12 +3614,13 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3611
3614
|
distractors
|
|
3612
3615
|
);
|
|
3613
3616
|
}
|
|
3614
|
-
constructor(spaceName, id, spaceType, matches, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors, isPreviewMode, key) {
|
|
3617
|
+
constructor(spaceName, id, spaceType, matches, useRegex, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors, isPreviewMode, key) {
|
|
3615
3618
|
super(key);
|
|
3616
3619
|
this.__spaceName = spaceName;
|
|
3617
3620
|
this.__id = id || (0, import_nanoid.nanoid)();
|
|
3618
3621
|
this.__matches = matches || spaceName;
|
|
3619
3622
|
this.__spaceType = spaceType || "Text";
|
|
3623
|
+
this.__useRegex = useRegex;
|
|
3620
3624
|
this.__caseSensitive = caseSensitive;
|
|
3621
3625
|
this.__errorsAllowed = errorsAllowed;
|
|
3622
3626
|
this.__minDecimals = minDecimals;
|
|
@@ -3631,6 +3635,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3631
3635
|
id: this.__id,
|
|
3632
3636
|
matches: this.__matches,
|
|
3633
3637
|
spaceType: this.__spaceType,
|
|
3638
|
+
useRegex: this.__useRegex,
|
|
3634
3639
|
caseSensitive: this.__caseSensitive,
|
|
3635
3640
|
errorsAllowed: this.__errorsAllowed,
|
|
3636
3641
|
minDecimals: this.__minDecimals,
|
|
@@ -3698,6 +3703,13 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3698
3703
|
const writable = this.getWritable();
|
|
3699
3704
|
writable.__spaceType = spaceType;
|
|
3700
3705
|
}
|
|
3706
|
+
getUseRegex() {
|
|
3707
|
+
return this.__useRegex;
|
|
3708
|
+
}
|
|
3709
|
+
setUseRegex(useRegex) {
|
|
3710
|
+
const writable = this.getWritable();
|
|
3711
|
+
writable.__useRegex = useRegex;
|
|
3712
|
+
}
|
|
3701
3713
|
getCaseSensitive() {
|
|
3702
3714
|
return this.__caseSensitive;
|
|
3703
3715
|
}
|
|
@@ -3741,13 +3753,14 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends import_lexi
|
|
|
3741
3753
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(FillInTheBlankSpaceComponent, { nodeKey: this.__key });
|
|
3742
3754
|
}
|
|
3743
3755
|
};
|
|
3744
|
-
function $createFillInTheBlankSpaceNode(spaceName, id, spaceType, matches, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors) {
|
|
3756
|
+
function $createFillInTheBlankSpaceNode(spaceName, id, spaceType, matches, useRegex, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors) {
|
|
3745
3757
|
window.dispatchEvent(new CustomEvent(RESET_EDITING_MODE));
|
|
3746
3758
|
const spaceNode = new FillInTheBlankSpaceNode(
|
|
3747
3759
|
spaceName,
|
|
3748
3760
|
id,
|
|
3749
3761
|
spaceType,
|
|
3750
3762
|
matches,
|
|
3763
|
+
useRegex,
|
|
3751
3764
|
caseSensitive,
|
|
3752
3765
|
errorsAllowed,
|
|
3753
3766
|
minDecimals,
|
|
@@ -4274,6 +4287,35 @@ function FillInTheBlankSpaceSettings(props) {
|
|
|
4274
4287
|
}
|
|
4275
4288
|
) }),
|
|
4276
4289
|
foundNode.getSpaceType() === "Text" && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
4290
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4291
|
+
Checkbox,
|
|
4292
|
+
{
|
|
4293
|
+
size: "small",
|
|
4294
|
+
label: "Use Regex",
|
|
4295
|
+
name: "use-regex",
|
|
4296
|
+
checked: !!foundNode.getUseRegex(),
|
|
4297
|
+
onChange: (checked) => {
|
|
4298
|
+
activeEditorRef.current?.update(
|
|
4299
|
+
() => {
|
|
4300
|
+
const targetNode = (0, import_lexical20.$getNodeByKey)(nodeKey);
|
|
4301
|
+
if (targetNode && $isFillInTheBlankSpaceNode(targetNode)) {
|
|
4302
|
+
targetNode.setUseRegex(checked);
|
|
4303
|
+
}
|
|
4304
|
+
},
|
|
4305
|
+
{
|
|
4306
|
+
onUpdate: () => {
|
|
4307
|
+
activeEditorRef.current?.getEditorState().read(() => {
|
|
4308
|
+
const targetNode = (0, import_lexical20.$getNodeByKey)(nodeKey);
|
|
4309
|
+
if (targetNode && $isFillInTheBlankSpaceNode(targetNode)) {
|
|
4310
|
+
setFoundNode(targetNode);
|
|
4311
|
+
}
|
|
4312
|
+
});
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
);
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
) }),
|
|
4277
4319
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4278
4320
|
Checkbox,
|
|
4279
4321
|
{
|
|
@@ -4291,7 +4333,7 @@ function FillInTheBlankSpaceSettings(props) {
|
|
|
4291
4333
|
}
|
|
4292
4334
|
}
|
|
4293
4335
|
) }),
|
|
4294
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4336
|
+
!foundNode.getUseRegex() && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4295
4337
|
TextInput,
|
|
4296
4338
|
{
|
|
4297
4339
|
id: "errors-allowed",
|
|
@@ -7288,12 +7330,42 @@ function FinancialStatementQuestionComponent(props) {
|
|
|
7288
7330
|
} else if (rowItem.type === "Line") {
|
|
7289
7331
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { "data-selectable": "true", children: [
|
|
7290
7332
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { "data-selectable": "true", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7291
|
-
"
|
|
7333
|
+
"div",
|
|
7292
7334
|
{
|
|
7293
7335
|
style: {
|
|
7294
7336
|
paddingLeft: `calc(1em * ${rowItem.depth})`
|
|
7295
7337
|
},
|
|
7296
|
-
children:
|
|
7338
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7339
|
+
import_LexicalNestedComposer.LexicalNestedComposer,
|
|
7340
|
+
{
|
|
7341
|
+
initialEditor: rowItem.entry,
|
|
7342
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(NestedEditor, { nodeKey, children: [
|
|
7343
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SettingsPanelNestedAgentPlugin, {}),
|
|
7344
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7345
|
+
import_LexicalRichTextPlugin.RichTextPlugin,
|
|
7346
|
+
{
|
|
7347
|
+
contentEditable: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NestedContentEditable, {}),
|
|
7348
|
+
ErrorBoundary: import_LexicalErrorBoundary.LexicalErrorBoundary,
|
|
7349
|
+
placeholder: null
|
|
7350
|
+
},
|
|
7351
|
+
nodeKey
|
|
7352
|
+
),
|
|
7353
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7354
|
+
import_LexicalHistoryPlugin2.HistoryPlugin,
|
|
7355
|
+
{
|
|
7356
|
+
externalHistoryState: historyState
|
|
7357
|
+
}
|
|
7358
|
+
),
|
|
7359
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7360
|
+
TypeaheadVariableAgentPlugin,
|
|
7361
|
+
{
|
|
7362
|
+
decoratorNode: FinancialStatementQuestionNode
|
|
7363
|
+
}
|
|
7364
|
+
),
|
|
7365
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(VariableComponentPlugin, {})
|
|
7366
|
+
] })
|
|
7367
|
+
}
|
|
7368
|
+
)
|
|
7297
7369
|
}
|
|
7298
7370
|
) }),
|
|
7299
7371
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
@@ -7348,10 +7420,40 @@ function FinancialStatementQuestionComponent(props) {
|
|
|
7348
7420
|
(distractorItem) => {
|
|
7349
7421
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { "data-selectable": "true", children: [
|
|
7350
7422
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { "data-selectable": "true", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7351
|
-
"
|
|
7423
|
+
"div",
|
|
7352
7424
|
{
|
|
7353
7425
|
style: { color: "var(--sl-color-red-500)" },
|
|
7354
|
-
children:
|
|
7426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7427
|
+
import_LexicalNestedComposer.LexicalNestedComposer,
|
|
7428
|
+
{
|
|
7429
|
+
initialEditor: distractorItem.entry,
|
|
7430
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(NestedEditor, { nodeKey, children: [
|
|
7431
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(SettingsPanelNestedAgentPlugin, {}),
|
|
7432
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7433
|
+
import_LexicalRichTextPlugin.RichTextPlugin,
|
|
7434
|
+
{
|
|
7435
|
+
contentEditable: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(NestedContentEditable, {}),
|
|
7436
|
+
ErrorBoundary: import_LexicalErrorBoundary.LexicalErrorBoundary,
|
|
7437
|
+
placeholder: null
|
|
7438
|
+
},
|
|
7439
|
+
nodeKey
|
|
7440
|
+
),
|
|
7441
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7442
|
+
import_LexicalHistoryPlugin2.HistoryPlugin,
|
|
7443
|
+
{
|
|
7444
|
+
externalHistoryState: historyState
|
|
7445
|
+
}
|
|
7446
|
+
),
|
|
7447
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
7448
|
+
TypeaheadVariableAgentPlugin,
|
|
7449
|
+
{
|
|
7450
|
+
decoratorNode: FinancialStatementQuestionNode
|
|
7451
|
+
}
|
|
7452
|
+
),
|
|
7453
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(VariableComponentPlugin, {})
|
|
7454
|
+
] })
|
|
7455
|
+
}
|
|
7456
|
+
)
|
|
7355
7457
|
}
|
|
7356
7458
|
) }),
|
|
7357
7459
|
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { "data-selectable": "true" })
|
|
@@ -7447,18 +7549,21 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7447
7549
|
continue;
|
|
7448
7550
|
}
|
|
7449
7551
|
if (isSerializableFinancialStatementLine(row)) {
|
|
7552
|
+
const entryNestedEditor = (0, import_lexical35.createEditor)();
|
|
7553
|
+
const entryNestedEditorState = entryNestedEditor.parseEditorState(row.entry.editorState);
|
|
7554
|
+
if (!entryNestedEditorState.isEmpty()) {
|
|
7555
|
+
entryNestedEditor.setEditorState(entryNestedEditorState);
|
|
7556
|
+
}
|
|
7450
7557
|
const amountNestedEditor = (0, import_lexical35.createEditor)();
|
|
7451
|
-
const
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
if (!editorState2.isEmpty()) {
|
|
7455
|
-
amountNestedEditor.setEditorState(editorState2);
|
|
7558
|
+
const amountNestedEditorState = amountNestedEditor.parseEditorState(row.amount.editorState);
|
|
7559
|
+
if (!amountNestedEditorState.isEmpty()) {
|
|
7560
|
+
amountNestedEditor.setEditorState(amountNestedEditorState);
|
|
7456
7561
|
}
|
|
7457
7562
|
restoredRows.push({
|
|
7458
7563
|
type: row.type,
|
|
7459
7564
|
id: row.id,
|
|
7460
7565
|
depth: row.depth,
|
|
7461
|
-
entry:
|
|
7566
|
+
entry: entryNestedEditor,
|
|
7462
7567
|
amount: amountNestedEditor,
|
|
7463
7568
|
isEntryHint: row.isEntryHint,
|
|
7464
7569
|
isAmountHint: row.isAmountHint,
|
|
@@ -7467,12 +7572,26 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7467
7572
|
continue;
|
|
7468
7573
|
}
|
|
7469
7574
|
}
|
|
7575
|
+
const restoredDistractors = [];
|
|
7576
|
+
for (const distractor of serializedNode.distractors) {
|
|
7577
|
+
const entryNestedEditor = (0, import_lexical35.createEditor)();
|
|
7578
|
+
const entryNestedEditorState = entryNestedEditor.parseEditorState(
|
|
7579
|
+
distractor.entry.editorState
|
|
7580
|
+
);
|
|
7581
|
+
if (!entryNestedEditorState.isEmpty()) {
|
|
7582
|
+
entryNestedEditor.setEditorState(entryNestedEditorState);
|
|
7583
|
+
}
|
|
7584
|
+
restoredDistractors.push({
|
|
7585
|
+
id: distractor.id,
|
|
7586
|
+
entry: entryNestedEditor
|
|
7587
|
+
});
|
|
7588
|
+
}
|
|
7470
7589
|
return $createFinancialStatementQuestionNode(
|
|
7471
7590
|
serializedNode.points,
|
|
7472
7591
|
headerNestedEditor,
|
|
7473
7592
|
serializedNode.columnHeaders,
|
|
7474
7593
|
restoredRows,
|
|
7475
|
-
|
|
7594
|
+
restoredDistractors,
|
|
7476
7595
|
serializedNode.id
|
|
7477
7596
|
);
|
|
7478
7597
|
}
|
|
@@ -7497,7 +7616,7 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7497
7616
|
type: row.type,
|
|
7498
7617
|
id: row.id,
|
|
7499
7618
|
depth: row.depth,
|
|
7500
|
-
entry: row.entry,
|
|
7619
|
+
entry: row.entry.toJSON(),
|
|
7501
7620
|
amount: row.amount.toJSON(),
|
|
7502
7621
|
isEntryHint: row.isEntryHint,
|
|
7503
7622
|
isAmountHint: row.isAmountHint,
|
|
@@ -7506,7 +7625,12 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7506
7625
|
}
|
|
7507
7626
|
throw new Error("Invalid row type");
|
|
7508
7627
|
}).filter(Boolean),
|
|
7509
|
-
distractors: this.__distractors
|
|
7628
|
+
distractors: this.__distractors.map((distractor) => {
|
|
7629
|
+
return {
|
|
7630
|
+
id: distractor.id,
|
|
7631
|
+
entry: distractor.entry.toJSON()
|
|
7632
|
+
};
|
|
7633
|
+
}),
|
|
7510
7634
|
type: TYPE_NAME4,
|
|
7511
7635
|
version: 1
|
|
7512
7636
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -3657,6 +3657,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3657
3657
|
node.__id,
|
|
3658
3658
|
node.__spaceType,
|
|
3659
3659
|
node.__matches,
|
|
3660
|
+
node.__useRegex,
|
|
3660
3661
|
node.__caseSensitive,
|
|
3661
3662
|
node.__errorsAllowed,
|
|
3662
3663
|
node.__minDecimals,
|
|
@@ -3672,6 +3673,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3672
3673
|
id,
|
|
3673
3674
|
matches,
|
|
3674
3675
|
spaceType,
|
|
3676
|
+
useRegex,
|
|
3675
3677
|
caseSensitive,
|
|
3676
3678
|
errorsAllowed,
|
|
3677
3679
|
minDecimals,
|
|
@@ -3683,6 +3685,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3683
3685
|
id,
|
|
3684
3686
|
spaceType,
|
|
3685
3687
|
matches,
|
|
3688
|
+
useRegex,
|
|
3686
3689
|
caseSensitive,
|
|
3687
3690
|
errorsAllowed,
|
|
3688
3691
|
minDecimals,
|
|
@@ -3690,12 +3693,13 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3690
3693
|
distractors
|
|
3691
3694
|
);
|
|
3692
3695
|
}
|
|
3693
|
-
constructor(spaceName, id, spaceType, matches, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors, isPreviewMode, key) {
|
|
3696
|
+
constructor(spaceName, id, spaceType, matches, useRegex, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors, isPreviewMode, key) {
|
|
3694
3697
|
super(key);
|
|
3695
3698
|
this.__spaceName = spaceName;
|
|
3696
3699
|
this.__id = id || nanoid();
|
|
3697
3700
|
this.__matches = matches || spaceName;
|
|
3698
3701
|
this.__spaceType = spaceType || "Text";
|
|
3702
|
+
this.__useRegex = useRegex;
|
|
3699
3703
|
this.__caseSensitive = caseSensitive;
|
|
3700
3704
|
this.__errorsAllowed = errorsAllowed;
|
|
3701
3705
|
this.__minDecimals = minDecimals;
|
|
@@ -3710,6 +3714,7 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3710
3714
|
id: this.__id,
|
|
3711
3715
|
matches: this.__matches,
|
|
3712
3716
|
spaceType: this.__spaceType,
|
|
3717
|
+
useRegex: this.__useRegex,
|
|
3713
3718
|
caseSensitive: this.__caseSensitive,
|
|
3714
3719
|
errorsAllowed: this.__errorsAllowed,
|
|
3715
3720
|
minDecimals: this.__minDecimals,
|
|
@@ -3777,6 +3782,13 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3777
3782
|
const writable = this.getWritable();
|
|
3778
3783
|
writable.__spaceType = spaceType;
|
|
3779
3784
|
}
|
|
3785
|
+
getUseRegex() {
|
|
3786
|
+
return this.__useRegex;
|
|
3787
|
+
}
|
|
3788
|
+
setUseRegex(useRegex) {
|
|
3789
|
+
const writable = this.getWritable();
|
|
3790
|
+
writable.__useRegex = useRegex;
|
|
3791
|
+
}
|
|
3780
3792
|
getCaseSensitive() {
|
|
3781
3793
|
return this.__caseSensitive;
|
|
3782
3794
|
}
|
|
@@ -3820,13 +3832,14 @@ var FillInTheBlankSpaceNode = class _FillInTheBlankSpaceNode extends DecoratorNo
|
|
|
3820
3832
|
return /* @__PURE__ */ jsx37(FillInTheBlankSpaceComponent, { nodeKey: this.__key });
|
|
3821
3833
|
}
|
|
3822
3834
|
};
|
|
3823
|
-
function $createFillInTheBlankSpaceNode(spaceName, id, spaceType, matches, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors) {
|
|
3835
|
+
function $createFillInTheBlankSpaceNode(spaceName, id, spaceType, matches, useRegex, caseSensitive, errorsAllowed, minDecimals, errorTolerance, distractors) {
|
|
3824
3836
|
window.dispatchEvent(new CustomEvent(RESET_EDITING_MODE));
|
|
3825
3837
|
const spaceNode = new FillInTheBlankSpaceNode(
|
|
3826
3838
|
spaceName,
|
|
3827
3839
|
id,
|
|
3828
3840
|
spaceType,
|
|
3829
3841
|
matches,
|
|
3842
|
+
useRegex,
|
|
3830
3843
|
caseSensitive,
|
|
3831
3844
|
errorsAllowed,
|
|
3832
3845
|
minDecimals,
|
|
@@ -4373,6 +4386,35 @@ function FillInTheBlankSpaceSettings(props) {
|
|
|
4373
4386
|
}
|
|
4374
4387
|
) }),
|
|
4375
4388
|
foundNode.getSpaceType() === "Text" && /* @__PURE__ */ jsxs10(Fragment16, { children: [
|
|
4389
|
+
/* @__PURE__ */ jsx41("div", { children: /* @__PURE__ */ jsx41(
|
|
4390
|
+
Checkbox,
|
|
4391
|
+
{
|
|
4392
|
+
size: "small",
|
|
4393
|
+
label: "Use Regex",
|
|
4394
|
+
name: "use-regex",
|
|
4395
|
+
checked: !!foundNode.getUseRegex(),
|
|
4396
|
+
onChange: (checked) => {
|
|
4397
|
+
activeEditorRef.current?.update(
|
|
4398
|
+
() => {
|
|
4399
|
+
const targetNode = $getNodeByKey15(nodeKey);
|
|
4400
|
+
if (targetNode && $isFillInTheBlankSpaceNode(targetNode)) {
|
|
4401
|
+
targetNode.setUseRegex(checked);
|
|
4402
|
+
}
|
|
4403
|
+
},
|
|
4404
|
+
{
|
|
4405
|
+
onUpdate: () => {
|
|
4406
|
+
activeEditorRef.current?.getEditorState().read(() => {
|
|
4407
|
+
const targetNode = $getNodeByKey15(nodeKey);
|
|
4408
|
+
if (targetNode && $isFillInTheBlankSpaceNode(targetNode)) {
|
|
4409
|
+
setFoundNode(targetNode);
|
|
4410
|
+
}
|
|
4411
|
+
});
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
);
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
) }),
|
|
4376
4418
|
/* @__PURE__ */ jsx41("div", { children: /* @__PURE__ */ jsx41(
|
|
4377
4419
|
Checkbox,
|
|
4378
4420
|
{
|
|
@@ -4390,7 +4432,7 @@ function FillInTheBlankSpaceSettings(props) {
|
|
|
4390
4432
|
}
|
|
4391
4433
|
}
|
|
4392
4434
|
) }),
|
|
4393
|
-
/* @__PURE__ */ jsx41("div", { children: /* @__PURE__ */ jsx41(
|
|
4435
|
+
!foundNode.getUseRegex() && /* @__PURE__ */ jsx41("div", { children: /* @__PURE__ */ jsx41(
|
|
4394
4436
|
TextInput,
|
|
4395
4437
|
{
|
|
4396
4438
|
id: "errors-allowed",
|
|
@@ -7513,12 +7555,42 @@ function FinancialStatementQuestionComponent(props) {
|
|
|
7513
7555
|
} else if (rowItem.type === "Line") {
|
|
7514
7556
|
return /* @__PURE__ */ jsxs15("tr", { "data-selectable": "true", children: [
|
|
7515
7557
|
/* @__PURE__ */ jsx56("td", { "data-selectable": "true", children: /* @__PURE__ */ jsx56(
|
|
7516
|
-
"
|
|
7558
|
+
"div",
|
|
7517
7559
|
{
|
|
7518
7560
|
style: {
|
|
7519
7561
|
paddingLeft: `calc(1em * ${rowItem.depth})`
|
|
7520
7562
|
},
|
|
7521
|
-
children:
|
|
7563
|
+
children: /* @__PURE__ */ jsx56(
|
|
7564
|
+
LexicalNestedComposer,
|
|
7565
|
+
{
|
|
7566
|
+
initialEditor: rowItem.entry,
|
|
7567
|
+
children: /* @__PURE__ */ jsxs15(NestedEditor, { nodeKey, children: [
|
|
7568
|
+
/* @__PURE__ */ jsx56(SettingsPanelNestedAgentPlugin, {}),
|
|
7569
|
+
/* @__PURE__ */ jsx56(
|
|
7570
|
+
RichTextPlugin,
|
|
7571
|
+
{
|
|
7572
|
+
contentEditable: /* @__PURE__ */ jsx56(NestedContentEditable, {}),
|
|
7573
|
+
ErrorBoundary: LexicalErrorBoundary,
|
|
7574
|
+
placeholder: null
|
|
7575
|
+
},
|
|
7576
|
+
nodeKey
|
|
7577
|
+
),
|
|
7578
|
+
/* @__PURE__ */ jsx56(
|
|
7579
|
+
HistoryPlugin,
|
|
7580
|
+
{
|
|
7581
|
+
externalHistoryState: historyState
|
|
7582
|
+
}
|
|
7583
|
+
),
|
|
7584
|
+
/* @__PURE__ */ jsx56(
|
|
7585
|
+
TypeaheadVariableAgentPlugin,
|
|
7586
|
+
{
|
|
7587
|
+
decoratorNode: FinancialStatementQuestionNode
|
|
7588
|
+
}
|
|
7589
|
+
),
|
|
7590
|
+
/* @__PURE__ */ jsx56(VariableComponentPlugin, {})
|
|
7591
|
+
] })
|
|
7592
|
+
}
|
|
7593
|
+
)
|
|
7522
7594
|
}
|
|
7523
7595
|
) }),
|
|
7524
7596
|
/* @__PURE__ */ jsxs15(
|
|
@@ -7573,10 +7645,40 @@ function FinancialStatementQuestionComponent(props) {
|
|
|
7573
7645
|
(distractorItem) => {
|
|
7574
7646
|
return /* @__PURE__ */ jsxs15("tr", { "data-selectable": "true", children: [
|
|
7575
7647
|
/* @__PURE__ */ jsx56("td", { "data-selectable": "true", children: /* @__PURE__ */ jsx56(
|
|
7576
|
-
"
|
|
7648
|
+
"div",
|
|
7577
7649
|
{
|
|
7578
7650
|
style: { color: "var(--sl-color-red-500)" },
|
|
7579
|
-
children:
|
|
7651
|
+
children: /* @__PURE__ */ jsx56(
|
|
7652
|
+
LexicalNestedComposer,
|
|
7653
|
+
{
|
|
7654
|
+
initialEditor: distractorItem.entry,
|
|
7655
|
+
children: /* @__PURE__ */ jsxs15(NestedEditor, { nodeKey, children: [
|
|
7656
|
+
/* @__PURE__ */ jsx56(SettingsPanelNestedAgentPlugin, {}),
|
|
7657
|
+
/* @__PURE__ */ jsx56(
|
|
7658
|
+
RichTextPlugin,
|
|
7659
|
+
{
|
|
7660
|
+
contentEditable: /* @__PURE__ */ jsx56(NestedContentEditable, {}),
|
|
7661
|
+
ErrorBoundary: LexicalErrorBoundary,
|
|
7662
|
+
placeholder: null
|
|
7663
|
+
},
|
|
7664
|
+
nodeKey
|
|
7665
|
+
),
|
|
7666
|
+
/* @__PURE__ */ jsx56(
|
|
7667
|
+
HistoryPlugin,
|
|
7668
|
+
{
|
|
7669
|
+
externalHistoryState: historyState
|
|
7670
|
+
}
|
|
7671
|
+
),
|
|
7672
|
+
/* @__PURE__ */ jsx56(
|
|
7673
|
+
TypeaheadVariableAgentPlugin,
|
|
7674
|
+
{
|
|
7675
|
+
decoratorNode: FinancialStatementQuestionNode
|
|
7676
|
+
}
|
|
7677
|
+
),
|
|
7678
|
+
/* @__PURE__ */ jsx56(VariableComponentPlugin, {})
|
|
7679
|
+
] })
|
|
7680
|
+
}
|
|
7681
|
+
)
|
|
7580
7682
|
}
|
|
7581
7683
|
) }),
|
|
7582
7684
|
/* @__PURE__ */ jsx56("td", { "data-selectable": "true" })
|
|
@@ -7672,18 +7774,21 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7672
7774
|
continue;
|
|
7673
7775
|
}
|
|
7674
7776
|
if (isSerializableFinancialStatementLine(row)) {
|
|
7777
|
+
const entryNestedEditor = createEditor2();
|
|
7778
|
+
const entryNestedEditorState = entryNestedEditor.parseEditorState(row.entry.editorState);
|
|
7779
|
+
if (!entryNestedEditorState.isEmpty()) {
|
|
7780
|
+
entryNestedEditor.setEditorState(entryNestedEditorState);
|
|
7781
|
+
}
|
|
7675
7782
|
const amountNestedEditor = createEditor2();
|
|
7676
|
-
const
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
if (!editorState2.isEmpty()) {
|
|
7680
|
-
amountNestedEditor.setEditorState(editorState2);
|
|
7783
|
+
const amountNestedEditorState = amountNestedEditor.parseEditorState(row.amount.editorState);
|
|
7784
|
+
if (!amountNestedEditorState.isEmpty()) {
|
|
7785
|
+
amountNestedEditor.setEditorState(amountNestedEditorState);
|
|
7681
7786
|
}
|
|
7682
7787
|
restoredRows.push({
|
|
7683
7788
|
type: row.type,
|
|
7684
7789
|
id: row.id,
|
|
7685
7790
|
depth: row.depth,
|
|
7686
|
-
entry:
|
|
7791
|
+
entry: entryNestedEditor,
|
|
7687
7792
|
amount: amountNestedEditor,
|
|
7688
7793
|
isEntryHint: row.isEntryHint,
|
|
7689
7794
|
isAmountHint: row.isAmountHint,
|
|
@@ -7692,12 +7797,26 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7692
7797
|
continue;
|
|
7693
7798
|
}
|
|
7694
7799
|
}
|
|
7800
|
+
const restoredDistractors = [];
|
|
7801
|
+
for (const distractor of serializedNode.distractors) {
|
|
7802
|
+
const entryNestedEditor = createEditor2();
|
|
7803
|
+
const entryNestedEditorState = entryNestedEditor.parseEditorState(
|
|
7804
|
+
distractor.entry.editorState
|
|
7805
|
+
);
|
|
7806
|
+
if (!entryNestedEditorState.isEmpty()) {
|
|
7807
|
+
entryNestedEditor.setEditorState(entryNestedEditorState);
|
|
7808
|
+
}
|
|
7809
|
+
restoredDistractors.push({
|
|
7810
|
+
id: distractor.id,
|
|
7811
|
+
entry: entryNestedEditor
|
|
7812
|
+
});
|
|
7813
|
+
}
|
|
7695
7814
|
return $createFinancialStatementQuestionNode(
|
|
7696
7815
|
serializedNode.points,
|
|
7697
7816
|
headerNestedEditor,
|
|
7698
7817
|
serializedNode.columnHeaders,
|
|
7699
7818
|
restoredRows,
|
|
7700
|
-
|
|
7819
|
+
restoredDistractors,
|
|
7701
7820
|
serializedNode.id
|
|
7702
7821
|
);
|
|
7703
7822
|
}
|
|
@@ -7722,7 +7841,7 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7722
7841
|
type: row.type,
|
|
7723
7842
|
id: row.id,
|
|
7724
7843
|
depth: row.depth,
|
|
7725
|
-
entry: row.entry,
|
|
7844
|
+
entry: row.entry.toJSON(),
|
|
7726
7845
|
amount: row.amount.toJSON(),
|
|
7727
7846
|
isEntryHint: row.isEntryHint,
|
|
7728
7847
|
isAmountHint: row.isAmountHint,
|
|
@@ -7731,7 +7850,12 @@ var FinancialStatementQuestionNode = class _FinancialStatementQuestionNode exten
|
|
|
7731
7850
|
}
|
|
7732
7851
|
throw new Error("Invalid row type");
|
|
7733
7852
|
}).filter(Boolean),
|
|
7734
|
-
distractors: this.__distractors
|
|
7853
|
+
distractors: this.__distractors.map((distractor) => {
|
|
7854
|
+
return {
|
|
7855
|
+
id: distractor.id,
|
|
7856
|
+
entry: distractor.entry.toJSON()
|
|
7857
|
+
};
|
|
7858
|
+
}),
|
|
7735
7859
|
type: TYPE_NAME4,
|
|
7736
7860
|
version: 1
|
|
7737
7861
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@examind/block-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"@comment version": [
|
|
5
5
|
"Don't specify package version here. It will be injected by publish workflow."
|
|
6
6
|
],
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"tsup": "^8.3.5",
|
|
63
63
|
"typescript": "^5.7.2",
|
|
64
64
|
"typescript-eslint": "^8.18.2",
|
|
65
|
-
"@examind/block-types": "0.
|
|
65
|
+
"@examind/block-types": "0.3.0"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@dnd-kit/core": "6.3.1",
|