Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

now accepts draftjs model as input, stringified model #32

Open
wants to merge 1 commit into
base: setup-bob
Choose a base branch
from

Conversation

cherucole
Copy link

Hi Dani, this is the fix for making the library accept input of type 'draft-js' model instead of html so no need to convert to editor-state using additional libraries and also extracting plain text as well

Copy link
Member

@DaniAkash DaniAkash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems to introduce breaking changes. Please check my comments @cherucole

@@ -80,7 +88,8 @@ function App() {
const setDefaultValue = (data: defaultSourceType) => {
try {
if (data) {
setEditorState(EditorState.createWithContent(stateFromHTML(data)));
const stateFromBlob = convertFromRaw(JSON.parse(data));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have the text editor running for other people that uses HTML as the default input.

We probably have to keep using html as the default data for the inputs. However, provide an additional layer that will accept default value using different formats.

For eg:
If the user provides defaultValue as a string, it will accept the value as HTML.
To provide defaultValue as Markdown, Raw or HTML, we can have an object, that receives the data as

{type: "md", value: "value as markdown"}
{type: "raw", value: "value as raw stringified object"}
{type: "html", value: "value as html"}

@@ -17,6 +20,8 @@ import EditorController from './Components/EditorController/EditorController';
import { ICustomWindow } from './types/ICustomWindow';

declare let window: ICustomWindow;
const blob =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we need this data for...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants