diff --git a/examples/draft-0-10-0/playground/src/App.css b/examples/draft-0-10-0/playground/src/App.css index 3192189fcb..5ed23255bb 100644 --- a/examples/draft-0-10-0/playground/src/App.css +++ b/examples/draft-0-10-0/playground/src/App.css @@ -19,6 +19,7 @@ } .playground-main select { + width: 100px; background: #843131; } @@ -102,6 +103,21 @@ color: #C15757; } +.nav-main .nav-experiment-selector option, +.nav-main .nav-experiment-selector { + background: transparent; + border: none; + color: #fff; + cursor: pointer; + outline: none; + text-align-last: right; +} + +.nav-main .nav-experiment-selector option { + color: #000; + padding: 10px 0px; +} + .nav-home img { vertical-align: -17px; margin-right: 4px; @@ -140,3 +156,14 @@ /** sad :( but seems to not be a way to overwrite that by configuration */ background: var(--main-background) !important; } + +.RichEditor-editor { + padding: 10px 20px; +} + +/** + * basic style for handling nested lists + */ +.RichEditor-editor li[data-block] li[data-block] { + margin-left: 20px; +} diff --git a/examples/draft-0-10-0/playground/src/App.js b/examples/draft-0-10-0/playground/src/App.js index 46a92d2717..5ffd92fb19 100644 --- a/examples/draft-0-10-0/playground/src/App.js +++ b/examples/draft-0-10-0/playground/src/App.js @@ -17,15 +17,21 @@ import DraftJsRichEditorExample from './DraftJsRichEditorExample'; import JSONTree from 'react-json-tree'; import {convertToHTML} from 'draft-convert'; import PanelGroup from 'react-panelgroup'; +import gkx from 'draft-js/lib/gkx'; +import convertFromHTMLModern from 'draft-js/lib/convertFromHTMLToContentBlocks2'; import { ContentState, EditorState, - convertFromHTML, + convertFromHTML as convertFromHTMLClassic, convertToRaw, convertFromRaw, } from 'draft-js'; +const fromHTML = gkx('draft_refactored_html_importer') + ? convertFromHTMLModern + : convertFromHTMLClassic; + const theme = { scheme: 'monokai', author: 'wimer hazenberg (http://www.monokai.nl)', @@ -58,9 +64,18 @@ const baseRawContent = { entityMap: {}, }; -const baseHtmlContent = ` -

heading inside blockquote

-

paragraph inside blockquote

+const baseHtmlContent = `
    +
  1. one
  2. +
  3. + +
  4. +
  5. three
  6. +
`; const BASE_CONTENT = { @@ -108,7 +123,7 @@ class DraftJsPlaygroundContainer extends Component { }; _setHTMLContent(html) { - const parsedHtml = convertFromHTML(html); + const parsedHtml = fromHTML(html); if (!parsedHtml) { return; @@ -145,10 +160,13 @@ class DraftJsPlaygroundContainer extends Component { }; onSelectChange = ({target: {value: mode}}) => { - this.setState({mode}); + this.setState({ + mode, + codeMirrorValue: BASE_CONTENT[mode], + }); }; - updateCodeMirror = (editor, data, codeMirrorValue) => { + updateCodeMirror = codeMirrorValue => { this.setState({codeMirrorValue}); }; @@ -158,6 +176,12 @@ class DraftJsPlaygroundContainer extends Component { ); }; + onExperimentChange = ({target: {value: experimentFlags}}) => { + if (experimentFlags) { + window.location.search = `gk_enable=${experimentFlags}`; + } + }; + render() { const {editorState, mode, codeMirrorValue} = this.state; @@ -173,6 +197,20 @@ class DraftJsPlaygroundContainer extends Component { Draft.js