From 3cfca030b428d74f984621942b9177ad4c8ee1cc Mon Sep 17 00:00:00 2001 From: MurakamiShinyu Date: Wed, 27 Nov 2024 10:46:42 +0900 Subject: [PATCH 1/2] fix: prevent wrong break at beginning of paragraph - fix (again) #1401 --- packages/core/src/vivliostyle/layout.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/core/src/vivliostyle/layout.ts b/packages/core/src/vivliostyle/layout.ts index 45b83e257..242a771ec 100644 --- a/packages/core/src/vivliostyle/layout.ts +++ b/packages/core/src/vivliostyle/layout.ts @@ -2008,6 +2008,12 @@ export class Column extends VtreeImpl.Container implements Layout.Column { ): Vtree.NodeContext { const position = this.findEndOfLine(edgePosition, checkPoints, true); let nodeContext = position.nodeContext; + + if (position.checkPointIndex === 0 && position.index === nodeContext.boxOffset) { + // Prevent wrong break at beginning of paragraph (Issue #1401, #1406) + return null; + } + const viewNode = nodeContext.viewNode; if ( viewNode.nodeType != 1 && From f58e4570d666300e03c6627408b327ed1929e5d8 Mon Sep 17 00:00:00 2001 From: MurakamiShinyu Date: Wed, 27 Nov 2024 11:53:30 +0900 Subject: [PATCH 2/2] fix: prevent breaking inside SVG - fix (again) #1406 --- packages/core/src/vivliostyle/layout.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/src/vivliostyle/layout.ts b/packages/core/src/vivliostyle/layout.ts index 242a771ec..9d955bcd8 100644 --- a/packages/core/src/vivliostyle/layout.ts +++ b/packages/core/src/vivliostyle/layout.ts @@ -633,7 +633,12 @@ export class Column extends VtreeImpl.Container implements Layout.Column { ); frame .loopWithFrame((bodyFrame) => { - if (position.viewNode && !LayoutHelper.isSpecialNodeContext(position)) { + if ( + position.viewNode && + !LayoutHelper.isSpecialNodeContext(position) && + // Prevent breaking inside SVG etc. (Issue #1406) + position.viewNode.parentElement?.namespaceURI === Base.NS.XHTML + ) { checkPoints.push(position.copy()); } this.maybePeelOff(position, 0).then((position1Param) => { @@ -2009,7 +2014,10 @@ export class Column extends VtreeImpl.Container implements Layout.Column { const position = this.findEndOfLine(edgePosition, checkPoints, true); let nodeContext = position.nodeContext; - if (position.checkPointIndex === 0 && position.index === nodeContext.boxOffset) { + if ( + position.checkPointIndex === 0 && + position.index === nodeContext.boxOffset + ) { // Prevent wrong break at beginning of paragraph (Issue #1401, #1406) return null; }