From a18f98151acd5557abe540f4e13525a044729cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=C3=A1nchez?= Date: Wed, 8 May 2024 12:11:41 +0200 Subject: [PATCH] fixed lists (#91) --- plugin-src/translators/text/paragraph/List.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/plugin-src/translators/text/paragraph/List.ts b/plugin-src/translators/text/paragraph/List.ts index 59d5a60..f220bc0 100644 --- a/plugin-src/translators/text/paragraph/List.ts +++ b/plugin-src/translators/text/paragraph/List.ts @@ -10,7 +10,7 @@ type Level = { type: ListType; }; -type ListType = 'ORDERED' | 'UNORDERED'; +type ListType = 'ORDERED' | 'UNORDERED' | 'NONE'; export class List { private levels: Map = new Map(); @@ -27,11 +27,11 @@ export class List { let level = this.levels.get(segment.indentation); - if (!level || level.type !== this.getListType(segment)) { + if (!level || level.type !== segment.listOptions.type) { level = { style: this.createStyle(textNode, segment.indentation), counter: 0, - type: this.getListType(segment) + type: segment.listOptions.type }; this.levels.set(segment.indentation, level); @@ -55,14 +55,6 @@ export class List { ); } - private getListType(segment: StyleTextSegment): ListType { - if (segment.listOptions.type === 'NONE') { - throw new Error('List type not valid'); - } - - return segment.listOptions.type; - } - private createStyle(node: PenpotTextNode, indentation: number): PenpotTextNode { return { ...node,