Skip to content

Commit

Permalink
Merge pull request #1194 from pateljannat/issues-55
Browse files Browse the repository at this point in the history
fix: markdown parser link issue
  • Loading branch information
pateljannat authored Dec 17, 2024
2 parents 8d961e9 + d3f7baa commit 824484e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/LessonForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const renderEditor = (holder) => {
holder: holder,
tools: getEditorTools(true),
autofocus: true,
defaultBlock: 'markdownParser',
defaultBlock: 'markdown',
})
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { toast } from 'frappe-ui'
import { useTimeAgo } from '@vueuse/core'
import { Quiz } from '@/utils/quiz'
import { Upload } from '@/utils/upload'
import { MarkdownParser } from '@/utils/markdownParser'
import { Markdown } from '@/utils/markdownParser'
import Header from '@editorjs/header'
import Paragraph from '@editorjs/paragraph'
import { CodeBox } from '@/utils/code'
Expand Down Expand Up @@ -156,12 +156,12 @@ export function getEditorTools() {
},
quiz: Quiz,
upload: Upload,
markdownParser: MarkdownParser,
markdown: Markdown,
image: SimpleImage,
table: Table,
paragraph: {
class: Paragraph,
inlineToolbar: false,
inlineToolbar: true,
config: {
preserveBlank: true,
},
Expand All @@ -187,7 +187,7 @@ export function getEditorTools() {
},
embed: {
class: Embed,
inlineToolbar: true,
inlineToolbar: false,
config: {
services: {
youtube: {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/utils/markdownParser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class MarkdownParser {
export class Markdown {
constructor({ data, api, readOnly, config }) {
this.api = api
this.data = data || {}
Expand Down Expand Up @@ -65,6 +65,8 @@ export class MarkdownParser {
} else if (previousLine && this.hasLink(previousLine)) {
const { text, url } = this.extractLink(previousLine)
const anchorTag = `<a href="${url}" target="_blank">${text}</a>`
console.log(previousLine.replace(/\[.+?\]\(.+?\)/, anchorTag))
debugger
this.convertBlock('paragraph', {
text: previousLine.replace(/\[.+?\]\(.+?\)/, anchorTag),
})
Expand Down Expand Up @@ -149,4 +151,4 @@ export class MarkdownParser {
}
}

export default MarkdownParser
export default Markdown

0 comments on commit 824484e

Please sign in to comment.