mirror of
https://github.com/usememos/memos.git
synced 2025-02-14 18:30:42 +01:00
feat: enable iframe rendering in markdown code block (#2799)
* enable iframe rendering in code block * fix eslint issue
This commit is contained in:
parent
196facfacd
commit
bd1cf62761
@ -15,6 +15,16 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {
|
|||||||
const formatedLanguage = language.toLowerCase() || "plaintext";
|
const formatedLanguage = language.toLowerCase() || "plaintext";
|
||||||
let highlightedCode = hljs.highlightAuto(content).value;
|
let highlightedCode = hljs.highlightAuto(content).value;
|
||||||
|
|
||||||
|
// Users can set Markdown code blocks as 'iframe'
|
||||||
|
// to embed videos or external audio links from services like Apple Music or Spotify.
|
||||||
|
if (formatedLanguage === "iframe") {
|
||||||
|
const renderHTML = () => {
|
||||||
|
return { __html: content };
|
||||||
|
};
|
||||||
|
|
||||||
|
return <div className="mx-auto w-11/12 !my-4" dangerouslySetInnerHTML={renderHTML()} />;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const temp = hljs.highlight(content, {
|
const temp = hljs.highlight(content, {
|
||||||
language: formatedLanguage,
|
language: formatedLanguage,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user