Skip to content

Commit

Permalink
#21 Add a "reset" option.
Browse files Browse the repository at this point in the history
  • Loading branch information
igorocky committed Aug 5, 2023
1 parent 0080f38 commit 6195322
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/metamath/test/MM_wrk_editor_json.res
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ let createInitialEditorState = (
disjText: stateLocStor->Belt.Option.map(obj => obj.disjText)->Belt.Option.getWithDefault(""),
disjEditMode: false,
disjErr: None,
disj: Belt_MapInt.fromArray([]),

wrkCtx: None,

Expand Down
1 change: 0 additions & 1 deletion src/metamath/test/MM_wrk_editor_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ let createEditorState = (
disjText: "",
disjEditMode: false,
disjErr: None,
disj: Belt_MapInt.fromArray([]),

wrkCtx: None,

Expand Down
12 changes: 12 additions & 0 deletions src/metamath/ui/MM_cmp_editor.res
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ let make = (
})->ignore
}

let actResetEditorContent = () => {
setState(resetEditorContent)
}

let rndError = (msgOpt,color) => {
switch msgOpt {
| None => <></>
Expand Down Expand Up @@ -1306,6 +1310,14 @@ let make = (
>
{"Import from JSON ..."->React.string}
</MenuItem>
<MenuItem
onClick={() => {
actCloseMainMenu()
actResetEditorContent()
}}
>
{"Reset editor content"->React.string}
</MenuItem>
<MenuItem
onClick={() => {
actCloseMainMenu()
Expand Down
19 changes: 18 additions & 1 deletion src/metamath/worker/MM_wrk_editor.res
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ type editorState = {
disjText: string,
disjEditMode: bool,
disjErr: option<string>,
disj: Belt_MapInt.t<Belt_SetInt.t>,

wrkCtx: option<mmContext>,

Expand Down Expand Up @@ -2572,3 +2571,21 @@ let textToSyntaxTree = (
}
}
}

let resetEditorContent = (st:editorState):editorState => {
{
...st,

descr: "",
descrEditMode: false,

varsText: "",
varsEditMode: false,

disjText: "",
disjEditMode: false,

stmts: [],
checkedStmtIds: [],
}
}
2 changes: 1 addition & 1 deletion src/metamath/worker/MM_wrk_editor.resi
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ type editorState = {
disjText: string,
disjEditMode: bool,
disjErr: option<string>,
disj: Belt_MapInt.t<Belt_SetInt.t>,

wrkCtx: option<mmContext>,

Expand Down Expand Up @@ -200,6 +199,7 @@ let findStmtsToMerge: editorState => result<(userStmt,userStmt), string>
let parseJstf: string => result<option<jstf>,string>
let removeAllTempData: editorState => editorState
let isEditMode: editorState => bool
let resetEditorContent: editorState => editorState

let getIdsOfSelectedNodes: stmtCont => (int,Belt_SetInt.t)
let hasSelectedText: stmtCont => bool
Expand Down

0 comments on commit 6195322

Please sign in to comment.