Awesome project! At the moment their are 3 known rich text editor for dash at this moment. pip install dash-quill
, pip install dash-summernote
and now pip install dash-mdxeditor
.
I’m the creator behind the dash summernote: Dash
Honestly summernote and mdxeditor are very close in functionality. Differences I could spot between the two was the image and video field I have setup in summernote. Working though providing links, I haven’t been able to figure out an alternative solution for the uploading image from the users computer. Curious to understand your thoughts as I noticed on the base library MdxEditor their was an image field yet when you setup your specific package in dash it isn’t provided. Have you touched on the image field for the rich text editor?
Outside of that another small difference is the ability to change text color and highlight text from summernote toolbar.
On the contrary, the codesandbox and overall dropdown functionality of MdxEditor is superior in my opinion. Really like the admonition and dif mode and overal header of the editor.
Great project, really appreciate seeing stuff like this. For those having trouble setting it up, just to add some context to what @jgomezgadea has setup, make sure you have the latest dash installed then at the top of the app.py before the imports you can setup the REACT_VERSION with adding:
import os
# Set the environment variable
os.environ['REACT_VERSION'] = '18.2.0'
Lastly, a constructive improvement I can mention is to make the props selectable for the component rather than just rendering the full component. Should be fairly easy to setup default props and prop type for src/lib/components/MdxEditor.tsx
for context this is my equivalent with summernote:
import React, { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import ReactSummernote from 'react-summernote';
import 'react-summernote/dist/react-summernote.css';
import 'bootstrap/js/dist/modal';
import 'bootstrap/js/dist/dropdown';
import 'bootstrap/js/dist/tooltip';
import 'bootstrap/dist/css/bootstrap.css';
const DashSummernote = (props) => {
const {id, setProps, value, toolbar, height} = props;
return (
<ReactSummernote
id={id}
value={value}
options={{
height: height,
dialogsInBody: true,
toolbar: toolbar
}}
onChange={(content) => {
setProps({ value: content });
}}
/>
);
}
DashSummernote.defaultProps = {};
DashSummernote.propTypes = {
id: PropTypes.string,
value: PropTypes.string,
setProps: PropTypes.func,
toolbar: PropTypes.array,
height: PropTypes.number
};
export default DashSummernote;
which allows me to change the props from the component from the python file via:
dash_summernote.DashSummernote(
id='summernote',
value='my-value',
toolbar=[
["style", ["style"]],
["font", ["bold", "underline", "clear"]],
["fontname", ["fontname"]],
["para", ["ul", "ol", "paragraph"]],
["table", ["table"]],
["insert", ["link", "picture", "video"]],
["view", ["fullscreen", "codeview"]]
],
height=300
)
If you did the same you could allow users to change the toolbar options dynamically.
OH! And welcome to Plotly! Saw this is your first post, what an impressive introduction.