draft-js-plugins

How to programatically add mentions using draft-js-mention-plugin?

北慕城南 提交于 2020-08-05 09:44:23
问题 The problem : I'm trying to create an edit interface for contents created with draft-js + draft-js-mention-plugin . However, editorState wasn't persisted, only plain text. Mentions were saved as an array of objects. Now I need to recreate the editorState with that data. Example: I have a plain text like this: const content = '@marcello we need to add spell check' And a mentions array with objects like this: const mentions = [{ length: 8, offset: 0, user: 'user:59441f5c37b1e209c300547d', }] To

Render html saved from draft-js

六眼飞鱼酱① 提交于 2019-12-19 09:10:41
问题 I'm learning React: totally newbie. If I save in DB the HTML directly from draft.js (or it's variants always based on it) and then in a view page of my React SPA I retrieve HTML from DB through my API: QUESTIONS: how can I render that HTML? dangerouslySetInnerHTML? Or maybe one of this (what do you suggest?)? https://github.com/wrakky/react-html-parser https://github.com/pveyes/htmr https://github.com/remarkablemark/html-react-parser https://github.com/utatti/react-render-html https://github

How to stop DraftJS cursor jumping to beginning of text?

血红的双手。 提交于 2019-12-11 04:23:09
问题 Code involved using DraftJS and Meteor Js application Task - Make a live preview where text from DraftJS will get saved to DB and from DB it get displayed on another component. But problem is once data comes from DB and I try to edit DraftJS cursor moved to the beginning. Code is import {Editor, EditorState, ContentState} from 'draft-js'; import React, { Component } from 'react'; import { TestDB } from '../api/yaml-component.js'; import { createContainer } from 'meteor/react-meteor-data';