@knowcode/doc-builder 1.3.9 → 1.3.10

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.10] - 2025-07-19
9
+
10
+ ### Fixed
11
+ - Reduced excessive top spacing in content area (changed from 40px to 16px)
12
+ - Fixed tooltip implementation with event delegation for better performance
13
+ - Added native `title` attribute as fallback for tooltips
14
+ - Applied spacing fixes to both default and notion themes
15
+
16
+ ### Improved
17
+ - Content now starts closer to the header/breadcrumb area
18
+ - Tooltips use simpler event delegation instead of individual listeners
19
+ - Better tooltip support with both custom CSS tooltips and native browser tooltips
20
+ - Removed unnecessary MutationObserver for cleaner code
21
+
22
+ ### Technical Details
23
+ - Content padding reduced from 40px to var(--space-lg) (16px)
24
+ - Event delegation on navigation container captures all tooltip events
25
+ - Native title attributes ensure tooltips work even if CSS/JS fails
26
+ - More efficient event handling with capture phase listeners
27
+
8
28
  ## [1.3.9] - 2025-07-19
9
29
 
10
30
  ### Fixed
@@ -705,7 +705,7 @@ pre code {
705
705
  .content {
706
706
  flex: 1;
707
707
  margin-left: var(--sidebar-width);
708
- padding: 40px var(--space-8);
708
+ padding: var(--space-4) var(--space-8);
709
709
  overflow-y: auto;
710
710
  background: var(--color-bg-default);
711
711
  transition: margin-left var(--duration-normal);
@@ -1087,7 +1087,7 @@ em, i {
1087
1087
  .content {
1088
1088
  flex: 1;
1089
1089
  margin-left: var(--sidebar-width);
1090
- padding: 40px var(--space-2xl) var(--space-xl);
1090
+ padding: var(--space-lg) var(--space-2xl) var(--space-xl);
1091
1091
  max-width: calc(var(--content-max-width) + var(--space-2xl) * 2);
1092
1092
  transition: margin-left var(--transition-base);
1093
1093
  }
package/assets/js/main.js CHANGED
@@ -1332,35 +1332,33 @@ function generateBreadcrumbs() {
1332
1332
 
1333
1333
  // Initialize tooltip positioning for navigation items
1334
1334
  function initTooltips() {
1335
- const tooltipElements = document.querySelectorAll('[data-tooltip]');
1336
- console.log(`Initializing tooltips for ${tooltipElements.length} elements`);
1335
+ // Use event delegation for better performance and dynamic content support
1336
+ const navigation = document.querySelector('.navigation');
1337
+ if (!navigation) return;
1337
1338
 
1338
- tooltipElements.forEach(element => {
1339
- // Remove any existing listeners to prevent duplicates
1340
- const newElement = element.cloneNode(true);
1341
- element.parentNode.replaceChild(newElement, element);
1339
+ navigation.addEventListener('mouseenter', function(e) {
1340
+ const tooltipElement = e.target.closest('[data-tooltip]');
1341
+ if (!tooltipElement) return;
1342
1342
 
1343
- newElement.addEventListener('mouseenter', function(e) {
1344
- const rect = newElement.getBoundingClientRect();
1345
- const tooltipText = newElement.getAttribute('data-tooltip');
1346
-
1347
- // Position the tooltip using CSS variables
1348
- // Tooltip appears to the right of the element with 10px gap
1349
- const leftPos = rect.right + 10;
1350
- const topPos = rect.top + rect.height / 2;
1351
-
1352
- console.log(`Tooltip positioned at: ${leftPos}, ${topPos} for "${tooltipText}"`);
1353
-
1354
- newElement.style.setProperty('--tooltip-left', `${leftPos}px`);
1355
- newElement.style.setProperty('--tooltip-top', `${topPos}px`);
1356
- });
1343
+ const rect = tooltipElement.getBoundingClientRect();
1344
+ const tooltipText = tooltipElement.getAttribute('data-tooltip');
1357
1345
 
1358
- // Clean up on mouse leave
1359
- newElement.addEventListener('mouseleave', function(e) {
1360
- newElement.style.removeProperty('--tooltip-left');
1361
- newElement.style.removeProperty('--tooltip-top');
1362
- });
1363
- });
1346
+ // Position the tooltip using CSS variables
1347
+ // Tooltip appears to the right of the element with 10px gap
1348
+ const leftPos = rect.right + 10;
1349
+ const topPos = rect.top + rect.height / 2;
1350
+
1351
+ tooltipElement.style.setProperty('--tooltip-left', `${leftPos}px`);
1352
+ tooltipElement.style.setProperty('--tooltip-top', `${topPos}px`);
1353
+ }, true); // Use capture phase
1354
+
1355
+ navigation.addEventListener('mouseleave', function(e) {
1356
+ const tooltipElement = e.target.closest('[data-tooltip]');
1357
+ if (!tooltipElement) return;
1358
+
1359
+ tooltipElement.style.removeProperty('--tooltip-left');
1360
+ tooltipElement.style.removeProperty('--tooltip-top');
1361
+ }, true); // Use capture phase
1364
1362
  }
1365
1363
 
1366
1364
  // Initialize on DOM Load
@@ -1373,17 +1371,4 @@ document.addEventListener('DOMContentLoaded', () => {
1373
1371
  addPDFExportButton();
1374
1372
  generateBreadcrumbs();
1375
1373
  initTooltips();
1376
-
1377
- // Re-initialize tooltips if navigation is dynamically updated
1378
- const navigation = document.querySelector('.navigation');
1379
- if (navigation) {
1380
- const observer = new MutationObserver(() => {
1381
- initTooltips();
1382
- });
1383
-
1384
- observer.observe(navigation, {
1385
- childList: true,
1386
- subtree: true
1387
- });
1388
- }
1389
1374
  });
@@ -286,7 +286,7 @@ function buildNavigationStructure(files, currentFile) {
286
286
 
287
287
  // Get folder description for tooltip
288
288
  const folderDescription = folderDescriptions[folderName] || '';
289
- const tooltipAttr = folderDescription ? `data-tooltip="${escapeHtml(folderDescription)}"` : '';
289
+ const tooltipAttr = folderDescription ? `data-tooltip="${escapeHtml(folderDescription)}" title="${escapeHtml(folderDescription)}"` : '';
290
290
 
291
291
  // Start all sections collapsed by default (JavaScript will expand sections containing active items)
292
292
  const hasActiveChild = checkActiveChild(folderData, currentFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {