Skip to content

Commit 4da546e

Browse files
committed
Can use and save marker for checked list
1 parent e02f057 commit 4da546e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/lexical-markdown/src/MarkdownTransformers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export type TextMatchTransformer = Readonly<{
201201

202202
const ORDERED_LIST_REGEX = /^(\s*)(\d{1,})\.\s/;
203203
const UNORDERED_LIST_REGEX = /^(\s*)[-*+]\s/;
204-
const CHECK_LIST_REGEX = /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i;
204+
const CHECK_LIST_REGEX = /^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i;
205205
const HEADING_REGEX = /^(#{1,6})\s/;
206206
const QUOTE_REGEX = /^>\s/;
207207
const CODE_START_REGEX = /^[ \t]*```([\w-]+)?/;
@@ -252,8 +252,8 @@ const listReplace = (listType: ListType): ElementTransformer['replace'] => {
252252
const listItem = $createListItemNode(
253253
listType === 'check' ? match[3] === 'x' : undefined,
254254
);
255-
if (listType === 'bullet') {
256-
const markerFound = match[0].trim();
255+
if (listType === 'bullet' || listType === 'check') {
256+
const markerFound = match[0][0];
257257
const listMarker: ListMarker = $isListMarker(markerFound)
258258
? markerFound
259259
: '-';
@@ -316,7 +316,7 @@ const listExport = (
316316
listType === 'number'
317317
? `${listNode.getStart() + index}. `
318318
: listType === 'check'
319-
? `- [${listItemNode.getChecked() ? 'x' : ' '}] `
319+
? `${listItemNode.getMarker()} [${listItemNode.getChecked() ? 'x' : ' '}] `
320320
: listItemNode.getMarker() + ' ';
321321
output.push(indent + prefix + exportChildren(listItemNode));
322322
index++;

0 commit comments

Comments
 (0)