0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00

fixed lists (#91)

This commit is contained in:
Alex Sánchez 2024-05-08 12:11:41 +02:00 committed by GitHub
parent 2920ac297b
commit a18f98151a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,7 @@ type Level = {
type: ListType; type: ListType;
}; };
type ListType = 'ORDERED' | 'UNORDERED'; type ListType = 'ORDERED' | 'UNORDERED' | 'NONE';
export class List { export class List {
private levels: Map<number, Level> = new Map(); private levels: Map<number, Level> = new Map();
@ -27,11 +27,11 @@ export class List {
let level = this.levels.get(segment.indentation); let level = this.levels.get(segment.indentation);
if (!level || level.type !== this.getListType(segment)) { if (!level || level.type !== segment.listOptions.type) {
level = { level = {
style: this.createStyle(textNode, segment.indentation), style: this.createStyle(textNode, segment.indentation),
counter: 0, counter: 0,
type: this.getListType(segment) type: segment.listOptions.type
}; };
this.levels.set(segment.indentation, level); 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 { private createStyle(node: PenpotTextNode, indentation: number): PenpotTextNode {
return { return {
...node, ...node,