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

create editor

parent 7ecec3d3
No related branches found
No related tags found
1 merge request!289Pm node views portals
...@@ -20,10 +20,29 @@ const initialValue = { ...@@ -20,10 +20,29 @@ const initialValue = {
content: [ content: [
{ {
type: 'paragraph', type: 'paragraph',
attrs: {
id: '',
class: 'paragraph',
track: [],
group: '',
viewid: '',
},
content: [ content: [
{ {
type: 'text', type: 'text',
text: 'A normal block of a paragraph of text', text: ' ',
},
{
type: 'multiple_choice',
attrs: {
id: '206bda35-858e-422d-a90d-164b7f460eb0',
},
content: [
{
type: 'text',
text: 'sss',
},
],
}, },
], ],
}, },
...@@ -37,8 +56,13 @@ const Hhmi = () => { ...@@ -37,8 +56,13 @@ const Hhmi = () => {
config={config} config={config}
autoFocus autoFocus
fileUpload={file => renderImage(file)} fileUpload={file => renderImage(file)}
<<<<<<< HEAD
value="" value=""
// targetFormat="JSON" // targetFormat="JSON"
=======
value={initialValue}
targetFormat="JSON"
>>>>>>> create editor
// readonly // readonly
layout={HhmiLayout} layout={HhmiLayout}
onChange={source => console.log(source)} onChange={source => console.log(source)}
......
...@@ -3,12 +3,16 @@ import React, { ...@@ -3,12 +3,16 @@ import React, {
useEffect, useEffect,
useRef, useRef,
useMemo, useMemo,
useCallback, useLayoutEffect,
useState, useState,
} from 'react'; } from 'react';
import { EditorState } from 'prosemirror-state'; import { EditorState } from 'prosemirror-state';
import { EditorView } from 'prosemirror-view'; import { EditorView } from 'prosemirror-view';
import { StepMap } from 'prosemirror-transform'; import { StepMap } from 'prosemirror-transform';
import { baseKeymap } from 'prosemirror-commands';
import { keymap } from 'prosemirror-keymap';
import { undo, redo } from 'prosemirror-history';
import styled from 'styled-components'; import styled from 'styled-components';
const styles = { const styles = {
...@@ -24,11 +28,9 @@ const EditorWrapper = styled.div` ...@@ -24,11 +28,9 @@ const EditorWrapper = styled.div`
export default ({ node, view, getPos }) => { export default ({ node, view, getPos }) => {
const [showExplanation, setShowExplanation] = useState(false); const [showExplanation, setShowExplanation] = useState(false);
} }
// }
const clickMe = () => { const clickMe = () => {
setShowExplanation(true); setShowExplanation(true);
showExp = true;
// view.dispatch(view.state.tr); // view.dispatch(view.state.tr);
}; };
......
...@@ -10,6 +10,11 @@ const multipleChoiceNode = { ...@@ -10,6 +10,11 @@ const multipleChoiceNode = {
parseDOM: [ parseDOM: [
{ {
tag: 'multiple-choice', tag: 'multiple-choice',
getAttrs(dom) {
return {
id: dom.getAttribute('id'),
};
},
}, },
], ],
}; };
......
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