Merge pull request #1330 from pateljannat/markdown-links

fix: link issue in lesson
This commit is contained in:
Jannat Patel
2025-02-20 16:37:33 +05:30
committed by GitHub
5 changed files with 28 additions and 13 deletions

View File

@@ -13,6 +13,6 @@ module.exports = defineConfig({
openMode: 0,
},
e2e: {
baseUrl: "http://lms1:8000",
baseUrl: "http://testui:8000",
},
});

View File

@@ -5,7 +5,7 @@ describe("Course Creation", () => {
cy.visit("/lms/courses");
// Create a course
cy.get("header").children().last().children().last().click();
cy.get("button").contains("New").click();
cy.wait(1000);
cy.url().should("include", "/courses/new/edit");
@@ -84,9 +84,8 @@ describe("Course Creation", () => {
cy.wait(1000);
cy.get("label").contains("Title").type("Test Lesson");
cy.get("#content .ce-block").type(
"This is an extremely big paragraph that is meant to test the UI. This is a very long paragraph. It contains more than once sentence. Its meant to be this long as this is a UI test. Its unbearably long and I'm not sure why I'm typing this much. I'm just going to keep typing until I feel like its long enough. I think its long enough now. I'm going to stop typing now."
"{enter}This is an extremely big paragraph that is meant to test the UI. This is a very long paragraph. It contains more than once sentence. Its meant to be this long as this is a UI test. Its unbearably long and I'm not sure why I'm typing this much. I'm just going to keep typing until I feel like its long enough. I think its long enough now. I'm going to stop typing now."
);
cy.button("Save").click();

View File

@@ -36,7 +36,7 @@
<FormControl
v-model="member.first_name"
:placeholder="__('First Name')"
type="test"
type="text"
class="w-full"
/>
<Button @click="addMember()" variant="subtle">

View File

@@ -139,7 +139,7 @@ const renderEditor = (holder) => {
const lesson = reactive({
title: '',
include_in_preview: false,
body: 'Test',
body: '',
instructor_notes: '',
content: '',
})
@@ -294,7 +294,7 @@ const convertToJSON = (lessonData) => {
type: 'upload',
data: {
file_url: video,
file_type: 'video',
file_type: video.split('.').pop(),
},
})
} else if (block.includes('{{ Audio')) {
@@ -303,7 +303,7 @@ const convertToJSON = (lessonData) => {
type: 'upload',
data: {
file_url: audio,
file_type: 'audio',
file_type: audio.split('.').pop(),
},
})
} else if (block.includes('{{ PDF')) {

View File

@@ -50,10 +50,18 @@ export class Markdown {
this.wrapper.innerHTML = this.text
this.wrapper.addEventListener('keydown', (event) => {
const value = event.target.textContent
let value = event.target.textContent
if (event.keyCode === 32 && value.startsWith('#')) {
this.convertToHeader(event, value)
} else if (event.keyCode === 13) {
} else if (event.keyCode == 189) {
this.convertBlock('list', {
style: 'unordered',
})
} else if (/^[a-zA-Z]/.test(event.key)) {
this.convertBlock('paragraph', {
text: value,
})
} else if (event.keyCode === 13 || event.keyCode === 190) {
this.parseContent(event)
}
})
@@ -75,7 +83,11 @@ export class Markdown {
parseContent(event) {
event.preventDefault()
const previousLine = this.wrapper.textContent
let previousLine = this.wrapper.textContent
if (event.keyCode === 190) {
previousLine = previousLine + '.'
}
if (previousLine && this.hasImage(previousLine)) {
this.wrapper.textContent = ''
this.convertBlock('image')
@@ -94,12 +106,12 @@ export class Markdown {
},
],
})
} else if (previousLine && previousLine.startsWith('1. ')) {
} else if (previousLine && previousLine.startsWith('1.')) {
this.convertBlock('list', {
style: 'ordered',
items: [
{
content: previousLine.replace('1. ', ''),
content: previousLine.replace('1.', ''),
},
],
})
@@ -108,6 +120,10 @@ export class Markdown {
this.convertBlock('embed', {
source: previousLine,
})
} else {
this.convertBlock('paragraph', {
text: previousLine,
})
}
}