web-remarq 0.4.4 → 0.4.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.
- package/dist/index.cjs +140 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +140 -60
- package/dist/index.js.map +1 -1
- package/dist/web-remarq.global.global.js +140 -60
- package/dist/web-remarq.global.global.js.map +1 -1
- package/package.json +1 -1
|
@@ -900,28 +900,26 @@ var WebRemarq = (() => {
|
|
|
900
900
|
|
|
901
901
|
.remarq-spacing {
|
|
902
902
|
position: fixed;
|
|
903
|
-
top: 0;
|
|
904
|
-
left: 0;
|
|
905
903
|
pointer-events: none;
|
|
906
904
|
z-index: 2147483646;
|
|
907
905
|
}
|
|
908
906
|
|
|
909
907
|
.remarq-spacing-margin {
|
|
910
|
-
position:
|
|
908
|
+
position: absolute;
|
|
911
909
|
background: rgba(249, 115, 22, 0.2);
|
|
912
910
|
pointer-events: none;
|
|
913
911
|
z-index: 1;
|
|
914
912
|
}
|
|
915
913
|
|
|
916
914
|
.remarq-spacing-padding {
|
|
917
|
-
position:
|
|
915
|
+
position: absolute;
|
|
918
916
|
background: rgba(34, 197, 94, 0.2);
|
|
919
917
|
pointer-events: none;
|
|
920
918
|
z-index: 2;
|
|
921
919
|
}
|
|
922
920
|
|
|
923
921
|
.remarq-spacing-content {
|
|
924
|
-
position:
|
|
922
|
+
position: absolute;
|
|
925
923
|
background: rgba(59, 130, 246, 0.3);
|
|
926
924
|
border: 1px dashed rgba(96, 165, 250, 0.8);
|
|
927
925
|
pointer-events: none;
|
|
@@ -939,7 +937,7 @@ var WebRemarq = (() => {
|
|
|
939
937
|
}
|
|
940
938
|
|
|
941
939
|
.remarq-spacing-label {
|
|
942
|
-
position:
|
|
940
|
+
position: absolute;
|
|
943
941
|
font-size: 11px;
|
|
944
942
|
font-weight: 700;
|
|
945
943
|
pointer-events: none;
|
|
@@ -1257,11 +1255,40 @@ var WebRemarq = (() => {
|
|
|
1257
1255
|
show(target) {
|
|
1258
1256
|
try {
|
|
1259
1257
|
const rect = target.getBoundingClientRect();
|
|
1258
|
+
const cs = window.getComputedStyle(target);
|
|
1259
|
+
const transform = cs.transform;
|
|
1260
|
+
const hasTransform = transform && transform !== "none";
|
|
1260
1261
|
this.overlayEl.style.display = "block";
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1262
|
+
if (hasTransform) {
|
|
1263
|
+
const w = target.offsetWidth;
|
|
1264
|
+
const h = target.offsetHeight;
|
|
1265
|
+
const origin = cs.transformOrigin;
|
|
1266
|
+
const [ox, oy] = origin.split(" ").map(parseFloat);
|
|
1267
|
+
const matrix = new DOMMatrix(transform);
|
|
1268
|
+
const corners = [
|
|
1269
|
+
matrix.transformPoint(new DOMPoint(-ox, -oy)),
|
|
1270
|
+
matrix.transformPoint(new DOMPoint(w - ox, -oy)),
|
|
1271
|
+
matrix.transformPoint(new DOMPoint(-ox, h - oy)),
|
|
1272
|
+
matrix.transformPoint(new DOMPoint(w - ox, h - oy))
|
|
1273
|
+
];
|
|
1274
|
+
const minX = Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x);
|
|
1275
|
+
const minY = Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y);
|
|
1276
|
+
const overlayX = rect.left - minX - ox;
|
|
1277
|
+
const overlayY = rect.top - minY - oy;
|
|
1278
|
+
this.overlayEl.style.left = `${overlayX}px`;
|
|
1279
|
+
this.overlayEl.style.top = `${overlayY}px`;
|
|
1280
|
+
this.overlayEl.style.width = `${w}px`;
|
|
1281
|
+
this.overlayEl.style.height = `${h}px`;
|
|
1282
|
+
this.overlayEl.style.transform = transform;
|
|
1283
|
+
this.overlayEl.style.transformOrigin = origin;
|
|
1284
|
+
} else {
|
|
1285
|
+
this.overlayEl.style.left = `${rect.left}px`;
|
|
1286
|
+
this.overlayEl.style.top = `${rect.top}px`;
|
|
1287
|
+
this.overlayEl.style.width = `${rect.width}px`;
|
|
1288
|
+
this.overlayEl.style.height = `${rect.height}px`;
|
|
1289
|
+
this.overlayEl.style.transform = "";
|
|
1290
|
+
this.overlayEl.style.transformOrigin = "";
|
|
1291
|
+
}
|
|
1265
1292
|
this.tooltipEl.textContent = describeElement(target);
|
|
1266
1293
|
this.tooltipEl.style.display = "block";
|
|
1267
1294
|
this.positionTooltip(rect.left, rect.top - 28);
|
|
@@ -1336,6 +1363,25 @@ var WebRemarq = (() => {
|
|
|
1336
1363
|
function parsePx(value) {
|
|
1337
1364
|
return parseFloat(value) || 0;
|
|
1338
1365
|
}
|
|
1366
|
+
function computeUntransformedOrigin(rect, offsetW, offsetH, transform, transformOrigin) {
|
|
1367
|
+
if (!transform || transform === "none") {
|
|
1368
|
+
return { x: rect.left, y: rect.top };
|
|
1369
|
+
}
|
|
1370
|
+
const [ox, oy] = transformOrigin.split(" ").map(parseFloat);
|
|
1371
|
+
const matrix = new DOMMatrix(transform);
|
|
1372
|
+
const corners = [
|
|
1373
|
+
matrix.transformPoint(new DOMPoint(-ox, -oy)),
|
|
1374
|
+
matrix.transformPoint(new DOMPoint(offsetW - ox, -oy)),
|
|
1375
|
+
matrix.transformPoint(new DOMPoint(-ox, offsetH - oy)),
|
|
1376
|
+
matrix.transformPoint(new DOMPoint(offsetW - ox, offsetH - oy))
|
|
1377
|
+
];
|
|
1378
|
+
const minX = Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x);
|
|
1379
|
+
const minY = Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y);
|
|
1380
|
+
return {
|
|
1381
|
+
x: rect.left - minX - ox,
|
|
1382
|
+
y: rect.top - minY - oy
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1339
1385
|
var SpacingOverlay = class {
|
|
1340
1386
|
constructor(parent) {
|
|
1341
1387
|
this.parent = parent;
|
|
@@ -1373,36 +1419,67 @@ var WebRemarq = (() => {
|
|
|
1373
1419
|
const margin = this.readSides(cs, "margin");
|
|
1374
1420
|
const padding = this.readSides(cs, "padding");
|
|
1375
1421
|
const border = this.readBorderSides(cs);
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1422
|
+
const transform = cs.transform;
|
|
1423
|
+
const transformOrigin = cs.transformOrigin;
|
|
1424
|
+
const hasTransform = transform && transform !== "none";
|
|
1425
|
+
const w = target.offsetWidth;
|
|
1426
|
+
const h = target.offsetHeight;
|
|
1427
|
+
const origin = computeUntransformedOrigin(rect, w, h, transform, transformOrigin);
|
|
1428
|
+
this.containerEl.style.left = `${origin.x}px`;
|
|
1429
|
+
this.containerEl.style.top = `${origin.y}px`;
|
|
1430
|
+
this.containerEl.style.width = `${w}px`;
|
|
1431
|
+
this.containerEl.style.height = `${h}px`;
|
|
1432
|
+
if (hasTransform) {
|
|
1433
|
+
this.containerEl.style.transform = transform;
|
|
1434
|
+
this.containerEl.style.transformOrigin = transformOrigin;
|
|
1435
|
+
} else {
|
|
1436
|
+
this.containerEl.style.transform = "";
|
|
1437
|
+
this.containerEl.style.transformOrigin = "";
|
|
1438
|
+
}
|
|
1439
|
+
this.positionEl(
|
|
1440
|
+
this.marginEl,
|
|
1441
|
+
-margin.left,
|
|
1442
|
+
-margin.top,
|
|
1443
|
+
w + margin.left + margin.right,
|
|
1444
|
+
h + margin.top + margin.bottom
|
|
1445
|
+
);
|
|
1446
|
+
this.positionEl(this.paddingEl, 0, 0, w, h);
|
|
1447
|
+
const contentLeft = border.left + padding.left;
|
|
1448
|
+
const contentTop = border.top + padding.top;
|
|
1449
|
+
const contentW = w - border.left - border.right - padding.left - padding.right;
|
|
1450
|
+
const contentH = h - border.top - border.bottom - padding.top - padding.bottom;
|
|
1451
|
+
this.positionEl(this.contentEl, contentLeft, contentTop, contentW, contentH);
|
|
1397
1452
|
this.clearLabels();
|
|
1398
1453
|
this.clearGaps();
|
|
1399
|
-
this.
|
|
1400
|
-
|
|
1401
|
-
|
|
1454
|
+
this.addMarginPaddingLabels(
|
|
1455
|
+
margin,
|
|
1456
|
+
-margin.left,
|
|
1457
|
+
-margin.top,
|
|
1458
|
+
w + margin.left + margin.right,
|
|
1459
|
+
h + margin.top + margin.bottom,
|
|
1460
|
+
0,
|
|
1461
|
+
0,
|
|
1462
|
+
w,
|
|
1463
|
+
h,
|
|
1464
|
+
"margin"
|
|
1465
|
+
);
|
|
1466
|
+
this.addMarginPaddingLabels(
|
|
1467
|
+
padding,
|
|
1468
|
+
0,
|
|
1469
|
+
0,
|
|
1470
|
+
w,
|
|
1471
|
+
h,
|
|
1472
|
+
contentLeft,
|
|
1473
|
+
contentTop,
|
|
1474
|
+
contentW,
|
|
1475
|
+
contentH,
|
|
1476
|
+
"padding"
|
|
1477
|
+
);
|
|
1478
|
+
if (contentW > 40 && contentH > 14) {
|
|
1402
1479
|
this.addLabel(
|
|
1403
|
-
`${Math.round(
|
|
1404
|
-
|
|
1405
|
-
|
|
1480
|
+
`${Math.round(contentW)} \xD7 ${Math.round(contentH)}`,
|
|
1481
|
+
contentTop + contentH / 2 - 6,
|
|
1482
|
+
contentLeft + contentW / 2,
|
|
1406
1483
|
"content"
|
|
1407
1484
|
);
|
|
1408
1485
|
}
|
|
@@ -1440,34 +1517,34 @@ var WebRemarq = (() => {
|
|
|
1440
1517
|
left: parsePx(cs.borderLeftWidth)
|
|
1441
1518
|
};
|
|
1442
1519
|
}
|
|
1443
|
-
positionEl(el,
|
|
1444
|
-
el.style.
|
|
1445
|
-
el.style.
|
|
1446
|
-
el.style.width = `${Math.max(0,
|
|
1447
|
-
el.style.height = `${Math.max(0,
|
|
1520
|
+
positionEl(el, left, top, width, height) {
|
|
1521
|
+
el.style.left = `${left}px`;
|
|
1522
|
+
el.style.top = `${top}px`;
|
|
1523
|
+
el.style.width = `${Math.max(0, width)}px`;
|
|
1524
|
+
el.style.height = `${Math.max(0, height)}px`;
|
|
1448
1525
|
}
|
|
1449
|
-
|
|
1526
|
+
addMarginPaddingLabels(sides, outerLeft, outerTop, outerW, outerH, innerLeft, innerTop, innerW, innerH, type) {
|
|
1450
1527
|
if (sides.top > 0) {
|
|
1451
|
-
const y =
|
|
1452
|
-
const x =
|
|
1528
|
+
const y = outerTop + (innerTop - outerTop) / 2 - 6;
|
|
1529
|
+
const x = outerLeft + outerW / 2;
|
|
1453
1530
|
this.addLabel(String(Math.round(sides.top)), y, x, type);
|
|
1454
1531
|
}
|
|
1455
1532
|
if (sides.bottom > 0) {
|
|
1456
|
-
const innerBottom =
|
|
1457
|
-
const outerBottom =
|
|
1533
|
+
const innerBottom = innerTop + innerH;
|
|
1534
|
+
const outerBottom = outerTop + outerH;
|
|
1458
1535
|
const y = innerBottom + (outerBottom - innerBottom) / 2 - 6;
|
|
1459
|
-
const x =
|
|
1536
|
+
const x = outerLeft + outerW / 2;
|
|
1460
1537
|
this.addLabel(String(Math.round(sides.bottom)), y, x, type);
|
|
1461
1538
|
}
|
|
1462
1539
|
if (sides.left > 0) {
|
|
1463
|
-
const y =
|
|
1464
|
-
const x =
|
|
1540
|
+
const y = outerTop + outerH / 2 - 6;
|
|
1541
|
+
const x = outerLeft + (innerLeft - outerLeft) / 2;
|
|
1465
1542
|
this.addLabel(String(Math.round(sides.left)), y, x, type);
|
|
1466
1543
|
}
|
|
1467
1544
|
if (sides.right > 0) {
|
|
1468
|
-
const innerRight =
|
|
1469
|
-
const outerRight =
|
|
1470
|
-
const y =
|
|
1545
|
+
const innerRight = innerLeft + innerW;
|
|
1546
|
+
const outerRight = outerLeft + outerW;
|
|
1547
|
+
const y = outerTop + outerH / 2 - 6;
|
|
1471
1548
|
const x = innerRight + (outerRight - innerRight) / 2;
|
|
1472
1549
|
this.addLabel(String(Math.round(sides.right)), y, x, type);
|
|
1473
1550
|
}
|
|
@@ -1527,13 +1604,15 @@ var WebRemarq = (() => {
|
|
|
1527
1604
|
renderGap(before, after, gap, isRow) {
|
|
1528
1605
|
const rectBefore = before.getBoundingClientRect();
|
|
1529
1606
|
const rectAfter = after.getBoundingClientRect();
|
|
1607
|
+
const parent = before.parentElement;
|
|
1608
|
+
const parentRect = parent ? parent.getBoundingClientRect() : null;
|
|
1530
1609
|
const gapEl = document.createElement("div");
|
|
1531
1610
|
gapEl.className = "remarq-spacing-gap";
|
|
1532
1611
|
if (isRow) {
|
|
1533
1612
|
const left = Math.min(rectBefore.right, rectAfter.right);
|
|
1534
1613
|
const right = Math.max(rectBefore.left, rectAfter.left);
|
|
1535
|
-
const top = Math.min(rectBefore.top, rectAfter.top);
|
|
1536
|
-
const height = Math.max(rectBefore.height, rectAfter.height);
|
|
1614
|
+
const top = parentRect ? parentRect.top : Math.min(rectBefore.top, rectAfter.top);
|
|
1615
|
+
const height = parentRect ? parentRect.height : Math.max(rectBefore.height, rectAfter.height);
|
|
1537
1616
|
gapEl.style.top = `${top}px`;
|
|
1538
1617
|
gapEl.style.left = `${left}px`;
|
|
1539
1618
|
gapEl.style.width = `${Math.abs(right - left)}px`;
|
|
@@ -1541,8 +1620,8 @@ var WebRemarq = (() => {
|
|
|
1541
1620
|
} else {
|
|
1542
1621
|
const top = Math.min(rectBefore.bottom, rectAfter.bottom);
|
|
1543
1622
|
const bottom = Math.max(rectBefore.top, rectAfter.top);
|
|
1544
|
-
const left = Math.min(rectBefore.left, rectAfter.left);
|
|
1545
|
-
const width = Math.max(rectBefore.width, rectAfter.width);
|
|
1623
|
+
const left = parentRect ? parentRect.left : Math.min(rectBefore.left, rectAfter.left);
|
|
1624
|
+
const width = parentRect ? parentRect.width : Math.max(rectBefore.width, rectAfter.width);
|
|
1546
1625
|
gapEl.style.top = `${top}px`;
|
|
1547
1626
|
gapEl.style.left = `${left}px`;
|
|
1548
1627
|
gapEl.style.width = `${width}px`;
|
|
@@ -1555,7 +1634,7 @@ var WebRemarq = (() => {
|
|
|
1555
1634
|
label.style.cssText = "font-size:10px;font-weight:700;pointer-events:none;";
|
|
1556
1635
|
gapEl.appendChild(label);
|
|
1557
1636
|
}
|
|
1558
|
-
this.
|
|
1637
|
+
this.parent.appendChild(gapEl);
|
|
1559
1638
|
this.gapEls.push(gapEl);
|
|
1560
1639
|
}
|
|
1561
1640
|
clearGaps() {
|
|
@@ -2024,7 +2103,7 @@ var WebRemarq = (() => {
|
|
|
2024
2103
|
var SHORTCUTS = [
|
|
2025
2104
|
{ key: `${modKey2}+I`, description: "Toggle inspect mode" },
|
|
2026
2105
|
{ key: "S", description: "Toggle spacing overlay", context: "inspect" },
|
|
2027
|
-
{ key:
|
|
2106
|
+
{ key: `${modKey2}+C`, description: "Copy all annotations to clipboard" },
|
|
2028
2107
|
{ key: "Esc", description: "Exit inspect mode / close popup" },
|
|
2029
2108
|
{ key: "?", description: "Show this help" },
|
|
2030
2109
|
{ key: "Enter", description: "Submit annotation", context: "popup" },
|
|
@@ -2314,7 +2393,8 @@ var WebRemarq = (() => {
|
|
|
2314
2393
|
spacingOverlay.hide();
|
|
2315
2394
|
}
|
|
2316
2395
|
}
|
|
2317
|
-
if (e.key === "c"
|
|
2396
|
+
if (e.altKey && e.key === "c") {
|
|
2397
|
+
e.preventDefault();
|
|
2318
2398
|
copyToClipboard();
|
|
2319
2399
|
}
|
|
2320
2400
|
if (e.key === "?") {
|