[MCP-UI] Dynamic Sizing

Users expect iframes to fit their content perfectly, not waste space or require scrolling. The journal viewer should automatically adjust to show exactly what's needed.

const height = document.documentElement.clientHeight
const width = document.documentElement.clientWidth

window.parent.postMessage(
	{
		type: 'ui-size-change',
		payload: { height, width },
	},
	'*',
)
Use clientHeight and clientWidth to measure the full content dimensions, then send a ui-size-change message to the parent window so it can resize the iframe accordingly.
The static preferred-frame-size from the previous exercise works for fixed layouts, but journal entries have varying content lengths. A short entry wastes space, while a long entry gets cut off.
 
 
posted @ 2026-02-02 14:38  Zhentiw  阅读(7)  评论(0)    收藏  举报