Skip to content

Commit

Permalink
Merge pull request #128 from blinko-space/#126
Browse files Browse the repository at this point in the history
fix: #126 iframe editor issue
  • Loading branch information
blinko-space authored Nov 18, 2024
2 parents a2aa503 + 76eafde commit 8dba3d0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/components/Common/Editor/editorPlugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ export const codeBlockLanguages = {
export const ProcessCodeBlocks = (content: string): string => {
if (!content) return '';
const codeBlockRegex = /```(?:(\w*)\n)?([\s\S]*?)```/g;
return content.replace(codeBlockRegex, (match, language, code) => {
if (!language || !(language in codeBlockLanguages)) {
return '```plain\n' + code.trim() + '\n```';
}
return '```' + language + '\n' + code.trim() + '\n```';
});
const htmlRegex = /(<[^>]+>)/gi;
try {
return content.replace(codeBlockRegex, (match, language, code) => {
if (!language || !(language in codeBlockLanguages)) {
return '```plain\n' + code.trim() + '\n```';
}
return '```' + language + '\n' + code.trim() + '\n```';
}).replace(htmlRegex, '\\$1');
} catch (error) {

return content
}
};

export const MyPlugins = [
Expand Down

0 comments on commit 8dba3d0

Please sign in to comment.