Skip to content
Snippets Groups Projects
Commit 2f579a37 authored by chris's avatar chris
Browse files

set content

parent f4c407d2
No related branches found
No related tags found
1 merge request!391Matching question
...@@ -70,7 +70,7 @@ const Editors = () => { ...@@ -70,7 +70,7 @@ const Editors = () => {
case 'ncbi': case 'ncbi':
return <NCBI />; return <NCBI />;
default: default:
return <HHMI />; return <Editoria />;
} }
}; };
......
import React from 'react'; import React, { useCallback, useState } from 'react';
import { Wax } from 'wax-prosemirror-core'; import { Wax } from 'wax-prosemirror-core';
import styled from 'styled-components'; import styled from 'styled-components';
...@@ -35,6 +35,14 @@ const TitleEditor = styled.div` ...@@ -35,6 +35,14 @@ const TitleEditor = styled.div`
width: 80px; width: 80px;
`; `;
const TitleEditorExport = styled.div`
background: #fff;
height: 20px;
position: relative;
top: 2px;
width: 120px;
`;
const ThirdEditorWrapper = styled.div` const ThirdEditorWrapper = styled.div`
margin-top: 30px; margin-top: 30px;
display: flex; display: flex;
...@@ -48,11 +56,20 @@ const ThirdEditor = styled.div` ...@@ -48,11 +56,20 @@ const ThirdEditor = styled.div`
`; `;
const ContentArea = styled.div` const ContentArea = styled.div`
height: 250px; height: 200px;
border: 1px solid black; border: 1px solid black;
overflow-y: auto;
`; `;
let a = '';
const Ncbi = () => { const Ncbi = () => {
const [content, setContent] = useState('');
const getContent = source => {
setContent(savedContent => `${savedContent} ${source}`);
};
return ( return (
<Wrapper> <Wrapper>
<FirstTwoWrapper> <FirstTwoWrapper>
...@@ -78,13 +95,13 @@ const Ncbi = () => { ...@@ -78,13 +95,13 @@ const Ncbi = () => {
</FirstTwoWrapper> </FirstTwoWrapper>
<ThirdEditorWrapper> <ThirdEditorWrapper>
<ThirdEditor> <ThirdEditor>
<ContentArea></ContentArea> <TitleEditorExport>Export On Enter</TitleEditorExport>
<ContentArea dangerouslySetInnerHTML={{ __html: content }} />
<Wax <Wax
config={configEnter} config={configEnter(getContent)}
autoFocus autoFocus
value=""
layout={EnterLayout} layout={EnterLayout}
placeholder="Start Typing ..." placeholder="Start Typing and press enter..."
/> />
</ThirdEditor> </ThirdEditor>
</ThirdEditorWrapper> </ThirdEditorWrapper>
......
...@@ -10,11 +10,13 @@ import { ...@@ -10,11 +10,13 @@ import {
EnterService, EnterService,
} from 'wax-prosemirror-services'; } from 'wax-prosemirror-services';
const getContentOnEnter = source => { import invisibles, {
console.log('editor content', source); space,
}; hardBreak,
paragraph,
} from '@guardian/prosemirror-invisibles';
const config = { const configEnter = getContent => ({
MenuService: [ MenuService: [
{ {
templateArea: 'topBar', templateArea: 'topBar',
...@@ -36,8 +38,12 @@ const config = { ...@@ -36,8 +38,12 @@ const config = {
ShortCutsService: {}, ShortCutsService: {},
LinkService: {}, LinkService: {},
SchemaService: DefaultSchema, SchemaService: DefaultSchema,
PmPlugins: [], PmPlugins: [invisibles([hardBreak()])],
EnterService: { getContentOnEnter }, EnterService: {
getContentOnEnter: source => {
getContent(source);
},
},
services: [ services: [
new EnterService(), new EnterService(),
...@@ -49,6 +55,6 @@ const config = { ...@@ -49,6 +55,6 @@ const config = {
new ListsService(), new ListsService(),
new BaseToolGroupService(), new BaseToolGroupService(),
], ],
}; });
export default config; export default configEnter;
...@@ -62,6 +62,7 @@ const EditorContainer = styled.div` ...@@ -62,6 +62,7 @@ const EditorContainer = styled.div`
.ProseMirror { .ProseMirror {
border-top: none; border-top: none;
line-height: 1.6em;
margin-right: ${grid(1)}; margin-right: ${grid(1)};
padding: ${grid(1)}; padding: ${grid(1)};
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment