Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use code syntax highlight plugin in react wrapper #909

Closed
zzzmj opened this issue Apr 17, 2020 · 2 comments
Closed

How to use code syntax highlight plugin in react wrapper #909

zzzmj opened this issue Apr 17, 2020 · 2 comments
Labels

Comments

@zzzmj
Copy link

zzzmj commented Apr 17, 2020

Summary

How to use code syntax highlight plugin in react wrapper

Screenshot

image

Version

Write the version of the editor you are currently using.

Additional context

import { Editor } from '@toast-ui/react-editor';
import hljs from 'highlight.js';
import codeSyntaxHightlight from '@toast-ui/editor-plugin-code-syntax-highlight';
import 'codemirror/lib/codemirror.css';
import '@toast-ui/editor/dist/toastui-editor.css';

//...

<Editor
  className="editor"
  ref={editorEl}
  previewStyle="vertical"
  height="600px"
  initialEditType="markdown"
  plugins={[
    [codeSyntaxHightlight, { hljs }]
  ]}
/>
@zzzmj zzzmj added the Question label Apr 17, 2020
@DoonDoony
Copy link

@zzzmj

In my case, It worked using .bind(hljs)
e.g,.

import React from "react";
import 'codemirror/lib/codemirror.css';
import 'highlight.js/styles/github.css';
import 'tui-color-picker/dist/tui-color-picker.css';
import '@toast-ui/editor/dist/toastui-editor.css';

import { Editor } from "@toast-ui/react-editor";
import colorSyntaxPlugin from "@toast-ui/editor-plugin-color-syntax";
import hljs from "highlight.js";
import codeSyntaxHighlightPlugin from "@toast-ui/editor-plugin-code-syntax-highlight";



export default class App extends React.Component<any, any> {
  render() {
    return (
      <div>
        <Editor
          initialValue="Hello World"
          previewStyle="vertical"
          height="600px"
          plugins={[codeSyntaxHighlightPlugin.bind(hljs), colorSyntaxPlugin]}
        />
      </div>
    );
  }
}

image

@zzzmj
Copy link
Author

zzzmj commented Apr 21, 2020

@zzzmj

In my case, It worked using .bind(hljs)
e.g,.

import React from "react";
import 'codemirror/lib/codemirror.css';
import 'highlight.js/styles/github.css';
import 'tui-color-picker/dist/tui-color-picker.css';
import '@toast-ui/editor/dist/toastui-editor.css';

import { Editor } from "@toast-ui/react-editor";
import colorSyntaxPlugin from "@toast-ui/editor-plugin-color-syntax";
import hljs from "highlight.js";
import codeSyntaxHighlightPlugin from "@toast-ui/editor-plugin-code-syntax-highlight";



export default class App extends React.Component<any, any> {
  render() {
    return (
      <div>
        <Editor
          initialValue="Hello World"
          previewStyle="vertical"
          height="600px"
          plugins={[codeSyntaxHighlightPlugin.bind(hljs), colorSyntaxPlugin]}
        />
      </div>
    );
  }
}

image

thank you...

I fixed the problem by reinstalling the @toast-ui/editor-plugin-code-syntax-highlight

@zzzmj zzzmj closed this as completed Apr 21, 2020
js87zz pushed a commit that referenced this issue Jun 17, 2021
Getting parent without selection, when user right click on a cell which contains a inline tags around text(span) failed.

#909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants