Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: numbered sublist with font style and pagination #831

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
49 changes: 45 additions & 4 deletions src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,27 @@ export class Draw {
return sourceElementList[index!].trList![trIndex!].tdList[tdIndex!].rowList!
}

public getOriginalRowList() {
public getRowListByTableElement(sourceElementList: IElement[], element: IElement): IRow[] {
const { tableId } = element
if (tableId) {
const { trId, tdId } = element
const tableElement = sourceElementList.find((el) => el.id === tableId)
const trElement = tableElement?.trList?.find((el) => el.id === trId)
const tdElement = trElement?.tdList?.find((el) => el.id === tdId)
return tdElement?.rowList || []
} else {
return this.getOriginalRowList(true)
}
}

public getOriginalRowList(getAllZones?: boolean) {
if (getAllZones) {
return [
...this.rowList,
...this.header.getRowList(),
...this.footer.getRowList()
]
}
const zoneManager = this.getZone()
if (zoneManager.isHeaderActive()) {
return this.header.getRowList()
Expand Down Expand Up @@ -616,7 +636,14 @@ export class Draw {
: this.elementList
}

public getOriginalElementList() {
public getOriginalElementList(getAllZones?: boolean) {
if (getAllZones) {
return [
...this.elementList,
...this.getHeaderElementList(),
...this.getFooterElementList()
]
}
const zoneManager = this.getZone()
if (zoneManager.isHeaderActive()) {
return this.getHeaderElementList()
Expand Down Expand Up @@ -1080,6 +1107,18 @@ export class Draw {
})
}

public getTabWidth(elementList: IRowElement[]) {
let tabWidth = 0
const { defaultTabWidth, scale } = this.options
for (let i = 1; i < elementList.length; i++) {
const element = elementList[i]
if (element?.type !== ElementType.TAB) break
tabWidth += defaultTabWidth * scale
}

return tabWidth
}

public getValue(options: IGetValueOption = {}): IEditorResult {
const { pageNo, extraPickAttrs } = options
let mainElementList = this.elementList
Expand Down Expand Up @@ -1263,6 +1302,7 @@ export class Draw {
ascent: 0,
elementList: [],
startIndex: 0,
endIndex: 0,
rowIndex: 0,
rowFlex: elementList?.[0]?.rowFlex || elementList?.[1]?.rowFlex
})
Expand Down Expand Up @@ -1740,6 +1780,7 @@ export class Draw {
width: metrics.width,
height,
startIndex: i,
endIndex: i,
elementList: [rowElement],
ascent,
rowIndex: curRow.rowIndex + 1,
Expand Down Expand Up @@ -2168,11 +2209,11 @@ export class Draw {
if (
preElement &&
((preElement.type === ElementType.SUBSCRIPT &&
element.type !== ElementType.SUBSCRIPT) ||
element.type !== ElementType.SUBSCRIPT) ||
(preElement.type === ElementType.SUPERSCRIPT &&
element.type !== ElementType.SUPERSCRIPT) ||
this.getElementSize(preElement) !==
this.getElementSize(element))
this.getElementSize(element))
) {
this.strikeout.render(ctx)
}
Expand Down
Loading