@immense/vue-pom-generator 1.0.108 → 1.0.109

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.mjs CHANGED
@@ -11953,6 +11953,20 @@ const ANNOTATOR_STYLES = `
11953
11953
  max-width: min(320px, calc(100vw - 24px));
11954
11954
  }
11955
11955
 
11956
+ .vpg-annotator-panel--preview {
11957
+ min-width: min(720px, calc(100vw - 24px));
11958
+ max-width: min(940px, calc(100vw - 24px));
11959
+ }
11960
+
11961
+ .vpg-annotator-panel--preview .vpg-annotator-textarea {
11962
+ height: min(52vh, 440px);
11963
+ resize: vertical;
11964
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
11965
+ white-space: pre;
11966
+ overflow: auto;
11967
+ }
11968
+
11969
+
11956
11970
  .vpg-annotator-arrow {
11957
11971
  position: absolute;
11958
11972
  z-index: 0;
@@ -12067,18 +12081,6 @@ const ANNOTATOR_STYLES = `
12067
12081
  margin-top: 12px;
12068
12082
  }
12069
12083
 
12070
- .vpg-annotator-shortcuts {
12071
- display: grid;
12072
- gap: 8px;
12073
- }
12074
-
12075
- .vpg-annotator-shortcut-row {
12076
- display: flex;
12077
- align-items: center;
12078
- justify-content: space-between;
12079
- gap: 12px;
12080
- }
12081
-
12082
12084
  .vpg-annotator-label {
12083
12085
  font-size: 12px;
12084
12086
  font-weight: 600;
@@ -12094,20 +12096,6 @@ const ANNOTATOR_STYLES = `
12094
12096
  padding: 8px 10px;
12095
12097
  }
12096
12098
 
12097
- .vpg-annotator-kbd {
12098
- min-width: 32px;
12099
- padding: 4px 8px;
12100
- border: 1px solid var(--vpg-annotator-border);
12101
- border-radius: var(--vpg-annotator-radius);
12102
- background: rgba(15, 23, 42, 0.72);
12103
- color: var(--vpg-annotator-text);
12104
- font: inherit;
12105
- font-size: 11px;
12106
- font-weight: 700;
12107
- line-height: 1;
12108
- text-align: center;
12109
- }
12110
-
12111
12099
  .vpg-annotator-highlight {
12112
12100
  position: fixed;
12113
12101
  z-index: 2147483646;
@@ -12139,6 +12127,7 @@ const ANNOTATOR_STYLES = `
12139
12127
  inset: 0;
12140
12128
  z-index: 2147483645;
12141
12129
  background: transparent;
12130
+ cursor: crosshair;
12142
12131
  }
12143
12132
 
12144
12133
  .vpg-annotator-marker {
@@ -12171,6 +12160,34 @@ const ANNOTATOR_STYLES = `
12171
12160
  font-size: 12px;
12172
12161
  font-weight: 600;
12173
12162
  }
12163
+
12164
+ .vpg-annotator-heading-row {
12165
+ display: flex;
12166
+ align-items: center;
12167
+ justify-content: space-between;
12168
+ gap: 8px;
12169
+ }
12170
+
12171
+ .vpg-annotator-heading-row .vpg-annotator-heading {
12172
+ margin-bottom: 4px;
12173
+ }
12174
+
12175
+ .vpg-annotator-panel-close {
12176
+ margin-left: auto;
12177
+ background: transparent;
12178
+ border: none;
12179
+ color: var(--vpg-annotator-text-soft);
12180
+ font-size: 16px;
12181
+ line-height: 1;
12182
+ padding: 2px 6px;
12183
+ cursor: pointer;
12184
+ border-radius: var(--vpg-annotator-radius);
12185
+ }
12186
+
12187
+ .vpg-annotator-panel-close:hover {
12188
+ color: var(--vpg-annotator-text);
12189
+ background: var(--vpg-annotator-bg-soft);
12190
+ }
12174
12191
  `;
12175
12192
  const ignoredComponentNamePattern = /^(?:items\[\d+\]\.template|template|anonymous|slot|transition|transition-group)$/i;
12176
12193
  function getDirectVueInstances(element) {
@@ -12329,35 +12346,15 @@ const TOOLBAR_POSITION_STORAGE_KEY = "vpg-annotator-toolbar-position";
12329
12346
  const RUNTIME_GUARD = "__VUE_POM_GENERATOR_ANNOTATOR_RUNTIME__";
12330
12347
  const TOOLBAR_ICON_MARKUP = {
12331
12348
  drag: '<svg viewBox="0 0 16 16"><path d="M5 3h1v1H5zM10 3h1v1h-1zM5 7h1v1H5zM10 7h1v1h-1zM5 11h1v1H5zM10 11h1v1h-1z" fill="currentColor" stroke="none" /></svg>',
12332
- inspect: '<svg viewBox="0 0 16 16"><path d="M8 2v3M8 11v3M2 8h3M11 8h3M4 4l2 2M10 10l2 2M12 4l-2 2M6 10l-2 2"/><circle cx="8" cy="8" r="2.5"/></svg>',
12349
+ inspect: '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="4.5"/><path d="M8 1v2.5M8 12.5v2.5M1 8h2.5M12.5 8h2.5"/><circle cx="8" cy="8" r="0.9" fill="currentColor" stroke="none"/></svg>',
12333
12350
  preview: '<svg viewBox="0 0 16 16"><path d="M1.5 8s2.4-4 6.5-4 6.5 4 6.5 4-2.4 4-6.5 4-6.5-4-6.5-4Z"/><circle cx="8" cy="8" r="1.8"/></svg>',
12334
12351
  copy: '<svg viewBox="0 0 16 16"><path d="M6 2.5h6.5v9H6z"/><path d="M3.5 5.5H5v6.5h5.5v1.5h-7z"/></svg>',
12335
12352
  clear: '<svg viewBox="0 0 16 16"><path d="M2.5 4.5h11"/><path d="M6 2.5h4"/><path d="M5 4.5v8"/><path d="M8 4.5v8"/><path d="M11 4.5v8"/><path d="M4 4.5h8l-.6 9H4.6z"/></svg>',
12336
12353
  settings: '<svg viewBox="0 0 16 16"><path d="M8 2.2l1 .6 1.2-.2.8 1 .9.7-.3 1.2.5 1-.5 1 .3 1.2-.9.7-.8 1-1.2-.2-1 .6-1-.6-1.2.2-.8-1-.9-.7.3-1.2-.5-1 .5-1-.3-1.2.9-.7.8-1 1.2.2z"/><circle cx="8" cy="8" r="2.2"/></svg>'
12337
12354
  };
12338
- const SHORTCUT_LABELS = {
12339
- select: "S",
12340
- preview: "P",
12341
- copy: "C",
12342
- clear: "X",
12343
- settings: ",",
12344
- cancel: "Esc"
12345
- };
12346
- function formatShortcutTitle(label, shortcut) {
12347
- return shortcut ? `${label} (${shortcut})` : label;
12348
- }
12349
12355
  function isInsideAnnotatorTree(node) {
12350
12356
  return node instanceof Element && !!node.closest(`[${ANNOTATOR_ROOT_ATTR}]`);
12351
12357
  }
12352
- function isEditableTarget(node) {
12353
- if (!(node instanceof Element)) {
12354
- return false;
12355
- }
12356
- if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement) {
12357
- return true;
12358
- }
12359
- return node.closest('[contenteditable=""], [contenteditable="true"]') !== null;
12360
- }
12361
12358
  function getElementSummary(element) {
12362
12359
  const testId = element.getAttribute("data-testid");
12363
12360
  if (testId) {
@@ -12422,10 +12419,7 @@ function createButtonBase(label, onClick, options = {}) {
12422
12419
  button.className = `vpg-annotator-btn${options.primary ? " vpg-annotator-btn--primary" : ""}`;
12423
12420
  button.setAttribute(ANNOTATOR_ROOT_ATTR, "");
12424
12421
  button.setAttribute("aria-label", label);
12425
- button.title = formatShortcutTitle(label, options.shortcut);
12426
- if (options.shortcut) {
12427
- button.setAttribute("aria-keyshortcuts", options.shortcut);
12428
- }
12422
+ button.title = label;
12429
12423
  if (options.pressed) {
12430
12424
  button.setAttribute("aria-pressed", "true");
12431
12425
  }
@@ -12565,23 +12559,18 @@ class AnnotatorRuntime {
12565
12559
  count.textContent = `${this.annotations.length} annotation${this.annotations.length === 1 ? "" : "s"}`;
12566
12560
  const selectButton = createIconButton(this.inspectMode ? "Stop selecting" : "Select element", "inspect", () => {
12567
12561
  this.setInspectMode(!this.inspectMode);
12568
- }, { primary: this.inspectMode, pressed: this.inspectMode, shortcut: SHORTCUT_LABELS.select });
12562
+ }, { primary: this.inspectMode, pressed: this.inspectMode });
12569
12563
  const previewButton = createIconButton("Preview annotations", "preview", () => this.openPreview(), {
12570
- disabled: this.annotations.length === 0,
12571
- shortcut: SHORTCUT_LABELS.preview
12564
+ disabled: this.annotations.length === 0
12572
12565
  });
12573
12566
  this.previewButton = previewButton;
12574
12567
  const copyButton = createIconButton("Copy annotations", "copy", () => this.copyAnnotations(), {
12575
- disabled: this.annotations.length === 0,
12576
- shortcut: SHORTCUT_LABELS.copy
12568
+ disabled: this.annotations.length === 0
12577
12569
  });
12578
12570
  const clearButton = createIconButton("Clear annotations", "clear", () => this.clearAnnotations(), {
12579
- disabled: this.annotations.length === 0,
12580
- shortcut: SHORTCUT_LABELS.clear
12581
- });
12582
- const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings(), {
12583
- shortcut: SHORTCUT_LABELS.settings
12571
+ disabled: this.annotations.length === 0
12584
12572
  });
12573
+ const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings());
12585
12574
  this.settingsButton = settingsButton;
12586
12575
  this.toolbarEl.append(handle, selectButton, previewButton, copyButton, clearButton, settingsButton, count);
12587
12576
  this.applyToolbarPosition();
@@ -12612,7 +12601,6 @@ class AnnotatorRuntime {
12612
12601
  this.renderMarkers();
12613
12602
  this.applyToolbarPosition();
12614
12603
  });
12615
- window.addEventListener("keydown", (event) => this.onWindowKeyDown(event), true);
12616
12604
  }
12617
12605
  loadSettings() {
12618
12606
  try {
@@ -12739,60 +12727,6 @@ class AnnotatorRuntime {
12739
12727
  window.addEventListener("pointercancel", onPointerUp);
12740
12728
  });
12741
12729
  }
12742
- onWindowKeyDown(event) {
12743
- if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) {
12744
- return;
12745
- }
12746
- if (event.key === "Escape") {
12747
- if (!this.inspectMode && !this.currentPanelEl) {
12748
- return;
12749
- }
12750
- event.preventDefault();
12751
- if (this.inspectMode) {
12752
- this.setInspectMode(false);
12753
- } else {
12754
- this.closePanel();
12755
- }
12756
- return;
12757
- }
12758
- if (isEditableTarget(event.target)) {
12759
- return;
12760
- }
12761
- const key = event.key.toLowerCase();
12762
- if (key === SHORTCUT_LABELS.select.toLowerCase()) {
12763
- event.preventDefault();
12764
- this.setInspectMode(!this.inspectMode);
12765
- return;
12766
- }
12767
- if (key === SHORTCUT_LABELS.preview.toLowerCase()) {
12768
- if (!this.annotations.length) {
12769
- return;
12770
- }
12771
- event.preventDefault();
12772
- this.openPreview();
12773
- return;
12774
- }
12775
- if (key === SHORTCUT_LABELS.copy.toLowerCase()) {
12776
- if (!this.annotations.length) {
12777
- return;
12778
- }
12779
- event.preventDefault();
12780
- void this.copyAnnotations();
12781
- return;
12782
- }
12783
- if (key === SHORTCUT_LABELS.clear.toLowerCase()) {
12784
- if (!this.annotations.length) {
12785
- return;
12786
- }
12787
- event.preventDefault();
12788
- this.clearAnnotations();
12789
- return;
12790
- }
12791
- if (event.key === SHORTCUT_LABELS.settings) {
12792
- event.preventDefault();
12793
- this.openSettings();
12794
- }
12795
- }
12796
12730
  setInspectMode(next) {
12797
12731
  this.inspectMode = next;
12798
12732
  this.shieldEl.hidden = !next;
@@ -12977,11 +12911,21 @@ class AnnotatorRuntime {
12977
12911
  this.editingAnnotationId = annotation.id;
12978
12912
  this.openInputForDraft(reference);
12979
12913
  }
12914
+ createPanelCloseButton(ariaLabel) {
12915
+ const closeButton = document.createElement("button");
12916
+ closeButton.type = "button";
12917
+ closeButton.className = "vpg-annotator-panel-close";
12918
+ closeButton.setAttribute(ANNOTATOR_ROOT_ATTR, "");
12919
+ closeButton.setAttribute("aria-label", ariaLabel);
12920
+ closeButton.textContent = "×";
12921
+ closeButton.addEventListener("click", () => this.closePanel());
12922
+ return closeButton;
12923
+ }
12980
12924
  openPreview() {
12981
12925
  if (!this.previewButton || this.annotations.length === 0) {
12982
12926
  return;
12983
12927
  }
12984
- const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel");
12928
+ const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel vpg-annotator-panel--preview");
12985
12929
  const title = document.createElement("div");
12986
12930
  title.className = "vpg-annotator-heading";
12987
12931
  title.textContent = "Annotation preview";
@@ -12992,7 +12936,10 @@ class AnnotatorRuntime {
12992
12936
  textarea.className = "vpg-annotator-textarea";
12993
12937
  textarea.readOnly = true;
12994
12938
  textarea.value = formatAnnotations(this.annotations, this.settings.outputDetail, window.location.href);
12995
- body.append(title, subtitle, textarea);
12939
+ const headerRow = document.createElement("div");
12940
+ headerRow.className = "vpg-annotator-heading-row";
12941
+ headerRow.append(title, this.createPanelCloseButton("Close preview"));
12942
+ body.append(headerRow, subtitle, textarea);
12996
12943
  this.showPanel(panel, () => this.attachFloating(this.previewButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
12997
12944
  }
12998
12945
  openSettings() {
@@ -13031,35 +12978,7 @@ class AnnotatorRuntime {
13031
12978
  this.saveSettings();
13032
12979
  });
13033
12980
  showComponentField.append(showComponentCopy, showComponentCheckbox);
13034
- const shortcutsField = document.createElement("div");
13035
- shortcutsField.className = "vpg-annotator-field";
13036
- const shortcutsLabel = document.createElement("div");
13037
- shortcutsLabel.className = "vpg-annotator-label";
13038
- shortcutsLabel.textContent = "Keyboard shortcuts";
13039
- const shortcutsList = document.createElement("div");
13040
- shortcutsList.className = "vpg-annotator-shortcuts";
13041
- for (const [shortcut, description] of [
13042
- [SHORTCUT_LABELS.select, "Toggle selection mode"],
13043
- [SHORTCUT_LABELS.preview, "Open preview"],
13044
- [SHORTCUT_LABELS.copy, "Copy annotations"],
13045
- [SHORTCUT_LABELS.clear, "Clear annotations"],
13046
- [SHORTCUT_LABELS.settings, "Open settings"],
13047
- [SHORTCUT_LABELS.cancel, "Close panel / cancel selection"]
13048
- ]) {
13049
- const row = document.createElement("div");
13050
- row.className = "vpg-annotator-shortcut-row";
13051
- const text = document.createElement("span");
13052
- text.className = "vpg-annotator-subtle";
13053
- text.textContent = description;
13054
- const kbd = document.createElement("kbd");
13055
- kbd.className = "vpg-annotator-kbd";
13056
- kbd.setAttribute(ANNOTATOR_ROOT_ATTR, "");
13057
- kbd.textContent = shortcut;
13058
- row.append(text, kbd);
13059
- shortcutsList.appendChild(row);
13060
- }
13061
- shortcutsField.append(shortcutsLabel, shortcutsList);
13062
- body.append(title, detailField, showComponentField, shortcutsField);
12981
+ body.append(title, detailField, showComponentField);
13063
12982
  this.showPanel(panel, () => this.attachFloating(this.settingsButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
13064
12983
  }
13065
12984
  disposeCurrentPanel() {