fix: table cell text render position error #166
This commit is contained in:
@@ -465,7 +465,7 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
const element: IElement = {
|
const element: IElement = {
|
||||||
type: ElementType.TABLE,
|
type: ElementType.TABLE,
|
||||||
value: !startIndex ? '' : ZERO,
|
value: '',
|
||||||
colgroup,
|
colgroup,
|
||||||
trList
|
trList
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import { I18n } from '../i18n/I18n'
|
|||||||
import { ImageObserver } from '../observer/ImageObserver'
|
import { ImageObserver } from '../observer/ImageObserver'
|
||||||
import { Zone } from '../zone/Zone'
|
import { Zone } from '../zone/Zone'
|
||||||
import { Footer } from './frame/Footer'
|
import { Footer } from './frame/Footer'
|
||||||
|
import { INLINE_ELEMENT_TYPE } from '../../dataset/constant/Element'
|
||||||
|
|
||||||
export class Draw {
|
export class Draw {
|
||||||
|
|
||||||
@@ -1004,7 +1005,8 @@ export class Draw {
|
|||||||
// 累计行宽 + 当前元素宽度 + 后面标点符号宽度
|
// 累计行宽 + 当前元素宽度 + 后面标点符号宽度
|
||||||
const curRowWidth = curRow.width + metrics.width + this.textParticle.measurePunctuationWidth(ctx, nextElement)
|
const curRowWidth = curRow.width + metrics.width + this.textParticle.measurePunctuationWidth(ctx, nextElement)
|
||||||
if (
|
if (
|
||||||
preElement?.type === ElementType.TABLE
|
element.type === ElementType.TABLE
|
||||||
|
|| preElement?.type === ElementType.TABLE
|
||||||
|| preElement?.type === ElementType.BLOCK
|
|| preElement?.type === ElementType.BLOCK
|
||||||
|| element.type === ElementType.BLOCK
|
|| element.type === ElementType.BLOCK
|
||||||
|| preElement?.imgDisplay === ImageDisplay.INLINE
|
|| preElement?.imgDisplay === ImageDisplay.INLINE
|
||||||
@@ -1012,6 +1014,10 @@ export class Draw {
|
|||||||
|| curRowWidth > innerWidth
|
|| curRowWidth > innerWidth
|
||||||
|| (i !== 0 && element.value === ZERO)
|
|| (i !== 0 && element.value === ZERO)
|
||||||
) {
|
) {
|
||||||
|
// 减小行元素前第一行空行行高
|
||||||
|
if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type!)) {
|
||||||
|
curRow.height = defaultBasicRowMarginHeight
|
||||||
|
}
|
||||||
// 两端对齐
|
// 两端对齐
|
||||||
if (preElement?.rowFlex === RowFlex.ALIGNMENT && curRowWidth > innerWidth) {
|
if (preElement?.rowFlex === RowFlex.ALIGNMENT && curRowWidth > innerWidth) {
|
||||||
const gap = (innerWidth - curRow.width) / curRow.elementList.length
|
const gap = (innerWidth - curRow.width) / curRow.elementList.length
|
||||||
|
|||||||
@@ -62,4 +62,11 @@ export const TEXTLIKE_ELEMENT_TYPE: ElementType[] = [
|
|||||||
ElementType.SUPERSCRIPT,
|
ElementType.SUPERSCRIPT,
|
||||||
ElementType.CONTROL,
|
ElementType.CONTROL,
|
||||||
ElementType.DATE
|
ElementType.DATE
|
||||||
|
]
|
||||||
|
|
||||||
|
export const INLINE_ELEMENT_TYPE: ElementType[] = [
|
||||||
|
ElementType.BLOCK,
|
||||||
|
ElementType.PAGE_BREAK,
|
||||||
|
ElementType.SEPARATOR,
|
||||||
|
ElementType.TABLE
|
||||||
]
|
]
|
||||||
+1
-1
@@ -133,7 +133,7 @@ elementList.splice(575, 0, {
|
|||||||
// 模拟表格
|
// 模拟表格
|
||||||
elementList.push({
|
elementList.push({
|
||||||
type: ElementType.TABLE,
|
type: ElementType.TABLE,
|
||||||
value: `\n`,
|
value: '',
|
||||||
colgroup: [{
|
colgroup: [{
|
||||||
width: 180
|
width: 180
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
Reference in New Issue
Block a user