visualknowledge 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ export function HtmlWidget({ html: htmlContent, onFullscreen }) {
38
38
  <iframe
39
39
  ref=${iframeRef}
40
40
  sandbox="allow-scripts allow-same-origin"
41
- style=${{ width: '100%', height: hasContent ? undefined : '0px', border: 'none', display: 'block' }}
41
+ style=${{ width: '100%', height: '0px', border: 'none', display: 'block', overflow: 'hidden' }}
42
42
  />
43
43
  </${WidgetContainer}>
44
44
  `;
@@ -52,10 +52,17 @@ function _writeHtml(iframe, content) {
52
52
  doc.write(content);
53
53
  doc.close();
54
54
 
55
- // 根据实际内容调整高度,随内容增长逐步扩大
55
+ // 紧凑高度:移除 body 默认 margin,只保留最小 padding
56
56
  try {
57
+ doc.body.style.margin = '0';
58
+ doc.body.style.padding = '0';
57
59
  const h = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight, 0);
58
- iframe.style.height = Math.min(h + 16, 1200) + 'px';
60
+ // 只在内容更高时才增大,不缩小(避免抖动)
61
+ const current = parseInt(iframe.style.height) || 0;
62
+ const target = Math.min(h + 4, 1200);
63
+ if (target > current || target < current - 20) {
64
+ iframe.style.height = target + 'px';
65
+ }
59
66
  } catch (_) {}
60
67
  } catch (e) {
61
68
  console.warn('[HtmlWidget] write failed:', e);
@@ -23,7 +23,7 @@
23
23
  .widget-container .widget-header .btn:hover{border-color:var(--accent);color:var(--accent)}
24
24
  .widget-container .widget-body{
25
25
  padding:0;display:flex;justify-content:center;overflow:auto;
26
- min-height:100px;
26
+ min-height:0;
27
27
  }
28
28
  .widget-container .widget-body svg{max-width:100%;height:auto}
29
29
  .widget-container .widget-loading{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visualknowledge",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Interactive AI Chat with Visualization - one-click launch via npx",
5
5
  "bin": {
6
6
  "visualknowledge": "./bin/visualknowledge.js"