File tree Expand file tree Collapse file tree 4 files changed +23
-4
lines changed
Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1- import React from "react" ;
1+ import React , { useState } from "react" ;
22// eslint-disable-next-line import/no-extraneous-dependencies
33import PropTypes from "prop-types" ;
44import { CgSoftwareDownload , CgMathPlus } from "react-icons/cg" ;
@@ -12,11 +12,19 @@ import {
1212} from "./header.style" ;
1313
1414export default function Header ( { download, load } ) {
15+ const [ noteName , setNoteName ] = useState ( "untitled.ipynb" ) ;
16+ const onNoteTitleChange = ( e ) => {
17+ setNoteName ( e ) ;
18+ } ;
1519 return (
1620 < HeaderContainer >
1721 < div > </ div >
1822 < NoteEditContainer >
19- < NoteTitle type = "text" value = "untitled.ipynb" />
23+ < NoteTitle
24+ onChange = { ( e ) => onNoteTitleChange ( e . target . value ) }
25+ type = "text"
26+ value = { noteName }
27+ />
2028 < div >
2129 < AddNoteLabel htmlFor = "import-notebook-file" >
2230 { " " }
@@ -29,7 +37,11 @@ export default function Header({ download, load }) {
2937 < AddNoteInput
3038 type = "file"
3139 id = "import-notebook-file"
32- onChange = { ( ) => load ( ) }
40+ onChange = { ( ) => {
41+ const fileName = load ( ) ;
42+ const name = `${ fileName . split ( "." ) [ 0 ] } .ipynb` ;
43+ onNoteTitleChange ( name ) ;
44+ } }
3345 />
3446 </ div >
3547 </ NoteEditContainer >
Original file line number Diff line number Diff line change 3030 color : # 36c5ce ;
3131 text-decoration : none;
3232}
33+
34+ input : focus {
35+ outline : none !important ;
36+ }
Original file line number Diff line number Diff line change 22// eslint-disable-next-line consistent-return
33export const reducer = ( state , action ) => {
44 if ( action . type === "CHANGE_CELL" ) {
5- console . log ( state ) ;
65 const stateCells = state . cells . map ( ( cell ) => {
76 if ( cell . id === action . payload . id ) {
87 return action . payload ;
@@ -36,6 +35,7 @@ export const reducer = (state, action) => {
3635 }
3736
3837 if ( action . type === "LOAD_NOTE" ) {
38+ // console.log(action.payload);
3939 return { ...state , cells : action . payload } ;
4040 }
4141} ;
Original file line number Diff line number Diff line change @@ -196,6 +196,7 @@ const load_package = async (array, callback) => {
196196} ;
197197
198198export const load_notebook = ( dispatch ) => {
199+ let fileName = null ;
199200 const { files } = document . getElementById ( "import-notebook-file" ) ;
200201 let json_content = null ;
201202 if ( files . length > 0 ) {
@@ -207,7 +208,9 @@ export const load_notebook = (dispatch) => {
207208 dispatch ( { type : "LOAD_NOTE" , payload : json } ) ;
208209 } ;
209210 reader . readAsText ( content ) ;
211+ fileName = content . name ;
210212 }
213+ return fileName ;
211214} ;
212215/**
213216 * Returns the id of the current cell's output div
You can’t perform that action at this time.
0 commit comments