From ebae04aa0e168e7f40c05794b36cdd2fc4230d0d Mon Sep 17 00:00:00 2001 From: yannis <yannisbarlas@gmail.com> Date: Mon, 4 Dec 2017 22:32:00 +0200 Subject: [PATCH] more prettier... --- packages/component-app/src/index.js | 4 +- .../src/components/Login.js | 10 +- .../src/components/Signup.js | 12 +- .../component-authentication/src/index.js | 2 +- .../src/redux/currentUser.js | 32 +++--- .../src/redux/login.js | 10 +- .../src/redux/signup.js | 10 +- .../src/components/AssignEditor.js | 12 +- .../src/components/AssignEditorContainer.js | 14 +-- .../src/components/Dashboard.js | 6 +- .../src/components/DashboardPage.js | 25 ++--- .../src/components/Reviews.js | 2 +- .../src/components/Status.js | 4 +- .../src/components/UploadManuscript.js | 2 +- .../src/redux/conversion.js | 26 ++--- .../src/components/Manuscript.js | 4 +- .../src/components/ManuscriptPage.js | 2 +- .../src/components/DecisionPage.js | 16 +-- .../src/components/ReviewPage.js | 16 +-- .../src/components/ReviewersPage.js | 4 +- .../src/components/decision/DecisionForm.js | 15 ++- .../src/components/decision/DecisionLayout.js | 38 +++---- .../src/components/review/ReviewForm.js | 21 ++-- .../src/components/review/ReviewLayout.js | 40 +++---- .../src/components/reviewers/Reviewer.js | 7 +- .../components/reviewers/ReviewerContainer.js | 2 +- .../src/components/reviewers/ReviewerForm.js | 12 +- .../reviewers/ReviewerFormContainer.js | 6 +- .../src/components/reviewers/Reviewers.js | 2 +- .../src/components/Confirm.js | 4 +- .../src/components/Declarations.js | 8 +- .../src/components/Metadata.js | 25 +++-- .../component-submit/src/components/Notes.js | 4 +- .../component-submit/src/components/Submit.js | 6 +- .../src/components/SubmitPage.js | 4 +- .../src/components/Suggestions.js | 16 +-- .../src/components/SupplementaryFiles.js | 2 +- .../src/components/Validots.js | 4 +- .../xpub-edit/src/components/HtmlEditor.js | 6 +- packages/xpub-edit/src/components/MenuBar.js | 4 +- .../src/components/abstract/AbstractEditor.js | 8 +- .../src/components/abstract/AbstractViewer.js | 2 +- .../src/components/abstract/config/icons.js | 14 +-- .../src/components/abstract/config/keys.js | 12 +- .../src/components/abstract/config/marks.js | 12 +- .../src/components/abstract/config/menu.js | 104 +++++++++--------- .../src/components/abstract/config/nodes.js | 4 +- .../src/components/abstract/config/schema.js | 2 +- .../src/components/note/NoteEditor.js | 8 +- .../src/components/note/NoteViewer.js | 2 +- .../src/components/note/config/icons.js | 12 +- .../src/components/note/config/keys.js | 10 +- .../src/components/note/config/marks.js | 12 +- .../src/components/note/config/schema.js | 2 +- .../src/components/text/TextEditor.js | 8 +- .../src/components/text/TextViewer.js | 2 +- .../src/components/text/config/schema.js | 2 +- .../src/components/title/TitleEditor.js | 8 +- .../src/components/title/TitleViewer.js | 2 +- .../src/components/title/config/icons.js | 8 +- .../src/components/title/config/keys.js | 6 +- .../src/components/title/config/marks.js | 2 +- .../src/components/title/config/menu.js | 24 ++-- .../src/components/title/config/schema.js | 2 +- packages/xpub-edit/src/decorations.js | 2 +- packages/xpub-edit/styleguide.config.js | 18 +-- 66 files changed, 349 insertions(+), 378 deletions(-) diff --git a/packages/component-app/src/index.js b/packages/component-app/src/index.js index 243220c28..6f1f42a64 100644 --- a/packages/component-app/src/index.js +++ b/packages/component-app/src/index.js @@ -1,7 +1,5 @@ module.exports = { frontend: { - components: [ - () => require('./components') - ] + components: [() => require('./components')], }, } diff --git a/packages/component-authentication/src/components/Login.js b/packages/component-authentication/src/components/Login.js index e78b25824..9b6f5763f 100644 --- a/packages/component-authentication/src/components/Login.js +++ b/packages/component-authentication/src/components/Login.js @@ -15,17 +15,17 @@ const Login = ({ errorMessage, handleSubmit }) => ( {errorMessage && <div className={classes.error}>{errorMessage}</div>} - <form onSubmit={handleSubmit} className={classes.form}> - <Field name="username" component={UsernameInput} /> - <Field name="password" component={PasswordInput} /> - <Button primary type="submit" className={classes.button}> + <form className={classes.form} onSubmit={handleSubmit}> + <Field component={UsernameInput} name="username" /> + <Field component={PasswordInput} name="password" /> + <Button className={classes.button} primary type="submit"> Login </Button> </form> <div className={classes.alternate}> <span className={classes.message}>You don't have an account?</span> - <Link to="/signup" className={classes.link}> + <Link className={classes.link} to="/signup"> Sign up </Link> </div> diff --git a/packages/component-authentication/src/components/Signup.js b/packages/component-authentication/src/components/Signup.js index 400eb8008..8a95e2222 100644 --- a/packages/component-authentication/src/components/Signup.js +++ b/packages/component-authentication/src/components/Signup.js @@ -18,18 +18,18 @@ const Signup = ({ errorMessage, handleSubmit }) => ( {errorMessage && <div className={classes.error}>{errorMessage}</div>} - <form onSubmit={handleSubmit} className={classes.form}> - <Field name="username" component={UsernameInput} /> - <Field name="email" component={EmailInput} /> - <Field name="password" component={PasswordInput} /> - <Button primary type="submit" className={classes.button}> + <form className={classes.form} onSubmit={handleSubmit}> + <Field component={UsernameInput} name="username" /> + <Field component={EmailInput} name="email" /> + <Field component={PasswordInput} name="password" /> + <Button className={classes.button} primary type="submit"> Sign up </Button> </form> <div className={classes.alternate}> <span className={classes.message}>Already have an account?</span> - <Link to="/login" className={classes.link}> + <Link className={classes.link} to="/login"> Login </Link> </div> diff --git a/packages/component-authentication/src/index.js b/packages/component-authentication/src/index.js index 3f2b60b0c..44c18796c 100644 --- a/packages/component-authentication/src/index.js +++ b/packages/component-authentication/src/index.js @@ -2,9 +2,9 @@ module.exports = { frontend: { components: [() => require('./components')], reducers: { + currentUser: () => require('./redux/currentUser').default, login: () => require('./redux/login').default, signup: () => require('./redux/signup').default, - currentUser: () => require('./redux/currentUser').default, }, }, } diff --git a/packages/component-authentication/src/redux/currentUser.js b/packages/component-authentication/src/redux/currentUser.js index b0b0f8ffe..c752a9bb3 100644 --- a/packages/component-authentication/src/redux/currentUser.js +++ b/packages/component-authentication/src/redux/currentUser.js @@ -20,8 +20,8 @@ export const getCurrentUserSuccess = user => ({ }) export const getCurrentUserFailure = error => ({ - type: GET_CURRENT_USER_FAILURE, error, + type: GET_CURRENT_USER_FAILURE, }) export const getCurrentUser = () => dispatch => { @@ -40,50 +40,50 @@ export const getCurrentUser = () => dispatch => { /* reducer */ const initialState = { - isFetching: false, - isFetched: false, + error: null, isAuthenticated: false, + isFetched: false, + isFetching: false, user: null, - error: null, } export default (state = initialState, action) => { switch (action.type) { case GET_CURRENT_USER_REQUEST: return { - isFetching: true, - isFetched: false, + error: null, isAuthenticated: false, + isFetched: false, + isFetching: true, user: null, - error: null, } case GET_CURRENT_USER_FAILURE: return { - isFetching: false, - isFetched: true, + error: action.error, isAuthenticated: false, + isFetched: true, + isFetching: false, user: null, - error: action.error, } case GET_CURRENT_USER_SUCCESS: return { - isFetching: false, - isFetched: true, + error: null, isAuthenticated: true, + isFetched: true, + isFetching: false, user: action.user, - error: null, } // clear the current user on logout case LOGOUT_SUCCESS: return { - isFetching: false, - isFetched: false, + error: null, isAuthenticated: false, + isFetched: false, + isFetching: false, user: null, - error: null, } default: diff --git a/packages/component-authentication/src/redux/login.js b/packages/component-authentication/src/redux/login.js index a1a051fed..706cb0254 100644 --- a/packages/component-authentication/src/redux/login.js +++ b/packages/component-authentication/src/redux/login.js @@ -21,8 +21,8 @@ export const loginSuccess = user => ({ }) export const loginFailure = error => ({ - type: LOGIN_FAILURE, error, + type: LOGIN_FAILURE, }) export const login = credentials => dispatch => { @@ -43,28 +43,28 @@ export const login = credentials => dispatch => { /* reducer */ const initialState = { - isFetching: false, error: null, + isFetching: false, } export default (state = initialState, action) => { switch (action.type) { case LOGIN_REQUEST: return { - isFetching: true, error: null, + isFetching: true, } case LOGIN_SUCCESS: return { - isFetching: false, error: null, + isFetching: false, } case LOGIN_FAILURE: return { - isFetching: false, error: action.error, + isFetching: false, } default: diff --git a/packages/component-authentication/src/redux/signup.js b/packages/component-authentication/src/redux/signup.js index be260253e..daa23590f 100644 --- a/packages/component-authentication/src/redux/signup.js +++ b/packages/component-authentication/src/redux/signup.js @@ -19,8 +19,8 @@ export const signupSuccess = user => ({ }) export const signupFailure = error => ({ - type: SIGNUP_FAILURE, error, + type: SIGNUP_FAILURE, }) export const signup = credentials => dispatch => { @@ -40,28 +40,28 @@ export const signup = credentials => dispatch => { /* reducer */ const initialState = { - isFetching: false, error: null, + isFetching: false, } export default (state = initialState, action) => { switch (action.type) { case SIGNUP_REQUEST: return { - isFetching: true, error: null, + isFetching: true, } case SIGNUP_SUCCESS: return { - isFetching: false, error: null, + isFetching: false, } case SIGNUP_FAILURE: return { - isFetching: false, error: action.error, + isFetching: false, } default: diff --git a/packages/component-dashboard/src/components/AssignEditor.js b/packages/component-dashboard/src/components/AssignEditor.js index c8f27ff0d..a08077a97 100644 --- a/packages/component-dashboard/src/components/AssignEditor.js +++ b/packages/component-dashboard/src/components/AssignEditor.js @@ -14,20 +14,20 @@ const AssignEditor = ({ addUserToTeam, }) => ( <Menu - value={team ? team.members[0] : null} label={teamName} - options={options} - placeholder="Assign an editor…" onChange={user => { addUserToTeam({ - team, - teamTypeName, - name: teamName, group: 'editor', + name: teamName, project, + team, + teamTypeName, user, }) }} + options={options} + placeholder="Assign an editor…" + value={team ? team.members[0] : null} /> ) diff --git a/packages/component-dashboard/src/components/AssignEditorContainer.js b/packages/component-dashboard/src/components/AssignEditorContainer.js index b14bd8c3d..b39db3e70 100644 --- a/packages/component-dashboard/src/components/AssignEditorContainer.js +++ b/packages/component-dashboard/src/components/AssignEditorContainer.js @@ -4,13 +4,19 @@ import AssignEditor from './AssignEditor' import { addUserToTeam } from '../redux/teams' const editorOption = user => ({ - value: user.id, label: user.username, // TODO: name + value: user.id, }) export default compose( connect( (state, { project, teamTypeName }) => ({ + options: + state.users && + !state.users.isFetching && + state.users.users + // .filter(user => user.roles.includes(teamType)) // TODO + .map(editorOption), team: state.teams && state.teams.find( @@ -19,12 +25,6 @@ export default compose( team.object.id === project.id && team.teamType.name === teamTypeName, ), - options: - state.users && - !state.users.isFetching && - state.users.users - // .filter(user => user.roles.includes(teamType)) // TODO - .map(editorOption), }), { addUserToTeam, diff --git a/packages/component-dashboard/src/components/Dashboard.js b/packages/component-dashboard/src/components/Dashboard.js index 1034a1d0f..4cb225f0c 100644 --- a/packages/component-dashboard/src/components/Dashboard.js +++ b/packages/component-dashboard/src/components/Dashboard.js @@ -42,9 +42,9 @@ const Dashboard = ({ <div className={classes.heading}>My Submissions</div> {dashboard.owner.map(project => ( <OwnerItemWithVersion + deleteProject={deleteProject} key={project.id} project={project} - deleteProject={deleteProject} /> ))} </div> @@ -55,9 +55,9 @@ const Dashboard = ({ <div className={classes.heading}>To review</div> {dashboard.reviewer.map(project => ( <ReviewerItemWithVersion + currentUser={currentUser} key={project.id} project={project} - currentUser={currentUser} reviewerResponse={reviewerResponse} /> ))} @@ -69,9 +69,9 @@ const Dashboard = ({ <div className={classes.heading}>My Manuscripts</div> {dashboard.editor.map(project => ( <EditorItemWithVersion + AssignEditor={AssignEditor} key={project.id} project={project} - AssignEditor={AssignEditor} /> ))} </div> diff --git a/packages/component-dashboard/src/components/DashboardPage.js b/packages/component-dashboard/src/components/DashboardPage.js index 0ff0ee724..e8efaac3c 100644 --- a/packages/component-dashboard/src/components/DashboardPage.js +++ b/packages/component-dashboard/src/components/DashboardPage.js @@ -28,10 +28,9 @@ export default compose( ]), connect( state => { - const collections = state.collections - const teams = state.teams + const { collections } = state + const { conversion, teams } = state const currentUser = selectCurrentUser(state) - const conversion = state.conversion const sortedCollections = newestFirst(collections) @@ -57,11 +56,6 @@ export default compose( ) const dashboard = { - owner: sortedCollections.filter( - collection => - collection.owners && - collection.owners.some(owner => owner.id === currentUser.id), - ), editor: newestFirst( unassignedCollections .concat(myCollections) @@ -70,6 +64,11 @@ export default compose( items.findIndex(item => item.id === collection.id) === index, ), ), + owner: sortedCollections.filter( + collection => + collection.owners && + collection.owners.some(owner => owner.id === currentUser.id), + ), // reviewer: newestFirst(teams // .filter(team => team.group === 'reviewer' // && team.object.type === 'collection' @@ -86,15 +85,15 @@ export default compose( ), } - return { collections, currentUser, conversion, dashboard } + return { collections, conversion, currentUser, dashboard } }, (dispatch, { history }) => ({ - uploadManuscript: acceptedFiles => - dispatch(uploadManuscript(acceptedFiles, history)), - reviewerResponse: (project, version, reviewer, status) => - dispatch(reviewerResponse(project, version, reviewer, status)), deleteProject: collection => dispatch(actions.deleteCollection(collection)), + reviewerResponse: (project, version, reviewer, status) => + dispatch(reviewerResponse(project, version, reviewer, status)), + uploadManuscript: acceptedFiles => + dispatch(uploadManuscript(acceptedFiles, history)), }), ), withProps({ diff --git a/packages/component-dashboard/src/components/Reviews.js b/packages/component-dashboard/src/components/Reviews.js index 7b40080a8..7eb86d258 100644 --- a/packages/component-dashboard/src/components/Reviews.js +++ b/packages/component-dashboard/src/components/Reviews.js @@ -7,7 +7,7 @@ import classes from './Reviews.local.scss' const Reviews = ({ reviews }) => ( <div className={classes.root}> {Object.keys(reviews).map(status => ( - <span key={status} className={classes.badge}> + <span className={classes.badge} key={status}> <Badge count={reviews[status].length} label={status} /> </span> ))} diff --git a/packages/component-dashboard/src/components/Status.js b/packages/component-dashboard/src/components/Status.js index b5d2db180..cbac37d53 100644 --- a/packages/component-dashboard/src/components/Status.js +++ b/packages/component-dashboard/src/components/Status.js @@ -4,11 +4,11 @@ import classes from './Status.local.css' // TODO: move labels to journal config const labels = { - new: 'Unsubmitted', - submitted: 'Submitted', accepted: 'Accepted', assignedToEditor: 'Assigned to editor', assigningReviewers: 'Assigning reviewers', + new: 'Unsubmitted', + submitted: 'Submitted', } const Status = ({ status }) => ( diff --git a/packages/component-dashboard/src/components/UploadManuscript.js b/packages/component-dashboard/src/components/UploadManuscript.js index 51a1ae5ad..eae6ef8c3 100644 --- a/packages/component-dashboard/src/components/UploadManuscript.js +++ b/packages/component-dashboard/src/components/UploadManuscript.js @@ -9,9 +9,9 @@ const isIdle = conversion => const UploadManuscript = ({ uploadManuscript, conversion }) => ( <Dropzone - onDrop={uploadManuscript} accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document" className={classes.dropzone} + onDrop={uploadManuscript} > <div className={classes.root}> <div diff --git a/packages/component-dashboard/src/redux/conversion.js b/packages/component-dashboard/src/redux/conversion.js index d4af1288f..34892de22 100644 --- a/packages/component-dashboard/src/redux/conversion.js +++ b/packages/component-dashboard/src/redux/conversion.js @@ -16,14 +16,14 @@ export const uploadManuscriptRequest = () => ({ }) export const uploadManuscriptSuccess = (collection, fragment) => ({ - type: UPLOAD_MANUSCRIPT_SUCCESS, collection, fragment, + type: UPLOAD_MANUSCRIPT_SUCCESS, }) export const uploadManuscriptFailure = error => ({ - type: UPLOAD_MANUSCRIPT_FAILURE, error, + type: UPLOAD_MANUSCRIPT_FAILURE, }) export const uploadManuscript = (acceptedFiles, history) => dispatch => { @@ -64,20 +64,20 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => { // TODO: rethrow errors so they can be caught here return dispatch( actions.createFragment(collection, { - fragmentType: 'version', created: new Date(), // TODO: set on server - version: 1, - source, - metadata: { - title, - }, files: { - supplementary: [], manuscript: { name: inputFile.name, url: fileURL, }, + supplementary: [], + }, + fragmentType: 'version', + metadata: { + title, }, + source, + version: 1, }), ).then(({ fragment }) => { dispatch(uploadManuscriptSuccess(collection, fragment)) @@ -105,8 +105,8 @@ export const uploadManuscript = (acceptedFiles, history) => dispatch => { /* reducer */ const initialState = { - converting: false, complete: undefined, + converting: false, error: undefined, } @@ -114,21 +114,21 @@ export default (state = initialState, action) => { switch (action.type) { case UPLOAD_MANUSCRIPT_REQUEST: return { - converting: true, complete: false, + converting: true, error: undefined, } case UPLOAD_MANUSCRIPT_SUCCESS: return { - converting: false, complete: true, + converting: false, } case UPLOAD_MANUSCRIPT_FAILURE: return { - converting: false, complete: false, + converting: false, error: action.error, } diff --git a/packages/component-manuscript/src/components/Manuscript.js b/packages/component-manuscript/src/components/Manuscript.js index af9097ad0..722f4c2fa 100644 --- a/packages/component-manuscript/src/components/Manuscript.js +++ b/packages/component-manuscript/src/components/Manuscript.js @@ -15,13 +15,13 @@ const Manuscript = ({ <SimpleEditor classes={classes.fullscreen} content={content} - user={currentUser} fileUpload={fileUpload} history={history} + onSave={source => updateManuscript({ source })} readOnly={false} trackChanges={false} update={data => updateManuscript(data)} - onSave={source => updateManuscript({ source })} + user={currentUser} /> ) diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index f59033cb5..b4ae8eaaf 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -25,7 +25,7 @@ export default compose( const content = version.source // TODO: load from a file - return { currentUser, project, version, content } + return { content, currentUser, project, version } }, { fileUpload: actions.fileUpload, diff --git a/packages/component-review/src/components/DecisionPage.js b/packages/component-review/src/components/DecisionPage.js index 95c1dc11a..6ab6c342b 100644 --- a/packages/component-review/src/components/DecisionPage.js +++ b/packages/component-review/src/components/DecisionPage.js @@ -18,13 +18,11 @@ import DecisionLayout from './decision/DecisionLayout' const handleDecision = (project, version) => dispatch => { return dispatch( actions.updateFragment(project, { + decision: version.decision, id: version.id, rev: version.rev, - decision: version.decision, }), ).then(() => { - console.log(version) - switch (version.decision.recommendation) { case 'accept': return dispatch( @@ -78,13 +76,11 @@ const handleDecision = (project, version) => dispatch => { } const onSubmit = (values, dispatch, { project, version, history }) => { - console.log('submit', values) - version.decision = { ...version.decision, ...values, - submitted: new Date(), status: 'submitted', + submitted: new Date(), } return dispatch(handleDecision(project, version)) @@ -100,8 +96,6 @@ const onSubmit = (values, dispatch, { project, version, history }) => { } const onChange = (values, dispatch, { project, version }) => { - console.log('change', values) - version.decision = { ...version.decision, ...values, @@ -109,9 +103,9 @@ const onChange = (values, dispatch, { project, version }) => { return dispatch( actions.updateFragment(project, { + decision: version.decision, id: version.id, rev: version.rev, - decision: version.decision, }), ) @@ -130,7 +124,7 @@ export default compose( const version = selectFragment(state, match.params.version) const currentVersion = selectCurrentVersion(state, project) - return { project, versions, version, currentVersion } + return { currentVersion, project, version, versions } }, { uploadFile, @@ -144,7 +138,7 @@ export default compose( }), reduxForm({ form: 'decision', - onSubmit, onChange: debounce(onChange, 1000, { maxWait: 5000 }), + onSubmit, }), )(DecisionLayout) diff --git a/packages/component-review/src/components/ReviewPage.js b/packages/component-review/src/components/ReviewPage.js index ce0aa8309..9ff53e953 100644 --- a/packages/component-review/src/components/ReviewPage.js +++ b/packages/component-review/src/components/ReviewPage.js @@ -22,11 +22,9 @@ const onSubmit = ( dispatch, { history, project, version, reviewer }, ) => { - console.log('submit', values) - Object.assign(reviewer, { - submitted: new Date(), status: 'reviewed', + submitted: new Date(), ...values, }) @@ -49,8 +47,6 @@ const onSubmit = ( } const onChange = (values, dispatch, { project, version, reviewer }) => { - console.log('change', values) - Object.assign(reviewer, { submitted: new Date(), ...values, @@ -94,12 +90,12 @@ export default compose( const reviewer = getReviewerFromUser(project, currentVersion, currentUser) return { - project, - versions, - version, currentVersion, - reviewer, handlingEditors, + project, + reviewer, + version, + versions, } }, { @@ -114,7 +110,7 @@ export default compose( }), reduxForm({ form: 'review', - onSubmit, onChange: debounce(onChange, 1000, { maxWait: 5000 }), + onSubmit, }), )(ReviewLayout) diff --git a/packages/component-review/src/components/ReviewersPage.js b/packages/component-review/src/components/ReviewersPage.js index f5b97db8f..3b8dfa8c4 100644 --- a/packages/component-review/src/components/ReviewersPage.js +++ b/packages/component-review/src/components/ReviewersPage.js @@ -40,10 +40,10 @@ export default compose( reviewer._reviewer = projectReviewer }) - return { project, version, reviewers, reviewerUsers } + return { project, reviewers, reviewerUsers, version } }), withProps({ - ReviewerForm: ReviewerFormContainer, Reviewer: ReviewerContainer, + ReviewerForm: ReviewerFormContainer, }), )(Reviewers) diff --git a/packages/component-review/src/components/decision/DecisionForm.js b/packages/component-review/src/components/decision/DecisionForm.js index 31417feb9..ed32ac84f 100644 --- a/packages/component-review/src/components/decision/DecisionForm.js +++ b/packages/component-review/src/components/decision/DecisionForm.js @@ -1,14 +1,13 @@ import React from 'react' import { FormSection } from 'redux-form' -import { Button } from 'xpub-ui' import { NoteEditor } from 'xpub-edit' -import { Attachments, RadioGroup, ValidatedField } from 'xpub-ui' +import { Attachments, Button, RadioGroup, ValidatedField } from 'xpub-ui' import { withJournal } from 'xpub-journal' import { required } from 'xpub-validators' import classes from './DecisionForm.local.scss' const NoteInput = input => ( - <NoteEditor title="Decision" placeholder="Enter your decision…" {...input} /> + <NoteEditor placeholder="Enter your decision…" title="Decision" {...input} /> ) const AttachmentsInput = uploadFile => input => ( @@ -16,7 +15,7 @@ const AttachmentsInput = uploadFile => input => ( ) const RecommendationInput = journal => input => ( - <RadioGroup inline required options={journal.recommendations} {...input} /> + <RadioGroup inline options={journal.recommendations} required {...input} /> ) const DecisionForm = ({ journal, valid, handleSubmit, uploadFile }) => ( @@ -26,15 +25,15 @@ const DecisionForm = ({ journal, valid, handleSubmit, uploadFile }) => ( <div className={classes.note}> <div className={classes.content}> <ValidatedField + component={NoteInput} name="content" validate={[required]} - component={NoteInput} /> </div> <ValidatedField - name="attachments" component={AttachmentsInput(uploadFile)} + name="attachments" /> </div> </FormSection> @@ -42,14 +41,14 @@ const DecisionForm = ({ journal, valid, handleSubmit, uploadFile }) => ( <div className={classes.section}> <ValidatedField + component={RecommendationInput(journal)} name="recommendation" validate={[required]} - component={RecommendationInput(journal)} /> </div> <div> - <Button type="submit" primary disabled={!valid}> + <Button disabled={!valid} primary type="submit"> Submit </Button> </div> diff --git a/packages/component-review/src/components/decision/DecisionLayout.js b/packages/component-review/src/components/decision/DecisionLayout.js index a32f27291..295bed8ad 100644 --- a/packages/component-review/src/components/decision/DecisionLayout.js +++ b/packages/component-review/src/components/decision/DecisionLayout.js @@ -22,7 +22,7 @@ const DecisionLayout = ({ versions.forEach(version => { // TODO: allow multiple decisions, e.g. appeals - const decision = version.decision + const { decision } = version if (decision && decision.submitted) { const submittedMoment = moment(decision.submitted) @@ -30,8 +30,6 @@ const DecisionLayout = ({ const label = submittedMoment.format('YYYY-MM-DD') decisionSections.push({ - key, - label, content: ( <div> <ReviewMetadata version={version} /> @@ -39,23 +37,21 @@ const DecisionLayout = ({ <Decision decision={decision} /> </div> ), + key, + label, }) editorSections.push({ - key, - label, content: ( - <SimpleEditor - content={version.source} - layout="bare" - readOnly={true} - /> + <SimpleEditor content={version.source} layout="bare" readOnly /> ), + key, + label, }) } }, []) - const decision = currentVersion.decision + const { decision } = currentVersion if (!decision || !decision.submitted) { const submittedMoment = moment() @@ -63,32 +59,28 @@ const DecisionLayout = ({ const label = submittedMoment.format('YYYY-MM-DD') decisionSections.push({ - key, - label, content: ( <div> <ReviewMetadata version={currentVersion} /> <DecisionReviews version={currentVersion} /> <DecisionForm decision={decision} - valid={valid} handleSubmit={handleSubmit} uploadFile={uploadFile} + valid={valid} /> </div> ), + key, + label, }) editorSections.push({ - key, - label, content: ( - <SimpleEditor - content={currentVersion.source} - layout="bare" - readOnly={true} - /> + <SimpleEditor content={currentVersion.source} layout="bare" readOnly /> ), + key, + label, }) } @@ -96,16 +88,16 @@ const DecisionLayout = ({ <div className={classes.root}> <div className={classes.column}> <Tabs - sections={editorSections} activeKey={editorSections[editorSections.length - 1].key} + sections={editorSections} title="Versions" /> </div> <div className={classes.column}> <Tabs - sections={decisionSections} activeKey={decisionSections[decisionSections.length - 1].key} + sections={decisionSections} title="Versions" /> </div> diff --git a/packages/component-review/src/components/review/ReviewForm.js b/packages/component-review/src/components/review/ReviewForm.js index 6f40767b2..0c4a38429 100644 --- a/packages/component-review/src/components/review/ReviewForm.js +++ b/packages/component-review/src/components/review/ReviewForm.js @@ -1,14 +1,13 @@ import React from 'react' import { FormSection } from 'redux-form' -import { Button } from 'xpub-ui' import { NoteEditor } from 'xpub-edit' -import { Attachments, RadioGroup, ValidatedField } from 'xpub-ui' +import { Attachments, Button, RadioGroup, ValidatedField } from 'xpub-ui' import { withJournal } from 'xpub-journal' import { required } from 'xpub-validators' import classes from './ReviewForm.local.scss' const NoteInput = input => ( - <NoteEditor title="Review" placeholder="Enter your review…" {...input} /> + <NoteEditor placeholder="Enter your review…" title="Review" {...input} /> ) const AttachmentsInput = uploadFile => input => ( @@ -17,16 +16,16 @@ const AttachmentsInput = uploadFile => input => ( const ConfidentialInput = input => ( <NoteEditor - title="Confidential" placeholder="Enter a confidential note to the editor (optional)…" + title="Confidential" {...input} /> ) const RecommendationInput = journal => input => ( <RadioGroup - inline class={classes.class} + inline options={journal.recommendations} {...input} /> @@ -39,15 +38,15 @@ const ReviewForm = ({ journal, valid, handleSubmit, uploadFile }) => ( <div className={classes.note}> <div className={classes.content}> <ValidatedField + component={NoteInput} name="content" validate={[required]} - component={NoteInput} /> </div> <ValidatedField - name="attachments" component={AttachmentsInput(uploadFile)} + name="attachments" /> </div> </FormSection> @@ -57,10 +56,10 @@ const ReviewForm = ({ journal, valid, handleSubmit, uploadFile }) => ( <FormSection name="confidential"> <div className={classes.note}> <div className={classes.content}> - <ValidatedField name="content" component={ConfidentialInput} /> + <ValidatedField component={ConfidentialInput} name="content" /> </div> - <ValidatedField name="attachments" component={AttachmentsInput} /> + <ValidatedField component={AttachmentsInput} name="attachments" /> </div> </FormSection> </div> @@ -69,15 +68,15 @@ const ReviewForm = ({ journal, valid, handleSubmit, uploadFile }) => ( <FormSection name="Recommendation"> <div className={classes.title}>Recommendation</div> <ValidatedField + component={RecommendationInput(journal)} name="recommendation" validate={[required]} - component={RecommendationInput(journal)} /> </FormSection> </div> <div> - <Button type="submit" primary disabled={!valid}> + <Button disabled={!valid} primary type="submit"> Submit </Button> </div> diff --git a/packages/component-review/src/components/review/ReviewLayout.js b/packages/component-review/src/components/review/ReviewLayout.js index 8dd8baf92..2c762bab5 100644 --- a/packages/component-review/src/components/review/ReviewLayout.js +++ b/packages/component-review/src/components/review/ReviewLayout.js @@ -32,30 +32,26 @@ const ReviewLayout = ({ const label = submittedMoment.format('YYYY-MM-DD') reviewSections.push({ - key, - label, content: ( <div> <ReviewMetadata - version={version} handlingEditors={handlingEditors} + version={version} /> <Review review={review} /> </div> ), + key, + label, }) // TODO: need to include unreviewed versions? editorSections.push({ - key, - label, content: ( - <SimpleEditor - content={version.source} - layout="bare" - readOnly={true} - /> + <SimpleEditor content={version.source} layout="bare" readOnly /> ), + key, + label, }) } }, []) @@ -70,34 +66,30 @@ const ReviewLayout = ({ const label = submittedMoment.format('YYYY-MM-DD') reviewSections.push({ - key, - label, content: ( <div> <ReviewMetadata - version={currentVersion} handlingEditors={handlingEditors} + version={currentVersion} /> <ReviewForm - review={review} - valid={valid} handleSubmit={handleSubmit} + review={review} uploadFile={uploadFile} + valid={valid} /> </div> ), + key, + label, }) editorSections.push({ - key, - label, content: ( - <SimpleEditor - layout="bare" - content={currentVersion.source} - readOnly={true} - /> + <SimpleEditor content={currentVersion.source} layout="bare" readOnly /> ), + key, + label, }) } @@ -105,16 +97,16 @@ const ReviewLayout = ({ <div className={classes.root}> <div className={classes.manuscript}> <Tabs - sections={editorSections} activeKey={editorSections[editorSections.length - 1].key} + sections={editorSections} title="Versions" /> </div> <div className={classes.review}> <Tabs - sections={reviewSections} activeKey={reviewSections[reviewSections.length - 1].key} + sections={reviewSections} title="Versions" /> </div> diff --git a/packages/component-review/src/components/reviewers/Reviewer.js b/packages/component-review/src/components/reviewers/Reviewer.js index 49a2e9364..ec48c6c34 100644 --- a/packages/component-review/src/components/reviewers/Reviewer.js +++ b/packages/component-review/src/components/reviewers/Reviewer.js @@ -1,9 +1,10 @@ import React from 'react' import { map } from 'lodash' import Moment from 'react-moment' -import classes from './Reviewer.local.scss' import { Avatar, Button } from 'xpub-ui' +import classes from './Reviewer.local.scss' + const ordinalLetter = ordinal => { return ordinal ? String.fromCharCode(96 + ordinal) : null } @@ -11,10 +12,10 @@ const ordinalLetter = ordinal => { const Reviewer = ({ reviewer, removeReviewer }) => ( <div className={classes.root}> <Avatar - status={reviewer.status} - width={100} height={70} reviewerLetter={ordinalLetter(reviewer._reviewer.ordinal)} + status={reviewer.status} + width={100} /> <div className={classes.name}>{reviewer._user.username}</div> <div> diff --git a/packages/component-review/src/components/reviewers/ReviewerContainer.js b/packages/component-review/src/components/reviewers/ReviewerContainer.js index 3f4f6408c..f3ec7eb0c 100644 --- a/packages/component-review/src/components/reviewers/ReviewerContainer.js +++ b/packages/component-review/src/components/reviewers/ReviewerContainer.js @@ -4,7 +4,7 @@ import { actions } from 'pubsweet-client' import Reviewer from './Reviewer' const removeReviewer = props => () => { - const id = props.reviewer.id + const { id } = props.reviewer return props.deleteFragment(props.project, { id }) } diff --git a/packages/component-review/src/components/reviewers/ReviewerForm.js b/packages/component-review/src/components/reviewers/ReviewerForm.js index fadd7992f..6a94db20a 100644 --- a/packages/component-review/src/components/reviewers/ReviewerForm.js +++ b/packages/component-review/src/components/reviewers/ReviewerForm.js @@ -16,13 +16,13 @@ const OptionRenderer = option => ( const ReviewerInput = loadOptions => ({ input }) => ( <Select.AsyncCreatable {...input} - valueKey="id" - labelKey="username" + // autoload={false} filterOption={() => true} + labelKey="username" loadOptions={loadOptions} - promptTextCreator={label => `Add ${label}?`} optionRenderer={OptionRenderer} - // autoload={false} + promptTextCreator={label => `Add ${label}?`} + valueKey="id" /> ) @@ -35,13 +35,13 @@ const ReviewerForm = ({ }) => ( <form onSubmit={handleSubmit(onSubmit(reset))}> <Field + component={ReviewerInput(loadOptions)} name="user" validate={required} - component={ReviewerInput(loadOptions)} /> <div className={classes.actions}> - <Button type="submit" primary disabled={!valid}> + <Button disabled={!valid} primary type="submit"> Invite reviewer </Button> </div> diff --git a/packages/component-review/src/components/reviewers/ReviewerFormContainer.js b/packages/component-review/src/components/reviewers/ReviewerFormContainer.js index 1d0b68eb0..fd2255d5b 100644 --- a/packages/component-review/src/components/reviewers/ReviewerFormContainer.js +++ b/packages/component-review/src/components/reviewers/ReviewerFormContainer.js @@ -29,12 +29,12 @@ const addProjectReviewer = (props, user) => { const addReviewer = (props, projectReviewer) => { const reviewer = { - id: uuid(), - reviewer: projectReviewer.id, - status: 'invited', events: { invited: new Date().toString(), }, + id: uuid(), + reviewer: projectReviewer.id, + status: 'invited', } return props diff --git a/packages/component-review/src/components/reviewers/Reviewers.js b/packages/component-review/src/components/reviewers/Reviewers.js index bb286e093..923c82ed3 100644 --- a/packages/component-review/src/components/reviewers/Reviewers.js +++ b/packages/component-review/src/components/reviewers/Reviewers.js @@ -13,8 +13,8 @@ const Reviewers = ({ <div className={classes.form}> <ReviewerForm project={project} - version={version} reviewerUsers={reviewerUsers} + version={version} /> </div> diff --git a/packages/component-submit/src/components/Confirm.js b/packages/component-submit/src/components/Confirm.js index 1f03326d2..80042aec6 100644 --- a/packages/component-submit/src/components/Confirm.js +++ b/packages/component-submit/src/components/Confirm.js @@ -20,8 +20,8 @@ const Confirm = ({ toggleConfirming }) => ( proper attribution. (The journal employs{' '} <a href="https://www.crossref.org/services/similarity-check/" - target="_blank" rel="noopener noreferrer" + target="_blank" > CrossCheck </a>{' '} @@ -44,7 +44,7 @@ const Confirm = ({ toggleConfirming }) => ( </p> <div className={classes.actions}> - <Button type="submit" primary> + <Button primary type="submit"> Submit your manuscript </Button> <span className={classes.actionDivider}> or </span> diff --git a/packages/component-submit/src/components/Declarations.js b/packages/component-submit/src/components/Declarations.js index 0b8afc7ff..2ccced010 100644 --- a/packages/component-submit/src/components/Declarations.js +++ b/packages/component-submit/src/components/Declarations.js @@ -6,24 +6,24 @@ import { withJournal } from 'xpub-journal' import { required } from 'xpub-validators' import classes from './Declarations.local.scss' -const DeclarationInput = input => <YesOrNo inline={true} {...input} /> +const DeclarationInput = input => <YesOrNo inline {...input} /> const Declarations = ({ journal }) => { return ( <FormSection name="declarations"> {journal.declarations.questions.map(question => ( <div - key={question.id} - id={`declarations.${question.id}`} className={classnames(classes.section, classes.spread)} + id={`declarations.${question.id}`} + key={question.id} > <div className={classes.legend}>{question.legend}</div> <ValidatedField + component={DeclarationInput} name={question.id} required validate={[required]} - component={DeclarationInput} /> </div> ))} diff --git a/packages/component-submit/src/components/Metadata.js b/packages/component-submit/src/components/Metadata.js index 231811b4a..4702c8536 100644 --- a/packages/component-submit/src/components/Metadata.js +++ b/packages/component-submit/src/components/Metadata.js @@ -3,7 +3,6 @@ import { FormSection } from 'redux-form' import { AbstractEditor, TitleEditor } from 'xpub-edit' import { CheckboxGroup, Menu, TextField, ValidatedField } from 'xpub-ui' import { withJournal } from 'xpub-journal' -import classes from './Metadata.local.scss' import { join, required, @@ -13,6 +12,8 @@ import { split, } from 'xpub-validators' +import classes from './Metadata.local.scss' + const minSize1 = minSize(1) const minChars20 = minChars(20) const minChars100 = minChars(100) @@ -25,8 +26,8 @@ const TitleInput = input => ( const AbstractInput = input => ( <AbstractEditor - title="Abstract" placeholder="Enter the abstract…" + title="Abstract" {...input} /> ) @@ -51,19 +52,19 @@ const Metadata = ({ journal }) => ( <FormSection name="metadata"> <div className={classes.section} id="metadata.title"> <ValidatedField + component={TitleInput} name="title" required validate={[minChars20, maxChars500]} - component={TitleInput} /> </div> <div className={classes.section} id="metadata.abstract"> <ValidatedField + component={AbstractInput} name="abstract" required validate={[minChars100, maxChars5000]} - component={AbstractInput} /> </div> @@ -71,12 +72,12 @@ const Metadata = ({ journal }) => ( <div className={classes.label}>Authors</div> <ValidatedField - name="authors" - required + component={AuthorsInput} format={join()} + name="authors" parse={split()} + required validate={[minSize1]} - component={AuthorsInput} /> </div> @@ -84,12 +85,12 @@ const Metadata = ({ journal }) => ( <div className={classes.label}>Keywords</div> <ValidatedField - name="keywords" - required + component={KeywordsInput} format={join()} + name="keywords" parse={split()} + required validate={[minSize1]} - component={KeywordsInput} /> </div> @@ -97,10 +98,10 @@ const Metadata = ({ journal }) => ( <div className={classes.label}>Type of article</div> <ValidatedField + component={ArticleTypeInput(journal)} name="articleType" required validate={[required]} - component={ArticleTypeInput(journal)} /> </div> @@ -108,10 +109,10 @@ const Metadata = ({ journal }) => ( <div className={classes.label}>Section</div> <ValidatedField + component={ArticleSectionInput(journal)} name="articleSection" required validate={[required]} - component={ArticleSectionInput(journal)} /> </div> </FormSection> diff --git a/packages/component-submit/src/components/Notes.js b/packages/component-submit/src/components/Notes.js index d19bb3046..3dd379f8a 100644 --- a/packages/component-submit/src/components/Notes.js +++ b/packages/component-submit/src/components/Notes.js @@ -25,16 +25,16 @@ const Notes = () => ( <FormSection name="notes"> <div className={classes.section} id="notes.fundingAcknowledgement"> <ValidatedField + component={FundingInput} name="fundingAcknowledgement" validate={[required]} - component={FundingInput} /> </div> <div className={classes.section} id="notes.specialInstructions"> <ValidatedField - name="specialInstructions" component={InstructionsInput} + name="specialInstructions" /> </div> </FormSection> diff --git a/packages/component-submit/src/components/Submit.js b/packages/component-submit/src/components/Submit.js index c150c7d0a..d1bbe7c2c 100644 --- a/packages/component-submit/src/components/Submit.js +++ b/packages/component-submit/src/components/Submit.js @@ -50,7 +50,7 @@ const Submit = ({ <SupplementaryFiles uploadFile={uploadFile} /> <div> - <Button type="button" primary onClick={toggleConfirming}> + <Button onClick={toggleConfirming} primary type="button"> Submit your manuscript </Button> </div> @@ -62,11 +62,11 @@ const Submit = ({ )} </form> - {/*<div className={classes.validots}> + {/* <div className={classes.validots}> <Validots valid={valid} handleSubmit={handleSubmit}/> - </div>*/} + </div> */} </div> ) diff --git a/packages/component-submit/src/components/SubmitPage.js b/packages/component-submit/src/components/SubmitPage.js index 6b0449db8..7cf7c29b1 100644 --- a/packages/component-submit/src/components/SubmitPage.js +++ b/packages/component-submit/src/components/SubmitPage.js @@ -90,10 +90,10 @@ export default compose( } }), reduxForm({ - form: 'submit', // enableReinitialize: true, - onSubmit, + form: 'submit', onChange: debounce(onChange, 1000, { maxWait: 5000 }), + onSubmit, }), withState('confirming', 'setConfirming', false), withHandlers({ diff --git a/packages/component-submit/src/components/Suggestions.js b/packages/component-submit/src/components/Suggestions.js index c416eee36..ecba81ed8 100644 --- a/packages/component-submit/src/components/Suggestions.js +++ b/packages/component-submit/src/components/Suggestions.js @@ -33,10 +33,10 @@ const Suggestions = () => ( <div className={classes.sublegend}>Suggested reviewers</div> <ValidatedField - name="suggested" + component={SuggestedReviewerInput} format={joinComma} + name="suggested" parse={splitComma} - component={SuggestedReviewerInput} /> </div> @@ -44,10 +44,10 @@ const Suggestions = () => ( <div className={classes.sublegend}>Opposed reviewers</div> <ValidatedField - name="opposed" + component={OpposedReviewerInput} format={joinComma} + name="opposed" parse={splitComma} - component={OpposedReviewerInput} /> </div> </FormSection> @@ -61,10 +61,10 @@ const Suggestions = () => ( <div className={classes.sublegend}>Suggested editors</div> <ValidatedField - name="suggested" + component={SuggestedEditorInput} format={joinComma} + name="suggested" parse={splitComma} - component={SuggestedEditorInput} /> </div> @@ -72,10 +72,10 @@ const Suggestions = () => ( <div className={classes.sublegend}>Opposed editors</div> <ValidatedField - name="opposed" + component={OpposedEditorInput} format={joinComma} + name="opposed" parse={splitComma} - component={OpposedEditorInput} /> </div> </FormSection> diff --git a/packages/component-submit/src/components/SupplementaryFiles.js b/packages/component-submit/src/components/SupplementaryFiles.js index 2330f2543..1fd8827a0 100644 --- a/packages/component-submit/src/components/SupplementaryFiles.js +++ b/packages/component-submit/src/components/SupplementaryFiles.js @@ -14,7 +14,7 @@ const SupplementaryFiles = ({ uploadFile }) => ( Upload supplementary materials </div> - <ValidatedField name="supplementary" component={FileInput(uploadFile)} /> + <ValidatedField component={FileInput(uploadFile)} name="supplementary" /> </div> </FormSection> ) diff --git a/packages/component-submit/src/components/Validots.js b/packages/component-submit/src/components/Validots.js index 1a19c0535..70b3d649e 100644 --- a/packages/component-submit/src/components/Validots.js +++ b/packages/component-submit/src/components/Validots.js @@ -13,11 +13,11 @@ export const Validots = ({ form, valid, handleSubmit }) => ( {form.registeredFields && map(form.registeredFields, field => ( <div key={field.name}> - <Field name={field.name} component={Validot} /> + <Field component={Validot} name={field.name} /> </div> ))} - <button onClick={handleSubmit} disabled={!valid}> + <button disabled={!valid} onClick={handleSubmit}> Submit </button> </div> diff --git a/packages/xpub-edit/src/components/HtmlEditor.js b/packages/xpub-edit/src/components/HtmlEditor.js index b1584a44b..48519fb4a 100644 --- a/packages/xpub-edit/src/components/HtmlEditor.js +++ b/packages/xpub-edit/src/components/HtmlEditor.js @@ -58,13 +58,13 @@ class HtmlEditor extends React.Component { return ( <Editor - options={options} className={className} + onBlur={this.onBlur} + onChange={this.onChange} + options={options} placeholder={placeholder} placeholderClassName={placeholderClassName} title={title} - onChange={this.onChange} - onBlur={this.onBlur} /> ) } diff --git a/packages/xpub-edit/src/components/MenuBar.js b/packages/xpub-edit/src/components/MenuBar.js index 4510877e5..605c74af4 100644 --- a/packages/xpub-edit/src/components/MenuBar.js +++ b/packages/xpub-edit/src/components/MenuBar.js @@ -11,14 +11,14 @@ const MenuBar = ({ title, menu, state, dispatch }) => { const Button = (item, key) => ( <button - key={key} className={classnames({ [classes.button]: true, [classes.active]: item.active && item.active(state), })} - title={item.title} disabled={item.enable && !item.enable(state)} + key={key} onMouseDown={handle(item.run)} + title={item.title} > {item.content} </button> diff --git a/packages/xpub-edit/src/components/abstract/AbstractEditor.js b/packages/xpub-edit/src/components/abstract/AbstractEditor.js index 55ef57d60..ea14634f7 100644 --- a/packages/xpub-edit/src/components/abstract/AbstractEditor.js +++ b/packages/xpub-edit/src/components/abstract/AbstractEditor.js @@ -12,14 +12,14 @@ const AbstractEditor = ({ onChange, }) => ( <HtmlEditor - options={options} - value={value} className={className} + onBlur={onBlur} + onChange={onChange} + options={options} placeholder={placeholder} placeholderClassName={placeholderClassName} title={title} - onBlur={onBlur} - onChange={onChange} + value={value} /> ) diff --git a/packages/xpub-edit/src/components/abstract/AbstractViewer.js b/packages/xpub-edit/src/components/abstract/AbstractViewer.js index 6a8ad3a01..4f4e707b2 100644 --- a/packages/xpub-edit/src/components/abstract/AbstractViewer.js +++ b/packages/xpub-edit/src/components/abstract/AbstractViewer.js @@ -3,7 +3,7 @@ import HtmlViewer from '../HtmlViewer' import * as options from './config' const AbstractViewer = ({ className, value }) => ( - <HtmlViewer className={className} value={value} options={options} /> + <HtmlViewer className={className} options={options} value={value} /> ) export default AbstractViewer diff --git a/packages/xpub-edit/src/components/abstract/config/icons.js b/packages/xpub-edit/src/components/abstract/config/icons.js index ac6303711..83b212795 100644 --- a/packages/xpub-edit/src/components/abstract/config/icons.js +++ b/packages/xpub-edit/src/components/abstract/config/icons.js @@ -1,11 +1,13 @@ import React from 'react' export default { - italic: <i>Ital</i>, bold: <b>Bold</b>, - superscript: ( + heading: <span>Section Title</span>, + italic: <i>Ital</i>, + link: <span>Link</span>, + small_caps: ( <span> - t<sup>x</sup> + T<span style={{ fontSize: '70%', fontVariant: 'small-caps' }}>T</span> </span> ), subscript: ( @@ -13,11 +15,9 @@ export default { t<sub>x</sub> </span> ), - small_caps: ( + superscript: ( <span> - T<span style={{ fontVariant: 'small-caps', fontSize: '70%' }}>T</span> + t<sup>x</sup> </span> ), - heading: <span>Section Title</span>, - link: <span>Link</span>, } diff --git a/packages/xpub-edit/src/components/abstract/config/keys.js b/packages/xpub-edit/src/components/abstract/config/keys.js index aa83d95ce..96bd95922 100644 --- a/packages/xpub-edit/src/components/abstract/config/keys.js +++ b/packages/xpub-edit/src/components/abstract/config/keys.js @@ -13,18 +13,18 @@ import { import schema from './schema' const keys = { - 'Mod-z': undo, - 'Shift-Mod-z': redo, Backspace: undoInputRule, - 'Mod-y': redo, + 'Ctrl-Enter': exitCode, Escape: selectParentNode, 'Mod-b': toggleMark(schema.marks.bold), - 'Mod-i': toggleMark(schema.marks.italic), 'Mod-Enter': exitCode, - 'Shift-Enter': exitCode, - 'Ctrl-Enter': exitCode, + 'Mod-i': toggleMark(schema.marks.italic), + 'Mod-y': redo, + 'Mod-z': undo, 'Shift-Ctrl-0': setBlockType(schema.nodes.paragraph), 'Shift-Ctrl-1': setBlockType(schema.nodes.heading, { level: 1 }), + 'Shift-Enter': exitCode, + 'Shift-Mod-z': redo, } Object.keys(baseKeymap).forEach(key => { diff --git a/packages/xpub-edit/src/components/abstract/config/marks.js b/packages/xpub-edit/src/components/abstract/config/marks.js index 823e598de..5af69382a 100644 --- a/packages/xpub-edit/src/components/abstract/config/marks.js +++ b/packages/xpub-edit/src/components/abstract/config/marks.js @@ -6,11 +6,11 @@ const link = { inclusive: false, parseDOM: [ { - tag: 'a[href]', getAttrs: dom => ({ href: dom.getAttribute('href'), title: dom.getAttribute('title'), }), + tag: 'a[href]', }, ], toDOM: node => ['a', node.attrs], @@ -25,12 +25,12 @@ const bold = { parseDOM: [ { tag: 'strong' }, { - tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null, + tag: 'b', }, { - style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null, + style: 'font-weight', }, ], toDOM: () => ['b'], @@ -52,10 +52,10 @@ const small_caps = { } export default { - link, - italic, bold, + italic, + link, + small_caps, subscript, superscript, - small_caps, } diff --git a/packages/xpub-edit/src/components/abstract/config/menu.js b/packages/xpub-edit/src/components/abstract/config/menu.js index aaf0b14fa..2e607f0da 100644 --- a/packages/xpub-edit/src/components/abstract/config/menu.js +++ b/packages/xpub-edit/src/components/abstract/config/menu.js @@ -33,36 +33,48 @@ const promptForURL = () => { } export default { - marks: { - italic: { - title: 'Toggle italic', - content: icons.italic, - active: markActive(schema.marks.italic), - run: toggleMark(schema.marks.italic), + blocks: { + h1: { + active: blockActive(schema.nodes.heading, { level: 1 }), + content: icons.heading, + enable: setBlockType(schema.nodes.heading, { level: 1 }), + run: (state, dispatch) => { + if (blockActive(schema.marks.heading)(state)) { + setBlockType(schema.marks.paragraph)(state, dispatch) + return true + } + + setBlockType(schema.nodes.heading, { level: 1 })(state, dispatch) + }, + title: 'Change to heading level 1', + }, + }, + history: { + redo: { + content: icons.redo, + enable: redo, + run: redo, + title: 'Redo last undone change', }, + undo: { + content: icons.undo, + enable: undo, + run: undo, + title: 'Undo last change', + }, + }, + marks: { bold: { - title: 'Toggle bold', - content: icons.bold, active: markActive(schema.marks.bold), + content: icons.bold, run: toggleMark(schema.marks.bold), + title: 'Toggle bold', }, - subscript: { - title: 'Toggle subscript', - content: icons.subscript, - active: markActive(schema.marks.subscript), - run: toggleMark(schema.marks.subscript), - }, - superscript: { - title: 'Toggle superscript', - content: icons.superscript, - active: markActive(schema.marks.superscript), - run: toggleMark(schema.marks.superscript), - }, - small_caps: { - title: 'Toggle small caps', - content: icons.small_caps, - active: markActive(schema.marks.small_caps), - run: toggleMark(schema.marks.small_caps), + italic: { + active: markActive(schema.marks.italic), + content: icons.italic, + run: toggleMark(schema.marks.italic), + title: 'Toggle italic', }, // link: { // title: 'Add or remove link', @@ -82,35 +94,23 @@ export default { // // view.focus() // } // } - }, - blocks: { - h1: { - title: 'Change to heading level 1', - content: icons.heading, - active: blockActive(schema.nodes.heading, { level: 1 }), - enable: setBlockType(schema.nodes.heading, { level: 1 }), - run: (state, dispatch) => { - if (blockActive(schema.marks.heading)(state)) { - setBlockType(schema.marks.paragraph)(state, dispatch) - return true - } - - setBlockType(schema.nodes.heading, { level: 1 })(state, dispatch) - }, + small_caps: { + active: markActive(schema.marks.small_caps), + content: icons.small_caps, + run: toggleMark(schema.marks.small_caps), + title: 'Toggle small caps', }, - }, - history: { - undo: { - title: 'Undo last change', - content: icons.undo, - enable: undo, - run: undo, + subscript: { + active: markActive(schema.marks.subscript), + content: icons.subscript, + run: toggleMark(schema.marks.subscript), + title: 'Toggle subscript', }, - redo: { - title: 'Redo last undone change', - content: icons.redo, - enable: redo, - run: redo, + superscript: { + active: markActive(schema.marks.superscript), + content: icons.superscript, + run: toggleMark(schema.marks.superscript), + title: 'Toggle superscript', }, }, } diff --git a/packages/xpub-edit/src/components/abstract/config/nodes.js b/packages/xpub-edit/src/components/abstract/config/nodes.js index 1e7463337..3d59ea01e 100644 --- a/packages/xpub-edit/src/components/abstract/config/nodes.js +++ b/packages/xpub-edit/src/components/abstract/config/nodes.js @@ -14,8 +14,8 @@ const heading = { level: { default: 1 }, }, content: 'inline*', - group: 'block', defining: true, + group: 'block', parseDOM: [{ tag: 'h1', attrs: { level: 1 } }], toDOM: node => ['h' + node.attrs.level, 0], } @@ -26,7 +26,7 @@ const text = { export default { doc, - paragraph, heading, + paragraph, text, } diff --git a/packages/xpub-edit/src/components/abstract/config/schema.js b/packages/xpub-edit/src/components/abstract/config/schema.js index 5a0173ddd..2b1161ddf 100644 --- a/packages/xpub-edit/src/components/abstract/config/schema.js +++ b/packages/xpub-edit/src/components/abstract/config/schema.js @@ -3,4 +3,4 @@ import { Schema } from 'prosemirror-model' import nodes from './nodes' import marks from './marks' -export default new Schema({ nodes, marks }) +export default new Schema({ marks, nodes }) diff --git a/packages/xpub-edit/src/components/note/NoteEditor.js b/packages/xpub-edit/src/components/note/NoteEditor.js index 8c31be952..9bddee2da 100644 --- a/packages/xpub-edit/src/components/note/NoteEditor.js +++ b/packages/xpub-edit/src/components/note/NoteEditor.js @@ -12,14 +12,14 @@ const NoteEditor = ({ onChange, }) => ( <HtmlEditor - options={options} className={className} - value={value} + onBlur={onBlur} + onChange={onChange} + options={options} placeholder={placeholder} placeholderClassName={placeholderClassName} title={title} - onBlur={onBlur} - onChange={onChange} + value={value} /> ) diff --git a/packages/xpub-edit/src/components/note/NoteViewer.js b/packages/xpub-edit/src/components/note/NoteViewer.js index e5adc8039..c9b47a3c9 100644 --- a/packages/xpub-edit/src/components/note/NoteViewer.js +++ b/packages/xpub-edit/src/components/note/NoteViewer.js @@ -3,7 +3,7 @@ import HtmlViewer from '../HtmlViewer' import * as options from './config' const NoteViewer = ({ className, value }) => ( - <HtmlViewer className={className} value={value} options={options} /> + <HtmlViewer className={className} options={options} value={value} /> ) export default NoteViewer diff --git a/packages/xpub-edit/src/components/note/config/icons.js b/packages/xpub-edit/src/components/note/config/icons.js index 54669c596..0e348d6cc 100644 --- a/packages/xpub-edit/src/components/note/config/icons.js +++ b/packages/xpub-edit/src/components/note/config/icons.js @@ -1,11 +1,12 @@ import React from 'react' export default { - italic: <i>Ital</i>, bold: <b>Bold</b>, - superscript: ( + italic: <i>Ital</i>, + link: <span>Link</span>, + small_caps: ( <span> - t<sup>x</sup> + T<span style={{ fontSize: '70%', fontVariant: 'small-caps' }}>T</span> </span> ), subscript: ( @@ -13,10 +14,9 @@ export default { t<sub>x</sub> </span> ), - small_caps: ( + superscript: ( <span> - T<span style={{ fontVariant: 'small-caps', fontSize: '70%' }}>T</span> + t<sup>x</sup> </span> ), - link: <span>Link</span>, } diff --git a/packages/xpub-edit/src/components/note/config/keys.js b/packages/xpub-edit/src/components/note/config/keys.js index 8919b9398..26b803102 100644 --- a/packages/xpub-edit/src/components/note/config/keys.js +++ b/packages/xpub-edit/src/components/note/config/keys.js @@ -12,16 +12,16 @@ import { import schema from './schema' const keys = { - 'Mod-z': undo, - 'Shift-Mod-z': redo, Backspace: undoInputRule, - 'Mod-y': redo, + 'Ctrl-Enter': exitCode, Escape: selectParentNode, 'Mod-b': toggleMark(schema.marks.bold), - 'Mod-i': toggleMark(schema.marks.italic), 'Mod-Enter': exitCode, + 'Mod-i': toggleMark(schema.marks.italic), + 'Mod-y': redo, + 'Mod-z': undo, 'Shift-Enter': exitCode, - 'Ctrl-Enter': exitCode, + 'Shift-Mod-z': redo, } Object.keys(baseKeymap).forEach(key => { diff --git a/packages/xpub-edit/src/components/note/config/marks.js b/packages/xpub-edit/src/components/note/config/marks.js index 823e598de..5af69382a 100644 --- a/packages/xpub-edit/src/components/note/config/marks.js +++ b/packages/xpub-edit/src/components/note/config/marks.js @@ -6,11 +6,11 @@ const link = { inclusive: false, parseDOM: [ { - tag: 'a[href]', getAttrs: dom => ({ href: dom.getAttribute('href'), title: dom.getAttribute('title'), }), + tag: 'a[href]', }, ], toDOM: node => ['a', node.attrs], @@ -25,12 +25,12 @@ const bold = { parseDOM: [ { tag: 'strong' }, { - tag: 'b', getAttrs: node => node.style.fontWeight !== 'normal' && null, + tag: 'b', }, { - style: 'font-weight', getAttrs: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null, + style: 'font-weight', }, ], toDOM: () => ['b'], @@ -52,10 +52,10 @@ const small_caps = { } export default { - link, - italic, bold, + italic, + link, + small_caps, subscript, superscript, - small_caps, } diff --git a/packages/xpub-edit/src/components/note/config/schema.js b/packages/xpub-edit/src/components/note/config/schema.js index 5a0173ddd..2b1161ddf 100644 --- a/packages/xpub-edit/src/components/note/config/schema.js +++ b/packages/xpub-edit/src/components/note/config/schema.js @@ -3,4 +3,4 @@ import { Schema } from 'prosemirror-model' import nodes from './nodes' import marks from './marks' -export default new Schema({ nodes, marks }) +export default new Schema({ marks, nodes }) diff --git a/packages/xpub-edit/src/components/text/TextEditor.js b/packages/xpub-edit/src/components/text/TextEditor.js index 8e924c9f4..ceff4e78f 100644 --- a/packages/xpub-edit/src/components/text/TextEditor.js +++ b/packages/xpub-edit/src/components/text/TextEditor.js @@ -16,14 +16,14 @@ const TextEditor = ({ onChange, }) => ( <HtmlEditor - options={options} className={className} - value={value} + onBlur={onBlur} + onChange={onChange} + options={options} placeholder={placeholder} placeholderClassName={placeholderClassName} title={title} - onBlur={onBlur} - onChange={onChange} + value={value} /> ) diff --git a/packages/xpub-edit/src/components/text/TextViewer.js b/packages/xpub-edit/src/components/text/TextViewer.js index a839a047e..5ec627f49 100644 --- a/packages/xpub-edit/src/components/text/TextViewer.js +++ b/packages/xpub-edit/src/components/text/TextViewer.js @@ -4,7 +4,7 @@ import HtmlViewer from '../HtmlViewer' import * as options from './config' const TextViewer = ({ className, value }) => ( - <HtmlViewer className={className} value={value} options={options} /> + <HtmlViewer className={className} options={options} value={value} /> ) export default TextViewer diff --git a/packages/xpub-edit/src/components/text/config/schema.js b/packages/xpub-edit/src/components/text/config/schema.js index e5ee6b963..3a13a3861 100644 --- a/packages/xpub-edit/src/components/text/config/schema.js +++ b/packages/xpub-edit/src/components/text/config/schema.js @@ -4,4 +4,4 @@ import nodes from './nodes' const marks = {} -export default new Schema({ nodes, marks }) +export default new Schema({ marks, nodes }) diff --git a/packages/xpub-edit/src/components/title/TitleEditor.js b/packages/xpub-edit/src/components/title/TitleEditor.js index 1edecf9a1..fc10ccda8 100644 --- a/packages/xpub-edit/src/components/title/TitleEditor.js +++ b/packages/xpub-edit/src/components/title/TitleEditor.js @@ -12,14 +12,14 @@ const TitleEditor = ({ onChange, }) => ( <HtmlEditor - options={options} className={className} - value={value} + onBlur={onBlur} + onChange={onChange} + options={options} placeholder={placeholder} placeholderClassName={placeholderClassName} title={title} - onBlur={onBlur} - onChange={onChange} + value={value} /> ) diff --git a/packages/xpub-edit/src/components/title/TitleViewer.js b/packages/xpub-edit/src/components/title/TitleViewer.js index 475d8fb28..d73bb2b7e 100644 --- a/packages/xpub-edit/src/components/title/TitleViewer.js +++ b/packages/xpub-edit/src/components/title/TitleViewer.js @@ -3,7 +3,7 @@ import HtmlViewer from '../HtmlViewer' import * as options from './config' const TitleViewer = ({ className, value }) => ( - <HtmlViewer options={options} className={className} value={value} /> + <HtmlViewer className={className} options={options} value={value} /> ) export default TitleViewer diff --git a/packages/xpub-edit/src/components/title/config/icons.js b/packages/xpub-edit/src/components/title/config/icons.js index 8558c9c0a..df1f1d484 100644 --- a/packages/xpub-edit/src/components/title/config/icons.js +++ b/packages/xpub-edit/src/components/title/config/icons.js @@ -2,9 +2,9 @@ import React from 'react' export default { italic: <i>Ital</i>, - superscript: ( + small_caps: ( <span> - t<sup>x</sup> + T<span style={{ fontSize: '70%', fontVariant: 'small-caps' }}>T</span> </span> ), subscript: ( @@ -12,9 +12,9 @@ export default { t<sub>x</sub> </span> ), - small_caps: ( + superscript: ( <span> - T<span style={{ fontVariant: 'small-caps', fontSize: '70%' }}>T</span> + t<sup>x</sup> </span> ), } diff --git a/packages/xpub-edit/src/components/title/config/keys.js b/packages/xpub-edit/src/components/title/config/keys.js index c6b1becf1..620a35d94 100644 --- a/packages/xpub-edit/src/components/title/config/keys.js +++ b/packages/xpub-edit/src/components/title/config/keys.js @@ -6,11 +6,11 @@ import { baseKeymap, toggleMark, chainCommands } from 'prosemirror-commands' import schema from './schema' const keys = { - 'Mod-z': undo, - 'Shift-Mod-z': redo, Backspace: undoInputRule, - 'Mod-y': redo, 'Mod-i': toggleMark(schema.marks.italic), + 'Mod-y': redo, + 'Mod-z': undo, + 'Shift-Mod-z': redo, } Object.keys(baseKeymap).forEach(key => { diff --git a/packages/xpub-edit/src/components/title/config/marks.js b/packages/xpub-edit/src/components/title/config/marks.js index 148061a89..4eec3d32c 100644 --- a/packages/xpub-edit/src/components/title/config/marks.js +++ b/packages/xpub-edit/src/components/title/config/marks.js @@ -20,7 +20,7 @@ const small_caps = { export default { italic, + small_caps, subscript, superscript, - small_caps, } diff --git a/packages/xpub-edit/src/components/title/config/menu.js b/packages/xpub-edit/src/components/title/config/menu.js index 1983e79a7..4edbe4a70 100644 --- a/packages/xpub-edit/src/components/title/config/menu.js +++ b/packages/xpub-edit/src/components/title/config/menu.js @@ -14,28 +14,28 @@ const markActive = type => state => { export default { marks: { italic: { - title: 'Toggle italic', - content: icons.italic, active: markActive(schema.marks.italic), + content: icons.italic, run: toggleMark(schema.marks.italic), + title: 'Toggle italic', + }, + small_caps: { + active: markActive(schema.marks.small_caps), + content: icons.small_caps, + run: toggleMark(schema.marks.small_caps), + title: 'Toggle small caps', }, subscript: { - title: 'Toggle subscript', - content: icons.subscript, active: markActive(schema.marks.subscript), + content: icons.subscript, run: toggleMark(schema.marks.subscript), + title: 'Toggle subscript', }, superscript: { - title: 'Toggle superscript', - content: icons.superscript, active: markActive(schema.marks.superscript), + content: icons.superscript, run: toggleMark(schema.marks.superscript), - }, - small_caps: { - title: 'Toggle small caps', - content: icons.small_caps, - active: markActive(schema.marks.small_caps), - run: toggleMark(schema.marks.small_caps), + title: 'Toggle superscript', }, }, } diff --git a/packages/xpub-edit/src/components/title/config/schema.js b/packages/xpub-edit/src/components/title/config/schema.js index 5a0173ddd..2b1161ddf 100644 --- a/packages/xpub-edit/src/components/title/config/schema.js +++ b/packages/xpub-edit/src/components/title/config/schema.js @@ -3,4 +3,4 @@ import { Schema } from 'prosemirror-model' import nodes from './nodes' import marks from './marks' -export default new Schema({ nodes, marks }) +export default new Schema({ marks, nodes }) diff --git a/packages/xpub-edit/src/decorations.js b/packages/xpub-edit/src/decorations.js index a88259e45..221da8dfe 100644 --- a/packages/xpub-edit/src/decorations.js +++ b/packages/xpub-edit/src/decorations.js @@ -1,7 +1,7 @@ import { DecorationSet, Decoration } from 'prosemirror-view' export default ({ props, classes }) => state => { - const doc = state.doc + const { doc } = state const decorations = [] if ( diff --git a/packages/xpub-edit/styleguide.config.js b/packages/xpub-edit/styleguide.config.js index b4faf2a00..b67773b61 100644 --- a/packages/xpub-edit/styleguide.config.js +++ b/packages/xpub-edit/styleguide.config.js @@ -1,22 +1,22 @@ module.exports = { - title: 'xpub-edit style guide', + context: { + faker: 'faker', + }, + serverPort: 6066, + skipComponentsWithoutExample: true, styleguideComponents: { StyleGuideRenderer: require.resolve( 'xpub-styleguide/src/components/StyleGuideRenderer', ), Wrapper: require.resolve('xpub-styleguide/src/components/Wrapper'), }, - serverPort: 6066, - skipComponentsWithoutExample: true, - context: { - faker: 'faker', - }, theme: { - fontFamily: { - base: '"Fira Sans", sans-serif', - }, color: { link: 'cornflowerblue', }, + fontFamily: { + base: '"Fira Sans", sans-serif', + }, }, + title: 'xpub-edit style guide', } -- GitLab