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

feat: support custom inline renderer #2633

Merged
merged 6 commits into from
Aug 3, 2022
Merged

Conversation

jajugoguma
Copy link
Contributor

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description

  • Added custom inline HTML renderer.
  • Can use the custom inline function by giving the editor's customHTMLRenderer option as shown below.
const editor = new Editor({
  // ...
  customHTMLRenderer: {
    customInline(node, { entering, skipChildren, origin }) {
      const { info } = node;

      if (info === "katex" && entering) {
        skipChildren();

        const exp = node.literal || node.firstChild?.literal || "";
        const renderedKatex = katex.renderToString(exp, {
          throwOnError: false
        });

        return [
          { type: "openTag", tagName: "span", classNames: ["tui-katex"] },
          { type: "html", content: renderedKatex },
          { type: "closeTag", tagName: "span" }
        ];
      }
      return origin();
    },
    // ...
  }
});

As-Is

To-Be


Thank you for your contribution to TOAST UI product. 🎉 😘 ✨

@jajugoguma
Copy link
Contributor Author

두레이 래퍼에서 에디터 기능을 강제로 확장하면서 타입에러가 발생합니다. 이는 신경쓰지 않으셔도 됩니다!

Copy link
Contributor

@jwlee1108 jwlee1108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료합니다.

Copy link
Contributor

@lja1018 lja1018 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료합니다.

apps/editor/src/convertors/toWysiwyg/toWwConvertors.ts Outdated Show resolved Hide resolved
@jajugoguma jajugoguma merged commit 0e4dfe6 into feat/dooray Aug 3, 2022
@jajugoguma jajugoguma deleted the feat/custom-inline branch August 3, 2022 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants