react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

highlighting code

Open mirik999 opened this issue 7 years ago • 6 comments

Hi people, anybody can explain please, how to highlight code with any module (highlight or prism or any module) ?

mirik999 avatar Jan 05 '18 13:01 mirik999

+1

lcasartelli avatar Mar 26 '18 16:03 lcasartelli

+1, this is a killer feature for me.

ferrao avatar Oct 03 '18 11:10 ferrao

If I can get some guidance, I am ok with putting work on this @jpuri.

ferrao avatar Oct 03 '18 11:10 ferrao

I have just been able to grab the editor state from rdw and convert it into the right state to load on a plain draft-js editor with prism syntax highlight support.

This is enough for my use case, as I have different components for editing and viewing. Let me know if this interests you @lcasartelli.

ferrao avatar Oct 03 '18 18:10 ferrao

hey guys, did you find a solution? trying to decide between SlateJS and this package. been struggling for weeks with this @ferrao @lcasartelli

ScottAgirs avatar Mar 19 '20 04:03 ScottAgirs

Using the color picker override I created a component with font and highlight colors

toolbar={{
   colorPicker: { component: FontColorPickers },
 }}
import FontColor from "./font-color";
import HighLightColor from "./highlight-color";

function FontColorPickers(props) {
  return (
    <div style={{ display: "flex" }}>
      <FontColor {...props} />
      <HighLightColor {...props} />
    </div>
  );
}

Using the documented example for overriding the picker to write my custom pickers. Then in the for the highlight the only difference is the first argument passed back in the onChange.

FontColor:

  const onPickerChange = color => {
    onChange("color", color.hex);
  };

Highlight:

const onPickerChange = color => {
    onChange("bgcolor", color .hex);
    setOpen(false);
 };

cpdwyer avatar Mar 29 '22 14:03 cpdwyer