-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUGFIX: 3839 show warn dialog before ckeditor formatting gets lost
- Loading branch information
Showing
8 changed files
with
211 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/neos-ui-redux-store/src/UI/InlineEditorMarkupDerivationDialog/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import produce from 'immer'; | ||
import {action as createAction, ActionType} from 'typesafe-actions'; | ||
|
||
import {InitAction} from '../../System'; | ||
|
||
export interface State extends Readonly<{ | ||
isOpen: boolean; | ||
acknowledgement?: 'CANCELED' | 'CONFIRMED' | ||
}> {} | ||
|
||
export const defaultState: State = { | ||
isOpen: false | ||
}; | ||
|
||
// | ||
// Export the action types | ||
// | ||
export enum actionTypes { | ||
OPEN = '@neos/neos-ui/UI/InlineEditorMarkupDerivationDialog/OPEN', | ||
CANCEL = '@neos/neos-ui/UI/InlineEditorMarkupDerivationDialog/CANCEL', | ||
CONFIRM = '@neos/neos-ui/UI/InlineEditorMarkupDerivationDialog/CONFIRM' | ||
} | ||
|
||
/** | ||
* Opens the modal | ||
*/ | ||
const open = () => createAction(actionTypes.OPEN); | ||
|
||
/** | ||
* Closes the modal | ||
*/ | ||
const cancel = () => createAction(actionTypes.CANCEL); | ||
|
||
/** | ||
* Confirms the modal | ||
*/ | ||
const confirm = () => createAction(actionTypes.CONFIRM); | ||
|
||
// | ||
// Export the actions | ||
// | ||
export const actions = { | ||
open, | ||
cancel, | ||
confirm | ||
}; | ||
|
||
export type Action = ActionType<typeof actions>; | ||
|
||
// | ||
// Export the reducer | ||
// | ||
export const reducer = (state: State = defaultState, action: InitAction | Action) => produce(state, draft => { | ||
switch (action.type) { | ||
case actionTypes.OPEN: { | ||
draft.isOpen = true; | ||
draft.acknowledgement = undefined; | ||
break; | ||
} | ||
case actionTypes.CANCEL: { | ||
draft.isOpen = false; | ||
draft.acknowledgement = 'CANCELED'; | ||
break; | ||
} | ||
case actionTypes.CONFIRM: { | ||
draft.isOpen = false; | ||
draft.acknowledgement = 'CONFIRMED'; | ||
break; | ||
} | ||
} | ||
}); | ||
|
||
export const selectors = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ntainers/Modals/InlineEditorMarkupDerivationDialog/InlineEditorMarkupDerivationDialog.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import {connect} from 'react-redux'; | ||
|
||
import {actions} from '@neos-project/neos-ui-redux-store'; | ||
import {Button, Dialog, Icon} from '@neos-project/react-ui-components'; | ||
import I18n from '@neos-project/neos-ui-i18n'; | ||
|
||
import style from './style.module.css'; | ||
|
||
const withReduxState = connect((state) => ({ | ||
isOpen: state?.ui?.inlineEditorMarkupDerivationDialog?.isOpen | ||
}), { | ||
onCancel: actions.UI.InlineEditorMarkupDerivationDialog.cancel, | ||
onConfirm: actions.UI.InlineEditorMarkupDerivationDialog.confirm | ||
}); | ||
|
||
export const InlineEditorMarkupDerivationDialog = withReduxState((props) => { | ||
if (!props.isOpen) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Dialog | ||
actions={[ | ||
<Button | ||
key="cancel" | ||
style="lighter" | ||
hoverStyle="brand" | ||
onClick={props.onCancel} | ||
> | ||
<I18n | ||
id="Neos.Neos.Ui:InlineEditorMarkupDerivationDialog:cancel" | ||
fallback="Cancel" | ||
/> | ||
</Button>, | ||
<Button | ||
key="confirm" | ||
style="warn" | ||
hoverStyle="warn" | ||
onClick={props.onConfirm} | ||
> | ||
<Icon icon="i-cursor" className={style.buttonIcon} /> | ||
<I18n | ||
id="Neos.Neos.Ui:InlineEditorMarkupDerivationDialog:confirm" | ||
fallback="Edit" | ||
/> | ||
</Button> | ||
]} | ||
title={<div> | ||
<Icon icon="highlighter"/> | ||
<span className={style.modalTitle}> | ||
<I18n | ||
id="Neos.Neos.Ui:InlineEditorMarkupDerivationDialog:title" | ||
fallback="Unexpected formatting in text" | ||
/> | ||
</span> | ||
</div>} | ||
onRequestClose={props.onCancel} | ||
type="warn" | ||
isOpen | ||
autoFocus | ||
> | ||
<div className={style.modalContents}> | ||
<I18n | ||
id="Neos.Neos.Ui:InlineEditorMarkupDerivationDialog:message" | ||
fallback="By editing this text its formatting might partially be lost." | ||
/> | ||
</div> | ||
</Dialog> | ||
); | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/neos-ui/src/Containers/Modals/InlineEditorMarkupDerivationDialog/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export {InlineEditorMarkupDerivationDialog} from './InlineEditorMarkupDerivationDialog'; |
9 changes: 9 additions & 0 deletions
9
packages/neos-ui/src/Containers/Modals/InlineEditorMarkupDerivationDialog/style.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.modalTitle { | ||
margin-left: var(--spacing-Full); | ||
} | ||
.modalContents { | ||
padding: var(--spacing-Full); | ||
} | ||
.buttonIcon { | ||
margin-right: var(--spacing-Half); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters