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
package/dist/index.js
CHANGED
|
@@ -877,28 +877,26 @@ var CSS = `
|
|
|
877
877
|
|
|
878
878
|
.remarq-spacing {
|
|
879
879
|
position: fixed;
|
|
880
|
-
top: 0;
|
|
881
|
-
left: 0;
|
|
882
880
|
pointer-events: none;
|
|
883
881
|
z-index: 2147483646;
|
|
884
882
|
}
|
|
885
883
|
|
|
886
884
|
.remarq-spacing-margin {
|
|
887
|
-
position:
|
|
885
|
+
position: absolute;
|
|
888
886
|
background: rgba(249, 115, 22, 0.2);
|
|
889
887
|
pointer-events: none;
|
|
890
888
|
z-index: 1;
|
|
891
889
|
}
|
|
892
890
|
|
|
893
891
|
.remarq-spacing-padding {
|
|
894
|
-
position:
|
|
892
|
+
position: absolute;
|
|
895
893
|
background: rgba(34, 197, 94, 0.2);
|
|
896
894
|
pointer-events: none;
|
|
897
895
|
z-index: 2;
|
|
898
896
|
}
|
|
899
897
|
|
|
900
898
|
.remarq-spacing-content {
|
|
901
|
-
position:
|
|
899
|
+
position: absolute;
|
|
902
900
|
background: rgba(59, 130, 246, 0.3);
|
|
903
901
|
border: 1px dashed rgba(96, 165, 250, 0.8);
|
|
904
902
|
pointer-events: none;
|
|
@@ -916,7 +914,7 @@ var CSS = `
|
|
|
916
914
|
}
|
|
917
915
|
|
|
918
916
|
.remarq-spacing-label {
|
|
919
|
-
position:
|
|
917
|
+
position: absolute;
|
|
920
918
|
font-size: 11px;
|
|
921
919
|
font-weight: 700;
|
|
922
920
|
pointer-events: none;
|
|
@@ -1234,11 +1232,40 @@ var Overlay = class {
|
|
|
1234
1232
|
show(target) {
|
|
1235
1233
|
try {
|
|
1236
1234
|
const rect = target.getBoundingClientRect();
|
|
1235
|
+
const cs = window.getComputedStyle(target);
|
|
1236
|
+
const transform = cs.transform;
|
|
1237
|
+
const hasTransform = transform && transform !== "none";
|
|
1237
1238
|
this.overlayEl.style.display = "block";
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1239
|
+
if (hasTransform) {
|
|
1240
|
+
const w = target.offsetWidth;
|
|
1241
|
+
const h = target.offsetHeight;
|
|
1242
|
+
const origin = cs.transformOrigin;
|
|
1243
|
+
const [ox, oy] = origin.split(" ").map(parseFloat);
|
|
1244
|
+
const matrix = new DOMMatrix(transform);
|
|
1245
|
+
const corners = [
|
|
1246
|
+
matrix.transformPoint(new DOMPoint(-ox, -oy)),
|
|
1247
|
+
matrix.transformPoint(new DOMPoint(w - ox, -oy)),
|
|
1248
|
+
matrix.transformPoint(new DOMPoint(-ox, h - oy)),
|
|
1249
|
+
matrix.transformPoint(new DOMPoint(w - ox, h - oy))
|
|
1250
|
+
];
|
|
1251
|
+
const minX = Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x);
|
|
1252
|
+
const minY = Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y);
|
|
1253
|
+
const overlayX = rect.left - minX - ox;
|
|
1254
|
+
const overlayY = rect.top - minY - oy;
|
|
1255
|
+
this.overlayEl.style.left = `${overlayX}px`;
|
|
1256
|
+
this.overlayEl.style.top = `${overlayY}px`;
|
|
1257
|
+
this.overlayEl.style.width = `${w}px`;
|
|
1258
|
+
this.overlayEl.style.height = `${h}px`;
|
|
1259
|
+
this.overlayEl.style.transform = transform;
|
|
1260
|
+
this.overlayEl.style.transformOrigin = origin;
|
|
1261
|
+
} else {
|
|
1262
|
+
this.overlayEl.style.left = `${rect.left}px`;
|
|
1263
|
+
this.overlayEl.style.top = `${rect.top}px`;
|
|
1264
|
+
this.overlayEl.style.width = `${rect.width}px`;
|
|
1265
|
+
this.overlayEl.style.height = `${rect.height}px`;
|
|
1266
|
+
this.overlayEl.style.transform = "";
|
|
1267
|
+
this.overlayEl.style.transformOrigin = "";
|
|
1268
|
+
}
|
|
1242
1269
|
this.tooltipEl.textContent = describeElement(target);
|
|
1243
1270
|
this.tooltipEl.style.display = "block";
|
|
1244
1271
|
this.positionTooltip(rect.left, rect.top - 28);
|
|
@@ -1313,6 +1340,25 @@ function getDirectText(el) {
|
|
|
1313
1340
|
function parsePx(value) {
|
|
1314
1341
|
return parseFloat(value) || 0;
|
|
1315
1342
|
}
|
|
1343
|
+
function computeUntransformedOrigin(rect, offsetW, offsetH, transform, transformOrigin) {
|
|
1344
|
+
if (!transform || transform === "none") {
|
|
1345
|
+
return { x: rect.left, y: rect.top };
|
|
1346
|
+
}
|
|
1347
|
+
const [ox, oy] = transformOrigin.split(" ").map(parseFloat);
|
|
1348
|
+
const matrix = new DOMMatrix(transform);
|
|
1349
|
+
const corners = [
|
|
1350
|
+
matrix.transformPoint(new DOMPoint(-ox, -oy)),
|
|
1351
|
+
matrix.transformPoint(new DOMPoint(offsetW - ox, -oy)),
|
|
1352
|
+
matrix.transformPoint(new DOMPoint(-ox, offsetH - oy)),
|
|
1353
|
+
matrix.transformPoint(new DOMPoint(offsetW - ox, offsetH - oy))
|
|
1354
|
+
];
|
|
1355
|
+
const minX = Math.min(corners[0].x, corners[1].x, corners[2].x, corners[3].x);
|
|
1356
|
+
const minY = Math.min(corners[0].y, corners[1].y, corners[2].y, corners[3].y);
|
|
1357
|
+
return {
|
|
1358
|
+
x: rect.left - minX - ox,
|
|
1359
|
+
y: rect.top - minY - oy
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1316
1362
|
var SpacingOverlay = class {
|
|
1317
1363
|
constructor(parent) {
|
|
1318
1364
|
this.parent = parent;
|
|
@@ -1350,36 +1396,67 @@ var SpacingOverlay = class {
|
|
|
1350
1396
|
const margin = this.readSides(cs, "margin");
|
|
1351
1397
|
const padding = this.readSides(cs, "padding");
|
|
1352
1398
|
const border = this.readBorderSides(cs);
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1399
|
+
const transform = cs.transform;
|
|
1400
|
+
const transformOrigin = cs.transformOrigin;
|
|
1401
|
+
const hasTransform = transform && transform !== "none";
|
|
1402
|
+
const w = target.offsetWidth;
|
|
1403
|
+
const h = target.offsetHeight;
|
|
1404
|
+
const origin = computeUntransformedOrigin(rect, w, h, transform, transformOrigin);
|
|
1405
|
+
this.containerEl.style.left = `${origin.x}px`;
|
|
1406
|
+
this.containerEl.style.top = `${origin.y}px`;
|
|
1407
|
+
this.containerEl.style.width = `${w}px`;
|
|
1408
|
+
this.containerEl.style.height = `${h}px`;
|
|
1409
|
+
if (hasTransform) {
|
|
1410
|
+
this.containerEl.style.transform = transform;
|
|
1411
|
+
this.containerEl.style.transformOrigin = transformOrigin;
|
|
1412
|
+
} else {
|
|
1413
|
+
this.containerEl.style.transform = "";
|
|
1414
|
+
this.containerEl.style.transformOrigin = "";
|
|
1415
|
+
}
|
|
1416
|
+
this.positionEl(
|
|
1417
|
+
this.marginEl,
|
|
1418
|
+
-margin.left,
|
|
1419
|
+
-margin.top,
|
|
1420
|
+
w + margin.left + margin.right,
|
|
1421
|
+
h + margin.top + margin.bottom
|
|
1422
|
+
);
|
|
1423
|
+
this.positionEl(this.paddingEl, 0, 0, w, h);
|
|
1424
|
+
const contentLeft = border.left + padding.left;
|
|
1425
|
+
const contentTop = border.top + padding.top;
|
|
1426
|
+
const contentW = w - border.left - border.right - padding.left - padding.right;
|
|
1427
|
+
const contentH = h - border.top - border.bottom - padding.top - padding.bottom;
|
|
1428
|
+
this.positionEl(this.contentEl, contentLeft, contentTop, contentW, contentH);
|
|
1374
1429
|
this.clearLabels();
|
|
1375
1430
|
this.clearGaps();
|
|
1376
|
-
this.
|
|
1377
|
-
|
|
1378
|
-
|
|
1431
|
+
this.addMarginPaddingLabels(
|
|
1432
|
+
margin,
|
|
1433
|
+
-margin.left,
|
|
1434
|
+
-margin.top,
|
|
1435
|
+
w + margin.left + margin.right,
|
|
1436
|
+
h + margin.top + margin.bottom,
|
|
1437
|
+
0,
|
|
1438
|
+
0,
|
|
1439
|
+
w,
|
|
1440
|
+
h,
|
|
1441
|
+
"margin"
|
|
1442
|
+
);
|
|
1443
|
+
this.addMarginPaddingLabels(
|
|
1444
|
+
padding,
|
|
1445
|
+
0,
|
|
1446
|
+
0,
|
|
1447
|
+
w,
|
|
1448
|
+
h,
|
|
1449
|
+
contentLeft,
|
|
1450
|
+
contentTop,
|
|
1451
|
+
contentW,
|
|
1452
|
+
contentH,
|
|
1453
|
+
"padding"
|
|
1454
|
+
);
|
|
1455
|
+
if (contentW > 40 && contentH > 14) {
|
|
1379
1456
|
this.addLabel(
|
|
1380
|
-
`${Math.round(
|
|
1381
|
-
|
|
1382
|
-
|
|
1457
|
+
`${Math.round(contentW)} \xD7 ${Math.round(contentH)}`,
|
|
1458
|
+
contentTop + contentH / 2 - 6,
|
|
1459
|
+
contentLeft + contentW / 2,
|
|
1383
1460
|
"content"
|
|
1384
1461
|
);
|
|
1385
1462
|
}
|
|
@@ -1417,34 +1494,34 @@ var SpacingOverlay = class {
|
|
|
1417
1494
|
left: parsePx(cs.borderLeftWidth)
|
|
1418
1495
|
};
|
|
1419
1496
|
}
|
|
1420
|
-
positionEl(el,
|
|
1421
|
-
el.style.
|
|
1422
|
-
el.style.
|
|
1423
|
-
el.style.width = `${Math.max(0,
|
|
1424
|
-
el.style.height = `${Math.max(0,
|
|
1497
|
+
positionEl(el, left, top, width, height) {
|
|
1498
|
+
el.style.left = `${left}px`;
|
|
1499
|
+
el.style.top = `${top}px`;
|
|
1500
|
+
el.style.width = `${Math.max(0, width)}px`;
|
|
1501
|
+
el.style.height = `${Math.max(0, height)}px`;
|
|
1425
1502
|
}
|
|
1426
|
-
|
|
1503
|
+
addMarginPaddingLabels(sides, outerLeft, outerTop, outerW, outerH, innerLeft, innerTop, innerW, innerH, type) {
|
|
1427
1504
|
if (sides.top > 0) {
|
|
1428
|
-
const y =
|
|
1429
|
-
const x =
|
|
1505
|
+
const y = outerTop + (innerTop - outerTop) / 2 - 6;
|
|
1506
|
+
const x = outerLeft + outerW / 2;
|
|
1430
1507
|
this.addLabel(String(Math.round(sides.top)), y, x, type);
|
|
1431
1508
|
}
|
|
1432
1509
|
if (sides.bottom > 0) {
|
|
1433
|
-
const innerBottom =
|
|
1434
|
-
const outerBottom =
|
|
1510
|
+
const innerBottom = innerTop + innerH;
|
|
1511
|
+
const outerBottom = outerTop + outerH;
|
|
1435
1512
|
const y = innerBottom + (outerBottom - innerBottom) / 2 - 6;
|
|
1436
|
-
const x =
|
|
1513
|
+
const x = outerLeft + outerW / 2;
|
|
1437
1514
|
this.addLabel(String(Math.round(sides.bottom)), y, x, type);
|
|
1438
1515
|
}
|
|
1439
1516
|
if (sides.left > 0) {
|
|
1440
|
-
const y =
|
|
1441
|
-
const x =
|
|
1517
|
+
const y = outerTop + outerH / 2 - 6;
|
|
1518
|
+
const x = outerLeft + (innerLeft - outerLeft) / 2;
|
|
1442
1519
|
this.addLabel(String(Math.round(sides.left)), y, x, type);
|
|
1443
1520
|
}
|
|
1444
1521
|
if (sides.right > 0) {
|
|
1445
|
-
const innerRight =
|
|
1446
|
-
const outerRight =
|
|
1447
|
-
const y =
|
|
1522
|
+
const innerRight = innerLeft + innerW;
|
|
1523
|
+
const outerRight = outerLeft + outerW;
|
|
1524
|
+
const y = outerTop + outerH / 2 - 6;
|
|
1448
1525
|
const x = innerRight + (outerRight - innerRight) / 2;
|
|
1449
1526
|
this.addLabel(String(Math.round(sides.right)), y, x, type);
|
|
1450
1527
|
}
|
|
@@ -1504,13 +1581,15 @@ var SpacingOverlay = class {
|
|
|
1504
1581
|
renderGap(before, after, gap, isRow) {
|
|
1505
1582
|
const rectBefore = before.getBoundingClientRect();
|
|
1506
1583
|
const rectAfter = after.getBoundingClientRect();
|
|
1584
|
+
const parent = before.parentElement;
|
|
1585
|
+
const parentRect = parent ? parent.getBoundingClientRect() : null;
|
|
1507
1586
|
const gapEl = document.createElement("div");
|
|
1508
1587
|
gapEl.className = "remarq-spacing-gap";
|
|
1509
1588
|
if (isRow) {
|
|
1510
1589
|
const left = Math.min(rectBefore.right, rectAfter.right);
|
|
1511
1590
|
const right = Math.max(rectBefore.left, rectAfter.left);
|
|
1512
|
-
const top = Math.min(rectBefore.top, rectAfter.top);
|
|
1513
|
-
const height = Math.max(rectBefore.height, rectAfter.height);
|
|
1591
|
+
const top = parentRect ? parentRect.top : Math.min(rectBefore.top, rectAfter.top);
|
|
1592
|
+
const height = parentRect ? parentRect.height : Math.max(rectBefore.height, rectAfter.height);
|
|
1514
1593
|
gapEl.style.top = `${top}px`;
|
|
1515
1594
|
gapEl.style.left = `${left}px`;
|
|
1516
1595
|
gapEl.style.width = `${Math.abs(right - left)}px`;
|
|
@@ -1518,8 +1597,8 @@ var SpacingOverlay = class {
|
|
|
1518
1597
|
} else {
|
|
1519
1598
|
const top = Math.min(rectBefore.bottom, rectAfter.bottom);
|
|
1520
1599
|
const bottom = Math.max(rectBefore.top, rectAfter.top);
|
|
1521
|
-
const left = Math.min(rectBefore.left, rectAfter.left);
|
|
1522
|
-
const width = Math.max(rectBefore.width, rectAfter.width);
|
|
1600
|
+
const left = parentRect ? parentRect.left : Math.min(rectBefore.left, rectAfter.left);
|
|
1601
|
+
const width = parentRect ? parentRect.width : Math.max(rectBefore.width, rectAfter.width);
|
|
1523
1602
|
gapEl.style.top = `${top}px`;
|
|
1524
1603
|
gapEl.style.left = `${left}px`;
|
|
1525
1604
|
gapEl.style.width = `${width}px`;
|
|
@@ -1532,7 +1611,7 @@ var SpacingOverlay = class {
|
|
|
1532
1611
|
label.style.cssText = "font-size:10px;font-weight:700;pointer-events:none;";
|
|
1533
1612
|
gapEl.appendChild(label);
|
|
1534
1613
|
}
|
|
1535
|
-
this.
|
|
1614
|
+
this.parent.appendChild(gapEl);
|
|
1536
1615
|
this.gapEls.push(gapEl);
|
|
1537
1616
|
}
|
|
1538
1617
|
clearGaps() {
|
|
@@ -2001,7 +2080,7 @@ var modKey2 = isMac2 ? "\u2325" : "Alt";
|
|
|
2001
2080
|
var SHORTCUTS = [
|
|
2002
2081
|
{ key: `${modKey2}+I`, description: "Toggle inspect mode" },
|
|
2003
2082
|
{ key: "S", description: "Toggle spacing overlay", context: "inspect" },
|
|
2004
|
-
{ key:
|
|
2083
|
+
{ key: `${modKey2}+C`, description: "Copy all annotations to clipboard" },
|
|
2005
2084
|
{ key: "Esc", description: "Exit inspect mode / close popup" },
|
|
2006
2085
|
{ key: "?", description: "Show this help" },
|
|
2007
2086
|
{ key: "Enter", description: "Submit annotation", context: "popup" },
|
|
@@ -2291,7 +2370,8 @@ function handleInspectKeydown(e) {
|
|
|
2291
2370
|
spacingOverlay.hide();
|
|
2292
2371
|
}
|
|
2293
2372
|
}
|
|
2294
|
-
if (e.key === "c"
|
|
2373
|
+
if (e.altKey && e.key === "c") {
|
|
2374
|
+
e.preventDefault();
|
|
2295
2375
|
copyToClipboard();
|
|
2296
2376
|
}
|
|
2297
2377
|
if (e.key === "?") {
|