Fix portrait image flow and drop-cap spacing
This commit is contained in:
@@ -87,6 +87,7 @@ class UIDisplayHandlerModule extends BaseModule {
|
||||
'dedupeRenderedWindow',
|
||||
'reflowTextBlocksForActiveExclusions',
|
||||
'blockIntersectsExclusions',
|
||||
'getFlowLineFromItems',
|
||||
'insertStoredElement',
|
||||
'handleHistoryWheel',
|
||||
'handleManualScrollStart',
|
||||
@@ -957,8 +958,8 @@ class UIDisplayHandlerModule extends BaseModule {
|
||||
try {
|
||||
await this.ensureLiveTailWindow();
|
||||
await this.scrollTo(this.getLiveEndLine(), { mode: 'enter-live-tail', smooth: false });
|
||||
this.layoutFlowLine = Math.max(0, Number(this.storyHistory?.renderedLineCount || 0));
|
||||
this.rebuildLayoutExclusions(this.renderedItems);
|
||||
this.layoutFlowLine = this.getFlowLineFromItems(this.renderedItems);
|
||||
const element = await this.renderStoryBlock(sentence, { animate: true, playback: true, placement: 'append' });
|
||||
if (!element) return null;
|
||||
sentence.element = element;
|
||||
@@ -1246,6 +1247,20 @@ class UIDisplayHandlerModule extends BaseModule {
|
||||
return this.layoutExclusions.some(exclusion => start < exclusion.endLine && end > exclusion.startLine);
|
||||
}
|
||||
|
||||
getFlowLineFromItems(items = this.renderedItems) {
|
||||
const source = Array.isArray(items) ? items : [];
|
||||
return source.reduce((max, item) => {
|
||||
const type = String(item?.kind || item?.type || '').toLowerCase();
|
||||
const size = String(item?.metadata?.imageLayout?.size || item?.metadata?.size || item?.size || '').toLowerCase();
|
||||
if (type === 'image' && size === 'portrait') {
|
||||
return max;
|
||||
}
|
||||
const start = Number(item?.lineStart ?? item?.metadata?.lineStart);
|
||||
const count = Math.max(0, Number(item?.lineCount ?? item?.metadata?.lineCount ?? 0));
|
||||
return Number.isFinite(start) && count > 0 ? Math.max(max, start + count) : max;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
async reflowTextBlocksForActiveExclusions(token = this.renderWindowToken) {
|
||||
if (!this.layoutExclusions.length || !this.paragraphContainer) return;
|
||||
const candidates = this.renderedItems.filter(item => this.blockIntersectsExclusions(item));
|
||||
@@ -2037,7 +2052,7 @@ class UIDisplayHandlerModule extends BaseModule {
|
||||
this.historyWindowEndId = 0;
|
||||
this.windowOriginLine = 0;
|
||||
}
|
||||
this.layoutFlowLine = Math.max(0, Number(this.storyHistory.renderedLineCount || 0));
|
||||
this.layoutFlowLine = this.getFlowLineFromItems(this.renderedItems);
|
||||
this.activeCenterBlockId = latestRendered || null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user