diff --git a/editors/demo/src/Editoria/config/config.js b/editors/demo/src/Editoria/config/config.js index 5cc22496654502259e273a5874f1b40c93253104..51b31b2968790c2ceed79ac394c2c7e7c9fb233b 100644 --- a/editors/demo/src/Editoria/config/config.js +++ b/editors/demo/src/Editoria/config/config.js @@ -45,6 +45,8 @@ import { CustomTagService, YjsService, disallowPasteImagesPlugin, + BlockDropDownToolGroupService, + TitleToolGroupService, } from 'wax-prosemirror-services'; import { EditoriaSchema } from 'wax-prosemirror-core'; @@ -62,8 +64,8 @@ import CharactersList from './CharactersList'; // }; const updateTitle = debounce(title => { - // console.log(title); -}, 3000); + console.log(title); +}, 100); const saveTags = tags => { // console.log(tags); @@ -83,6 +85,8 @@ export default { templateArea: 'mainMenuToolBar', toolGroups: [ 'Base', + 'BlockDropDown', + 'TitleTool', { name: 'Annotations', more: [ @@ -105,10 +109,10 @@ export default { 'FullScreen', ], }, - { - templateArea: 'leftSideBar', - toolGroups: ['DisplayText'], - }, + // { + // templateArea: 'leftSideBar', + // toolGroups: ['DisplayText'], + // }, { templateArea: 'commentTrackToolBar', toolGroups: ['TrackCommentOptions'], @@ -172,7 +176,9 @@ export default { // }, services: [ + new TitleToolGroupService(), // new YjsService(), + new BlockDropDownToolGroupService(), new CustomTagService(), new DisplayBlockLevelService(), new DisplayToolGroupService(), @@ -196,7 +202,7 @@ export default { new CodeBlockService(), new CodeBlockToolGroupService(), new EditingSuggestingService(), - new DisplayTextToolGroupService(), + // new DisplayTextToolGroupService(), new MathService(), new FindAndReplaceService(), new TrackingAndEditingToolGroupService(), diff --git a/wax-prosemirror-services/index.js b/wax-prosemirror-services/index.js index e413c6e6ad8de85cc606246d4baa92c0eab4d3db..d2c016666ce2b14fe8e4449255bc2fbcff9043fc 100644 --- a/wax-prosemirror-services/index.js +++ b/wax-prosemirror-services/index.js @@ -68,7 +68,7 @@ export { default as QuestionsDropDownToolGroupService } from './src/WaxToolGroup export { default as OENContainersToolGroupService } from './src/WaxToolGroups/OENContainersToolGroupService/OENContainersToolGroupService'; export { default as OENLeftToolGroupService } from './src/WaxToolGroups/OENLeftToolGroupService/OENLeftToolGroupService'; export { default as FindAndReplaceToolGroupService } from './src/WaxToolGroups/FindAndReplaceToolGroupService/FindAndReplaceToolGroupService'; - +export { default as TitleToolGroupService } from './src/WaxToolGroups/TitleToolGroupService/TitleToolGroupService'; /* Plugins */ export { default as disallowPasteImagesPlugin } from './src/ImageService/plugins/disallowPasteImagesPlugin'; diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js index 1896a291388f8db837ccf5b6587d0d77b3b01e17..e88b3af8088c3a33bd053e0588bcffe161975099 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js @@ -43,7 +43,9 @@ const Label = styled.label` `; const SwitchComponent = props => { - const { className, label, labelPosition, onChange, ...rest } = props; + const { className, label, labelPosition, onChange, text, ...rest } = props; + + const ariaLabel = `Is it correct ${text}`; return ( <Wrapper className={className}> @@ -53,7 +55,7 @@ const SwitchComponent = props => { </Label> )} - <Switch aria-label="Is it correct" onChange={onChange} {...rest} /> + <Switch aria-label={ariaLabel} onChange={onChange} {...rest} /> {label && labelPosition === 'right' && ( <Label labelPosition={labelPosition} onClick={onChange}> diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js index cdf6481287a05ca6c69f508a1a919b8be9a42333..5261c7e9f2a3f19b7eb673635baf40a3f2793101 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js @@ -6,6 +6,7 @@ const CustomSwitch = ({ node, getPos }) => { const context = useContext(WaxContext); const [checked, setChecked] = useState(false); const [checkedAnswerMode, setCheckedAnswerMode] = useState(false); + const { pmViews: { main }, } = context; @@ -45,6 +46,17 @@ const CustomSwitch = ({ node, getPos }) => { }); }; + const getUpdatedNode = () => { + let nodeFound = node; + const allNodes = getNodes(main); + allNodes.forEach(singNode => { + if (singNode.node.attrs.id === node.attrs.id) { + nodeFound = singNode; + } + }); + return nodeFound; + }; + return ( <YesNoSwitch checked={checked} @@ -52,7 +64,7 @@ const CustomSwitch = ({ node, getPos }) => { customProps={customProps} handleChange={handleChange} isEditable={isEditable} - node={node} + node={getUpdatedNode()} /> ); }; diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js index 7451482d3f36fbf62ecd28a69681b38b6b0cb5c3..6d847117a0457a783b5f16d7b2a00f4d7892c128 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js @@ -44,7 +44,7 @@ const StyledIconWrong = styled(Icon)` `; const YesNoSwitch = ({ customProps, - node, + node: { node }, isEditable, handleChange, checked, @@ -83,6 +83,7 @@ const YesNoSwitch = ({ label="Correct?" labelPosition="left" onChange={handleChange} + text={node.textContent} unCheckedChildren="NO" /> ); diff --git a/wax-prosemirror-services/src/WaxToolGroups/BlockDropDownToolGroupService/BlockDropDownComponent.js b/wax-prosemirror-services/src/WaxToolGroups/BlockDropDownToolGroupService/BlockDropDownComponent.js index c24e0fb3dd21f83478605ba3abdbf041c721ee29..d49baaaa0ce26af13f7ced05c0cd392791cc954b 100644 --- a/wax-prosemirror-services/src/WaxToolGroups/BlockDropDownToolGroupService/BlockDropDownComponent.js +++ b/wax-prosemirror-services/src/WaxToolGroups/BlockDropDownToolGroupService/BlockDropDownComponent.js @@ -14,8 +14,9 @@ const DropdownStyled = styled(Dropdown)` opacity: ${props => (props.select ? 1 : 0.4)}; pointer-events: ${props => (props.select ? 'default' : 'none')}; .Dropdown-control { + width: 170px; border: none; - padding: 12px 122px 8px 10px; + padding: 12px 26px 8px 10px; &:hover { box-shadow: none; } @@ -26,7 +27,7 @@ const DropdownStyled = styled(Dropdown)` } .Dropdown-menu { - width: 100.4%; + width: 102%; display: flex; flex-direction: column; align-items: flex-start; @@ -46,7 +47,7 @@ const BlockDropDownComponent = ({ view, tools }) => { const [label, setLabel] = useState(null); const dropDownOptions = [ - { label: 'Title (H1)', value: '0', item: tools[0] }, + // { label: 'Title (H1)', value: '0', item: tools[0] }, // { label: 'author', value: '1', item: tools[1] }, // { label: 'Subtitle', value: '2', item: tools[2] }, // { label: 'Epigraph Prose', value: '3', item: tools[3] }, diff --git a/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleTool.js b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleTool.js new file mode 100644 index 0000000000000000000000000000000000000000..ffb22fec4ab399504d1f968bb056c4ca3ae309a2 --- /dev/null +++ b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleTool.js @@ -0,0 +1,14 @@ +import { injectable, inject } from 'inversify'; +import { ToolGroup } from 'wax-prosemirror-core'; + +@injectable() +class TitleTool extends ToolGroup { + tools = []; + + constructor(@inject('Title') title) { + super(); + this.tools = [title]; + } +} + +export default TitleTool; diff --git a/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleToolGroupService.js b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleToolGroupService.js new file mode 100644 index 0000000000000000000000000000000000000000..b034747792b976b615b66d0a066312b1b1ca3b56 --- /dev/null +++ b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/TitleToolGroupService.js @@ -0,0 +1,11 @@ +import { Service } from 'wax-prosemirror-core'; +import TitleTool from './TitleTool'; +import './titleTool.css'; + +class TitleToolGroupService extends Service { + register() { + this.container.bind('TitleTool').to(TitleTool); + } +} + +export default TitleToolGroupService; diff --git a/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/titleTool.css b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/titleTool.css new file mode 100644 index 0000000000000000000000000000000000000000..4f95e94a8c5913c3a6ec11666cf393c8b0616493 --- /dev/null +++ b/wax-prosemirror-services/src/WaxToolGroups/TitleToolGroupService/titleTool.css @@ -0,0 +1,3 @@ + div[data-name='TitleTool'] button { + width: 90px; + } \ No newline at end of file