Draft.js copy paste styles?

Greetings to all. Who worked with draft.js? Need help...
Sobstvenno code below adds the editor to text, everything works fine, but a question arises:
From the Editor there are options in which I describe the tools I need, in fact I only need a couple. But how about the fact that when you copy and paste text from a text Editor pulls out unnecessary styles, including color, spacing etc. I know there stripPastedStyles the editor that disables the copying of styles. But I need to recognize links, and other styles there. How to be?
jyWG6R2.png
import React { useState, useEffect } from 'react';
import { Editor } from 'react-draft-wysiwyg';
import { EditorState, convertToRaw, convertFromRaw } from 'draft-js';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';

export default function TextEditor({ description, changeDescription }) {

 const rawDescription = convertFromRaw(JSON.parse(description));
 const [content, setContent] = useState(
EditorState.createWithContent(rawDescription)
);

 const toolbar = {
 options: ['inline', 'link', 'list', 'textAlign', 'history'],
 inline: { inDropdown: true },
 list: { inDropdown: true },
 textAlign: { inDropdown: true },
};

 const handleChangeDescription = editorState => {
 const contentState = editorState.getCurrentContent();
 const json = JSON.stringify(convertToRaw(contentState));
setContent(editorState);
changeDescription(json);
};

 return (
 <div className="text-form-editor">
<Editor
wrapperClassName="demo-wrapper"
 editorClassName="nts-input-desc-editor-custom-styles"
editorState={content}
onEditorStateChange={handleChangeDescription}
toolbar={toolbar}
/>
</div>
);
}
April 4th 20 at 13:22
0 answer

Find more questions by tags JavaScriptReact