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(react): optionable remarkable #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import django from 'django';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { Remarkable } from 'remarkable';

import { getCookie } from './lib.js';
import { InitContext, StateContext } from './context.js';
Expand Down Expand Up @@ -253,8 +252,13 @@ export function ReplyFormPart({

export function CommentBodyPart({ allowFeedback, comment, isRemoved }) {
const rawMarkup = useMemo(() => {
const md = new Remarkable();
const _markup = md.render(comment);
const _markup = import('remarkable').then(Remarkable => {
const md = new Remarkable();
return md.render(comment);
}).catch(err => { return '' });
if (typeof _markup === 'object' && typeof _markup.then === 'function') {
return { __html: comment };
}
return { __html: _markup };
}, [comment]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ export function PreviewComment({avatar, name, url, comment, replyTo}) {
}

const raw_markup = () => {
const md = new Remarkable();
const _raw_markup = md.render(comment);
const _raw_markup = import('remarkable').then(Remarkable => {
const md = new Remarkable();
return md.render(comment);
}).catch(err => { return '' });
if (typeof _raw_markup === 'object' && typeof _raw_markup.then === 'function') {
return { __html: comment };
}
return { __html: _raw_markup };
}

Expand Down