web-remarq 0.4.3 → 0.4.4

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/dist/index.d.cts CHANGED
@@ -95,4 +95,4 @@ declare const WebRemarq: {
95
95
  clearAll(): void;
96
96
  };
97
97
 
98
- export { type AgentAnnotation, type AgentExport, type Annotation, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type ImportResult, WebRemarq, type WebRemarqOptions };
98
+ export { type AgentAnnotation, type AgentExport, type Annotation, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type ImportResult, type ToolbarPosition, WebRemarq, type WebRemarqOptions };
package/dist/index.d.ts CHANGED
@@ -95,4 +95,4 @@ declare const WebRemarq: {
95
95
  clearAll(): void;
96
96
  };
97
97
 
98
- export { type AgentAnnotation, type AgentExport, type Annotation, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type ImportResult, WebRemarq, type WebRemarqOptions };
98
+ export { type AgentAnnotation, type AgentExport, type Annotation, type AnnotationStore, type CSSModuleClass, type ElementFingerprint, type ImportResult, type ToolbarPosition, WebRemarq, type WebRemarqOptions };
package/dist/index.js CHANGED
@@ -592,7 +592,7 @@ var CSS = `
592
592
  .remarq-toolbar.remarq-pos-top-right { top: 16px; right: 16px; }
593
593
  .remarq-toolbar.remarq-pos-top-left { top: 16px; left: 16px; flex-direction: row-reverse; }
594
594
 
595
- .remarq-toolbar.remarq-minimized { padding: 4px; }
595
+ .remarq-toolbar.remarq-minimized { padding: 8px; }
596
596
 
597
597
  .remarq-toolbar-btn {
598
598
  display: flex;
@@ -1888,6 +1888,7 @@ var MarkerManager = class {
1888
1888
  // src/ui/toast.ts
1889
1889
  var currentToast = null;
1890
1890
  var currentTimer = null;
1891
+ var fadeTimer = null;
1891
1892
  function showToast(container, message, duration = 3e3) {
1892
1893
  hideToast();
1893
1894
  const toast = document.createElement("div");
@@ -1898,7 +1899,7 @@ function showToast(container, message, duration = 3e3) {
1898
1899
  currentTimer = setTimeout(() => {
1899
1900
  if (currentToast) {
1900
1901
  currentToast.classList.add("remarq-toast-fade");
1901
- setTimeout(() => hideToast(), 300);
1902
+ fadeTimer = setTimeout(() => hideToast(), 300);
1902
1903
  }
1903
1904
  }, duration);
1904
1905
  }
@@ -1907,6 +1908,10 @@ function hideToast() {
1907
1908
  clearTimeout(currentTimer);
1908
1909
  currentTimer = null;
1909
1910
  }
1911
+ if (fadeTimer) {
1912
+ clearTimeout(fadeTimer);
1913
+ fadeTimer = null;
1914
+ }
1910
1915
  if (currentToast) {
1911
1916
  currentToast.remove();
1912
1917
  currentToast = null;
@@ -2278,7 +2283,7 @@ function handleInspectKeydown(e) {
2278
2283
  toolbar.setSpacingActive(spacingMode);
2279
2284
  if (!spacingMode) spacingOverlay.hide();
2280
2285
  }
2281
- if (e.key === "i" && e.altKey) {
2286
+ if (e.altKey && e.code === "KeyI") {
2282
2287
  e.preventDefault();
2283
2288
  setInspecting(!inspecting);
2284
2289
  if (!inspecting) {
@@ -2440,13 +2445,36 @@ function exportJSON() {
2440
2445
  showToast(themeManager.container, "Exported as JSON");
2441
2446
  }
2442
2447
  function copyToClipboard() {
2448
+ var _a3;
2443
2449
  const md = generateMarkdown();
2444
- if (!md) return;
2445
- navigator.clipboard.writeText(md).then(() => {
2450
+ if (!md) {
2451
+ showToast(themeManager.container, "No annotations to copy");
2452
+ return;
2453
+ }
2454
+ if ((_a3 = navigator.clipboard) == null ? void 0 : _a3.writeText) {
2455
+ navigator.clipboard.writeText(md).then(() => {
2456
+ showToast(themeManager.container, "Copied to clipboard");
2457
+ }).catch(() => {
2458
+ fallbackCopy(md);
2459
+ });
2460
+ } else {
2461
+ fallbackCopy(md);
2462
+ }
2463
+ }
2464
+ function fallbackCopy(text) {
2465
+ const textarea = document.createElement("textarea");
2466
+ textarea.value = text;
2467
+ textarea.style.position = "fixed";
2468
+ textarea.style.opacity = "0";
2469
+ document.body.appendChild(textarea);
2470
+ textarea.select();
2471
+ try {
2472
+ document.execCommand("copy");
2446
2473
  showToast(themeManager.container, "Copied to clipboard");
2447
- }).catch(() => {
2448
- console.warn("[web-remarq] Clipboard write failed");
2449
- });
2474
+ } catch (e) {
2475
+ showToast(themeManager.container, "Failed to copy");
2476
+ }
2477
+ textarea.remove();
2450
2478
  }
2451
2479
  function exportAgent() {
2452
2480
  const anns = storage.getAll();
@@ -2466,10 +2494,13 @@ function copyAgentToClipboard() {
2466
2494
  }
2467
2495
  function setupMutationObserver() {
2468
2496
  mutationObserver = new MutationObserver((mutations) => {
2497
+ let hasExternalMutation = false;
2469
2498
  for (const m of mutations) {
2470
- if (m.target instanceof HTMLElement && m.target.closest("[data-remarq-theme]")) return;
2499
+ if (m.target instanceof HTMLElement && m.target.closest("[data-remarq-theme]")) continue;
2500
+ hasExternalMutation = true;
2501
+ break;
2471
2502
  }
2472
- scheduleRefresh();
2503
+ if (hasExternalMutation) scheduleRefresh();
2473
2504
  });
2474
2505
  mutationObserver.observe(document.body, {
2475
2506
  childList: true,