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

now accepts draftjs model as input, stringified model#32

Open
cherucole wants to merge 1 commit intoreact-native-toolkit:setup-bobfrom
cherucole:setup-bob
Open

now accepts draftjs model as input, stringified model#32
cherucole wants to merge 1 commit intoreact-native-toolkit:setup-bobfrom
cherucole:setup-bob

Conversation

@cherucole
Copy link
Copy Markdown

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
Copy Markdown
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

Comment thread draftjs-web/src/App.tsx
try {
if (data) {
setEditorState(EditorState.createWithContent(stateFromHTML(data)));
const stateFromBlob = convertFromRaw(JSON.parse(data));
Copy link
Copy Markdown
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"}

Comment thread draftjs-web/src/App.tsx
import { ICustomWindow } from './types/ICustomWindow';

declare let window: ICustomWindow;
const blob =
Copy link
Copy Markdown
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.

2 participants