@broberg/cms-inline-edit 0.7.1 → 0.7.2
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 +59 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1419,11 +1419,48 @@ function togglePageTools(options, forankring) {
|
|
|
1419
1419
|
plus.setAttribute("data-testid", "page-tools-tags-plus");
|
|
1420
1420
|
plus.style.cssText = "background:rgba(255,255,255,.04);border:1px solid #3a3f4a;border-radius:9px;padding:8px 12px;color:#fff;font:600 12px system-ui,sans-serif;cursor:pointer;";
|
|
1421
1421
|
plus.textContent = "# Tags +";
|
|
1422
|
+
const boks = document.createElement("div");
|
|
1423
|
+
boks.setAttribute("data-testid", "page-tools-tags-boks");
|
|
1424
|
+
boks.style.cssText = "flex:1;min-width:0;display:none;flex-wrap:wrap;align-items:center;gap:5px;background:#12151a;border:1px solid #3a3f4a;border-radius:8px;padding:5px 7px;cursor:text;";
|
|
1425
|
+
const chips = [];
|
|
1422
1426
|
const felt = document.createElement("input");
|
|
1423
1427
|
felt.type = "text";
|
|
1424
1428
|
felt.placeholder = "tag1, tag2, tag3";
|
|
1425
1429
|
felt.setAttribute("data-testid", "page-tools-tags-input");
|
|
1426
|
-
felt.style.cssText = "flex:1;min-width:
|
|
1430
|
+
felt.style.cssText = "flex:1;min-width:70px;background:transparent;border:none;padding:2px;color:#fff;font:12px system-ui,sans-serif;outline:none;";
|
|
1431
|
+
const tegnChips = () => {
|
|
1432
|
+
Array.prototype.forEach.call(boks.querySelectorAll("[data-chip]"), (c) => c.remove());
|
|
1433
|
+
chips.forEach((t, i) => {
|
|
1434
|
+
const chip = document.createElement("span");
|
|
1435
|
+
chip.setAttribute("data-chip", "");
|
|
1436
|
+
chip.setAttribute("data-testid", "page-tools-tag-chip");
|
|
1437
|
+
chip.style.cssText = "display:inline-flex;align-items:center;gap:4px;background:rgba(0,178,255,.15);border:1px solid rgba(0,178,255,.45);border-radius:999px;padding:2px 4px 2px 8px;color:#7fd8ff;font:600 11px system-ui,sans-serif;";
|
|
1438
|
+
chip.textContent = t;
|
|
1439
|
+
const x = document.createElement("button");
|
|
1440
|
+
x.type = "button";
|
|
1441
|
+
x.setAttribute("data-testid", "page-tools-tag-fjern");
|
|
1442
|
+
x.setAttribute("aria-label", `Fjern ${t}`);
|
|
1443
|
+
x.style.cssText = "background:none;border:none;color:#7fd8ff;font:700 13px system-ui,sans-serif;cursor:pointer;line-height:1;padding:0 3px;";
|
|
1444
|
+
x.textContent = "\xD7";
|
|
1445
|
+
x.addEventListener("click", (e) => {
|
|
1446
|
+
e.stopPropagation();
|
|
1447
|
+
chips.splice(i, 1);
|
|
1448
|
+
tegnChips();
|
|
1449
|
+
felt.focus();
|
|
1450
|
+
});
|
|
1451
|
+
chip.appendChild(x);
|
|
1452
|
+
boks.insertBefore(chip, felt);
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
const tagify = () => {
|
|
1456
|
+
const nye = parseTags(felt.value);
|
|
1457
|
+
for (const t of nye) {
|
|
1458
|
+
if (!chips.some((c) => c.toLowerCase() === t.toLowerCase())) chips.push(t);
|
|
1459
|
+
}
|
|
1460
|
+
felt.value = "";
|
|
1461
|
+
tegnChips();
|
|
1462
|
+
};
|
|
1463
|
+
boks.addEventListener("click", () => felt.focus());
|
|
1427
1464
|
const gem = document.createElement("button");
|
|
1428
1465
|
gem.type = "button";
|
|
1429
1466
|
gem.setAttribute("data-testid", "page-tools-tags-gem");
|
|
@@ -1431,12 +1468,13 @@ function togglePageTools(options, forankring) {
|
|
|
1431
1468
|
gem.textContent = "Gem";
|
|
1432
1469
|
plus.addEventListener("click", () => {
|
|
1433
1470
|
plus.style.display = "none";
|
|
1434
|
-
|
|
1471
|
+
boks.style.display = "flex";
|
|
1435
1472
|
gem.style.display = "inline-block";
|
|
1436
1473
|
felt.focus();
|
|
1437
1474
|
});
|
|
1438
1475
|
const gemTags = async () => {
|
|
1439
|
-
|
|
1476
|
+
tagify();
|
|
1477
|
+
const nye = [...chips];
|
|
1440
1478
|
if (!nye.length) return;
|
|
1441
1479
|
gem.disabled = true;
|
|
1442
1480
|
gem.textContent = "\u2026";
|
|
@@ -1449,6 +1487,8 @@ function togglePageTools(options, forankring) {
|
|
|
1449
1487
|
gem.textContent = holdt ? "Gemt \u2713" : "Fejl";
|
|
1450
1488
|
if (holdt) {
|
|
1451
1489
|
felt.value = "";
|
|
1490
|
+
chips.length = 0;
|
|
1491
|
+
tegnChips();
|
|
1452
1492
|
setTimeout(() => {
|
|
1453
1493
|
gem.textContent = "Gem";
|
|
1454
1494
|
gem.disabled = false;
|
|
@@ -1463,12 +1503,27 @@ function togglePageTools(options, forankring) {
|
|
|
1463
1503
|
};
|
|
1464
1504
|
gem.addEventListener("click", () => void gemTags());
|
|
1465
1505
|
felt.addEventListener("keydown", (e) => {
|
|
1506
|
+
if (e.key === ",") {
|
|
1507
|
+
e.preventDefault();
|
|
1508
|
+
tagify();
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1466
1511
|
if (e.key === "Enter") {
|
|
1467
1512
|
e.preventDefault();
|
|
1468
1513
|
void gemTags();
|
|
1514
|
+
return;
|
|
1469
1515
|
}
|
|
1516
|
+
if (e.key === "Backspace" && felt.value === "" && chips.length) {
|
|
1517
|
+
e.preventDefault();
|
|
1518
|
+
chips.pop();
|
|
1519
|
+
tegnChips();
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
felt.addEventListener("input", () => {
|
|
1523
|
+
if (felt.value.includes(",")) tagify();
|
|
1470
1524
|
});
|
|
1471
|
-
|
|
1525
|
+
boks.appendChild(felt);
|
|
1526
|
+
tagRow.append(plus, boks, gem);
|
|
1472
1527
|
popup.appendChild(tagRow);
|
|
1473
1528
|
const lukP\u00E5Klik = (e) => {
|
|
1474
1529
|
if (!popup.contains(e.target) && !forankring.contains(e.target)) luk();
|