instruckt 0.4.9 → 0.4.13

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.
@@ -50,7 +50,8 @@ function getCsrfToken() {
50
50
  function headers() {
51
51
  const h = {
52
52
  "Content-Type": "application/json",
53
- Accept: "application/json"
53
+ Accept: "application/json",
54
+ "X-Requested-With": "XMLHttpRequest"
54
55
  };
55
56
  const csrf = getCsrfToken();
56
57
  if (csrf) h["X-XSRF-TOKEN"] = csrf;
@@ -1284,6 +1285,13 @@ var _Instruckt = class _Instruckt {
1284
1285
  if (this.highlightLocked) return;
1285
1286
  (_a = this.highlight) == null ? void 0 : _a.hide();
1286
1287
  };
1288
+ /** Block mousedown/pointerdown in annotation mode so SPA frameworks can't navigate */
1289
+ this.boundAnnotateBlock = (e) => {
1290
+ if (this.isInstruckt(e.target)) return;
1291
+ e.preventDefault();
1292
+ e.stopPropagation();
1293
+ e.stopImmediatePropagation();
1294
+ };
1287
1295
  this.boundClick = (e) => {
1288
1296
  var _a, _b, _c, _d;
1289
1297
  const target = e.target;
@@ -1613,11 +1621,17 @@ var _Instruckt = class _Instruckt {
1613
1621
  attachAnnotateListeners() {
1614
1622
  document.addEventListener("mousemove", this.boundMouseMove);
1615
1623
  document.addEventListener("mouseleave", this.boundMouseLeave);
1624
+ for (const evt of ["mousedown", "pointerdown"]) {
1625
+ window.addEventListener(evt, this.boundAnnotateBlock, true);
1626
+ }
1616
1627
  window.addEventListener("click", this.boundClick, true);
1617
1628
  }
1618
1629
  detachAnnotateListeners() {
1619
1630
  document.removeEventListener("mousemove", this.boundMouseMove);
1620
1631
  document.removeEventListener("mouseleave", this.boundMouseLeave);
1632
+ for (const evt of ["mousedown", "pointerdown"]) {
1633
+ window.removeEventListener(evt, this.boundAnnotateBlock, true);
1634
+ }
1621
1635
  window.removeEventListener("click", this.boundClick, true);
1622
1636
  }
1623
1637
  isInstruckt(el) {