@@ -4,23 +4,22 @@ import {
44} from 'semantic-ui-react' ;
55
66import ReactDOM from 'react-dom' ;
7+ import { SlateTransformer } from '@accordproject/markdown-slate' ;
8+
79import './index.css' ;
810import MarkdownAsInputEditor from '../../src/MarkdownAsInputEditor' ;
911import SlateAsInputEditor from '../../src/SlateAsInputEditor' ;
10- import PluginManager from '../../src/PluginManager' ;
11- import FromMarkdown from '../../src/markdown/fromMarkdown' ;
1212
1313import * as serviceWorker from './serviceWorker' ;
1414import 'semantic-ui-css/semantic.min.css' ;
15- import List from '../../src/plugins/list' ;
16- import Video from '../../src/plugins/video' ;
1715import NoEdit from '../../src/plugins/noedit' ;
16+ import List from '../../src/plugins/list' ;
17+
18+ const plugins = [ NoEdit ( ) , List ( ) ] ;
19+ const slateTransformer = new SlateTransformer ( ) ;
1820
19- const plugins = [ List ( ) , Video ( ) , NoEdit ( ) ] ;
20- const pluginManager = new PluginManager ( plugins ) ;
21- const fromMarkdown = new FromMarkdown ( pluginManager ) ;
21+ const defaultMarkdown = `# My Heading
2222
23- const defaultMarkdown = `# Heading One
2423This is text. This is *italic* text. This is **bold** text. This is a [link](https://clause.io). This is \`inline code\`.
2524
2625This is ***bold and italic*** text
4342
4443### Sub heading
4544
46- Video:
47-
48- <video/>
49-
50- Another video:
45+ This is more text.
5146
52- <video src="https://www.youtube.com/embed/cmmq-JBMbbQ"/>` ;
47+ Fin.
48+ ` ;
5349
5450const propsObj = {
5551 WIDTH : '600px' ,
@@ -63,23 +59,22 @@ function Demo() {
6359 /**
6460 * Current Slate Value
6561 */
66- const [ slateValue , setSlateValue ] = useState ( fromMarkdown . convert ( defaultMarkdown ) ) ;
62+ const [ slateValue , setSlateValue ] = useState ( slateTransformer . fromMarkdown ( defaultMarkdown ) ) ;
6763 const [ markdown , setMarkdown ] = useState ( defaultMarkdown ) ;
6864
6965 /**
7066 * Called when the markdown changes
7167 */
72- const onMarkdownChange = useCallback ( ( slateValue , markdown ) => {
68+ const onMarkdownChange = useCallback ( ( markdown ) => {
7369 localStorage . setItem ( 'markdown-editor' , markdown ) ;
74- // setSlateValue(slateValue);
75- // setMarkdown(markdown);
7670 } , [ ] ) ;
7771
7872 /**
7973 * Called when the Slate Value changes
8074 */
81- const onSlateValueChange = useCallback ( ( slateValue , markdown ) => {
75+ const onSlateValueChange = useCallback ( ( slateValue ) => {
8276 localStorage . setItem ( 'slate-editor-value' , slateValue . toJSON ( ) ) ;
77+ const markdown = slateTransformer . toMarkdown ( slateValue ) ;
8378 setSlateValue ( slateValue ) ;
8479 setMarkdown ( markdown ) ;
8580 } , [ ] ) ;
0 commit comments