Skip to content
Merged
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
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "npm"
Expand All @@ -25,10 +25,10 @@ jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "npm"
Expand All @@ -41,10 +41,10 @@ jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "npm"
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Run E2E tests
run: npm run test:e2e

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-test-results
Expand Down
11 changes: 7 additions & 4 deletions src/shared/markdown-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,13 @@ const defaultMarkdownSerializerNodes: MarkdownSerializerNodes = {
) {
text = linkMark.attrs.href as string;
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const startOfLine: boolean = state.atBlank() || state.closed;
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-assignment */
const startOfLine: boolean =
// @ts-expect-error
// eslint-disable-next-line
state.atBlank() || state.atBlockStart || state.closed;
/* eslint-enable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-assignment */

// escape the text using the built in escape code
let escapedText = state.esc(node.text, startOfLine);

Expand Down
56 changes: 56 additions & 0 deletions test/shared/roundtrip.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { test, expect, Page } from "@playwright/test";
import {
switchMode,
clearEditor,
editorSelector,
enterTextAsMarkdown,
} from "../e2e-helpers";

test.describe.serial("roundtrip tests", () => {
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
await page.goto("/empty.html");
await switchMode(page, "markdown");
});

test.afterAll(async () => {
await page.close();
});

for (const [markdown] of [
//Basic commonmark
["plain"],
["*italic*"],
["_italic_"],
["**bold**"],
["__bold__"],
["# H1"],
["## H2"],
["[link](http://www.example.com)"],
["![Image](http://www.example.com/pretty.png)"],
["> blockquote"],
["* List Item"],
["- List Item"],
["1. List Item"],
["2) List Item"],
["lol\n\n---\n\nlmao"],
["lol\n\n***\n\nlmao"],
["`code`"],
//TODO: Codeblock does weird things roundtripping: Adds an extra space
//['```javascript\ncodeblock\n```' ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good knowledge for a potential follow up ticket (in case it is worth fixing of course).


//Escape character
[String.raw`\# not a header`],
[String.raw`- \# list item (not header)`],
] as const) {
test(`should make markdown -> richtext -> markdown round trip '${JSON.stringify(markdown)}'`, async () => {
await clearEditor(page);
await enterTextAsMarkdown(page, markdown);
await switchMode(page, "markdown");

const text = await page.innerText(editorSelector);
expect(text).toBe(markdown);
});
}
});