@progress/kendo-pdfviewer-common 0.4.2-develop.1 → 0.5.0-develop.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/es/annotations/annotation-editor-layer-builder.js +6 -1
- package/dist/es/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/es/annotations/annotation-layer-builder.js +14 -4
- package/dist/es/annotations/annotation-layer.js +358 -337
- package/dist/es/annotations/draw-layer-builder.js +5 -1
- package/dist/es/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/es/annotations/shared/event_utils.js +6 -0
- package/dist/es/text/text-layer-builder.js +13 -1
- package/dist/es/utils.js +3 -2
- package/dist/es/widget/page.js +22 -0
- package/dist/es/widget/pdfviewer.js +24 -13
- package/dist/es2015/annotations/annotation-editor-layer-builder.js +6 -1
- package/dist/es2015/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/es2015/annotations/annotation-layer-builder.js +14 -4
- package/dist/es2015/annotations/annotation-layer.js +358 -337
- package/dist/es2015/annotations/draw-layer-builder.js +5 -1
- package/dist/es2015/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es2015/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/es2015/annotations/shared/event_utils.js +6 -0
- package/dist/es2015/text/text-layer-builder.js +13 -1
- package/dist/es2015/utils.js +3 -2
- package/dist/es2015/widget/page.js +22 -0
- package/dist/es2015/widget/pdfviewer.js +24 -13
- package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/annotation-editor-layer-builder.js +6 -1
- package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +3 -0
- package/dist/npm/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/npm/annotations/annotation-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/annotation-layer-builder.js +14 -4
- package/dist/npm/annotations/annotation-layer.d.ts +3 -1
- package/dist/npm/annotations/annotation-layer.js +358 -337
- package/dist/npm/annotations/draw-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/draw-layer-builder.js +5 -1
- package/dist/npm/annotations/helpers/annotation-storage.d.ts +10 -0
- package/dist/npm/annotations/helpers/annotation-storage.js +14 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +1 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/npm/annotations/shared/event_utils.d.ts +4 -0
- package/dist/npm/annotations/shared/event_utils.js +6 -0
- package/dist/npm/text/text-layer-builder.d.ts +3 -1
- package/dist/npm/text/text-layer-builder.js +13 -1
- package/dist/npm/utils.d.ts +1 -0
- package/dist/npm/utils.js +5 -3
- package/dist/npm/widget/page.js +22 -0
- package/dist/npm/widget/pdfviewer.d.ts +1 -0
- package/dist/npm/widget/pdfviewer.js +23 -12
- package/package.json +1 -1
|
@@ -17,8 +17,7 @@ import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib
|
|
|
17
17
|
import { AnnotationEditorType, DOMSVGFactory, FeatureTest, PDFDateString, setLayerDimensions, shadow, Util, XfaLayer } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
18
18
|
import { AnnotationBorderStyleType, AnnotationPrefix, AnnotationType, LINE_FACTOR } from "./shared/utils";
|
|
19
19
|
import { ColorConverters } from "./shared/scripting_utils";
|
|
20
|
-
|
|
21
|
-
// import { AnnotationStorage } from "pdfjs-dist/types/src/display/annotation_storage";
|
|
20
|
+
import { AnnotationStorage } from "./helpers/annotation-storage";
|
|
22
21
|
// const DEFAULT_TAB_INDEX = 1000;
|
|
23
22
|
// it is unclear why the value 1000 is chosen by pdf.js
|
|
24
23
|
// kendo a11y tests fail if this is not 0
|
|
@@ -48,15 +47,16 @@ class AnnotationElementFactory {
|
|
|
48
47
|
switch (fieldType) {
|
|
49
48
|
case "Tx":
|
|
50
49
|
return new TextWidgetAnnotationElement(parameters);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
case "Btn":
|
|
51
|
+
if (parameters.data.radioButton) {
|
|
52
|
+
return new RadioButtonWidgetAnnotationElement(parameters);
|
|
53
|
+
}
|
|
54
|
+
else if (parameters.data.checkBox) {
|
|
55
|
+
return new CheckboxWidgetAnnotationElement(parameters);
|
|
56
|
+
}
|
|
57
|
+
return new PushButtonWidgetAnnotationElement(parameters);
|
|
58
|
+
case "Ch":
|
|
59
|
+
return new ChoiceWidgetAnnotationElement(parameters);
|
|
60
60
|
// case "Sig":
|
|
61
61
|
// return new SignatureWidgetAnnotationElement(parameters);
|
|
62
62
|
default:
|
|
@@ -1382,89 +1382,107 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
1382
1382
|
// super(parameters, { isRenderable: !!parameters.data.hasOwnCanvas });
|
|
1383
1383
|
// }
|
|
1384
1384
|
// }
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
//
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
//
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
//
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1385
|
+
class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
1386
|
+
constructor(parameters) {
|
|
1387
|
+
super(parameters, { isRenderable: parameters.renderForms });
|
|
1388
|
+
}
|
|
1389
|
+
render() {
|
|
1390
|
+
const storage = this.annotationStorage;
|
|
1391
|
+
const data = this.data;
|
|
1392
|
+
const id = data.id;
|
|
1393
|
+
let value = storage.getValue(id, {
|
|
1394
|
+
value: data.exportValue === data.fieldValue
|
|
1395
|
+
}).value;
|
|
1396
|
+
if (typeof value === "string") {
|
|
1397
|
+
// The value has been changed through js and set in annotationStorage.
|
|
1398
|
+
value = value !== "Off";
|
|
1399
|
+
storage.setValue(id, { value });
|
|
1400
|
+
}
|
|
1401
|
+
// this.container.classList.add("buttonWidgetAnnotation", "checkBox");
|
|
1402
|
+
this.container.classList.add("k-button-widget-annotation", "k-checkbox-widget-annotation");
|
|
1403
|
+
const element = document.createElement("input");
|
|
1404
|
+
GetElementsByNameSet.add(element);
|
|
1405
|
+
element.setAttribute("data-element-id", id);
|
|
1406
|
+
element.disabled = data.readOnly;
|
|
1407
|
+
this._setRequired(element, this.data.required);
|
|
1408
|
+
element.type = "checkbox";
|
|
1409
|
+
element.name = data.fieldName;
|
|
1410
|
+
if (value) {
|
|
1411
|
+
element.setAttribute("checked", (true).toString());
|
|
1412
|
+
}
|
|
1413
|
+
element.setAttribute("exportValue", data.exportValue);
|
|
1414
|
+
element.tabIndex = DEFAULT_TAB_INDEX;
|
|
1415
|
+
element.addEventListener("change", event => {
|
|
1416
|
+
const { name, checked } = event.target;
|
|
1417
|
+
for (const checkbox of this._getElementsByName(name, /* skipId = */ id)) {
|
|
1418
|
+
const curChecked = checked && checkbox.exportValue === data.exportValue;
|
|
1419
|
+
if (checkbox.domElement) {
|
|
1420
|
+
checkbox.domElement.checked = curChecked;
|
|
1421
|
+
}
|
|
1422
|
+
storage.setValue(checkbox.id, { value: curChecked });
|
|
1423
|
+
}
|
|
1424
|
+
storage.setValue(id, { value: checked });
|
|
1425
|
+
});
|
|
1426
|
+
element.addEventListener("resetform", event => {
|
|
1427
|
+
const defaultValue = data.defaultFieldValue || "Off";
|
|
1428
|
+
// @ts-expect-error(TS)
|
|
1429
|
+
event.target.checked = defaultValue === data.exportValue;
|
|
1430
|
+
});
|
|
1431
|
+
if (this.enableScripting && this.hasJSActions) {
|
|
1432
|
+
element.addEventListener("updatefromsandbox", jsEvent => {
|
|
1433
|
+
const actions = {
|
|
1434
|
+
value(event) {
|
|
1435
|
+
event.target.checked = event.detail.value !== "Off";
|
|
1436
|
+
storage.setValue(id, { value: event.target.checked });
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
this._dispatchEventFromSandbox(actions, jsEvent);
|
|
1440
|
+
});
|
|
1441
|
+
this._setEventListeners(element, null, [
|
|
1442
|
+
["change", "Validate"],
|
|
1443
|
+
["change", "Action"],
|
|
1444
|
+
["focus", "Focus"],
|
|
1445
|
+
["blur", "Blur"],
|
|
1446
|
+
["mousedown", "Mouse Down"],
|
|
1447
|
+
["mouseenter", "Mouse Enter"],
|
|
1448
|
+
["mouseleave", "Mouse Exit"],
|
|
1449
|
+
["mouseup", "Mouse Up"]
|
|
1450
|
+
], event => event.target.checked);
|
|
1451
|
+
}
|
|
1452
|
+
if (this.enableScripting && this.hasJSActions) {
|
|
1453
|
+
element.addEventListener("updatefromsandbox", jsEvent => {
|
|
1454
|
+
const actions = {
|
|
1455
|
+
value(event) {
|
|
1456
|
+
event.target.checked = event.detail.value !== "Off";
|
|
1457
|
+
storage.setValue(id, { value: event.target.checked });
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
this._dispatchEventFromSandbox(actions, jsEvent);
|
|
1461
|
+
});
|
|
1462
|
+
this._setEventListeners(element, null, [
|
|
1463
|
+
["change", "Validate"],
|
|
1464
|
+
["change", "Action"],
|
|
1465
|
+
["focus", "Focus"],
|
|
1466
|
+
["blur", "Blur"],
|
|
1467
|
+
["mousedown", "Mouse Down"],
|
|
1468
|
+
["mouseenter", "Mouse Enter"],
|
|
1469
|
+
["mouseleave", "Mouse Exit"],
|
|
1470
|
+
["mouseup", "Mouse Up"]
|
|
1471
|
+
], event => event.target.checked);
|
|
1472
|
+
}
|
|
1473
|
+
this._setBackgroundColor(element);
|
|
1474
|
+
this._setDefaultPropertiesFromJS(element);
|
|
1475
|
+
this.container.append(element);
|
|
1476
|
+
return this.container;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1462
1479
|
class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
1463
1480
|
constructor(parameters) {
|
|
1464
1481
|
super(parameters, { isRenderable: parameters.renderForms });
|
|
1465
1482
|
}
|
|
1466
1483
|
render() {
|
|
1467
|
-
this.container.classList.add("buttonWidgetAnnotation", "radioButton");
|
|
1484
|
+
//this.container.classList.add("buttonWidgetAnnotation", "radioButton");
|
|
1485
|
+
this.container.classList.add("k-button-widget-annotation", "k-radio-button-widget-annotation");
|
|
1468
1486
|
const storage = this.annotationStorage;
|
|
1469
1487
|
const data = this.data;
|
|
1470
1488
|
const id = data.id;
|
|
@@ -1548,253 +1566,250 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
|
1548
1566
|
return this.container;
|
|
1549
1567
|
}
|
|
1550
1568
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
//
|
|
1557
|
-
//
|
|
1558
|
-
//
|
|
1559
|
-
|
|
1560
|
-
//
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
//
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
//
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
//
|
|
1787
|
-
//
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
// return this.container;
|
|
1796
|
-
// }
|
|
1797
|
-
// }
|
|
1569
|
+
class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
|
1570
|
+
constructor(parameters) {
|
|
1571
|
+
super(parameters, { ignoreBorder: parameters.data.hasAppearance });
|
|
1572
|
+
}
|
|
1573
|
+
render() {
|
|
1574
|
+
// The rendering and functionality of a push button widget annotation is
|
|
1575
|
+
// equal to that of a link annotation, but may have more functionality, such
|
|
1576
|
+
// as performing actions on form fields (resetting, submitting, et cetera).
|
|
1577
|
+
const container = super.render();
|
|
1578
|
+
//container.classList.add("buttonWidgetAnnotation", "pushButton");
|
|
1579
|
+
this.container.classList.add("k-button-widget-annotation", "k-push-button-widget-annotation");
|
|
1580
|
+
const linkElement = container.lastChild;
|
|
1581
|
+
if (this.enableScripting && this.hasJSActions && linkElement) {
|
|
1582
|
+
this._setDefaultPropertiesFromJS(linkElement);
|
|
1583
|
+
linkElement.addEventListener("updatefromsandbox", jsEvent => {
|
|
1584
|
+
this._dispatchEventFromSandbox({}, jsEvent);
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
return container;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|
1591
|
+
constructor(parameters) {
|
|
1592
|
+
super(parameters, { isRenderable: parameters.renderForms });
|
|
1593
|
+
}
|
|
1594
|
+
render() {
|
|
1595
|
+
this.container.classList.add("choiceWidgetAnnotation");
|
|
1596
|
+
const storage = this.annotationStorage;
|
|
1597
|
+
const id = this.data.id;
|
|
1598
|
+
const storedData = storage.getValue(id, {
|
|
1599
|
+
value: this.data.fieldValue
|
|
1600
|
+
});
|
|
1601
|
+
const selectElement = document.createElement("select");
|
|
1602
|
+
GetElementsByNameSet.add(selectElement);
|
|
1603
|
+
selectElement.setAttribute("data-element-id", id);
|
|
1604
|
+
selectElement.disabled = this.data.readOnly;
|
|
1605
|
+
this._setRequired(selectElement, this.data.required);
|
|
1606
|
+
selectElement.name = this.data.fieldName;
|
|
1607
|
+
selectElement.tabIndex = DEFAULT_TAB_INDEX;
|
|
1608
|
+
let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
|
|
1609
|
+
if (!this.data.combo) {
|
|
1610
|
+
// List boxes have a size and (optionally) multiple selection.
|
|
1611
|
+
selectElement.size = this.data.options.length;
|
|
1612
|
+
if (this.data.multiSelect) {
|
|
1613
|
+
selectElement.multiple = true;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
selectElement.addEventListener("resetform", () => {
|
|
1617
|
+
const defaultValue = this.data.defaultFieldValue;
|
|
1618
|
+
for (const option of selectElement.options) {
|
|
1619
|
+
option.selected = option.value === defaultValue;
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
// Insert the options into the choice field.
|
|
1623
|
+
for (const option of this.data.options) {
|
|
1624
|
+
const optionElement = document.createElement("option");
|
|
1625
|
+
optionElement.textContent = option.displayValue;
|
|
1626
|
+
optionElement.value = option.exportValue;
|
|
1627
|
+
if (storedData.value.includes(option.exportValue)) {
|
|
1628
|
+
optionElement.setAttribute("selected", (true).toString());
|
|
1629
|
+
addAnEmptyEntry = false;
|
|
1630
|
+
}
|
|
1631
|
+
selectElement.append(optionElement);
|
|
1632
|
+
}
|
|
1633
|
+
let removeEmptyEntry = null;
|
|
1634
|
+
if (addAnEmptyEntry) {
|
|
1635
|
+
const noneOptionElement = document.createElement("option");
|
|
1636
|
+
noneOptionElement.value = " ";
|
|
1637
|
+
noneOptionElement.setAttribute("hidden", (true).toString());
|
|
1638
|
+
noneOptionElement.setAttribute("selected", (true).toString());
|
|
1639
|
+
selectElement.prepend(noneOptionElement);
|
|
1640
|
+
removeEmptyEntry = () => {
|
|
1641
|
+
noneOptionElement.remove();
|
|
1642
|
+
selectElement.removeEventListener("input", removeEmptyEntry);
|
|
1643
|
+
removeEmptyEntry = null;
|
|
1644
|
+
};
|
|
1645
|
+
selectElement.addEventListener("input", removeEmptyEntry);
|
|
1646
|
+
}
|
|
1647
|
+
const getValue = isExport => {
|
|
1648
|
+
const name = isExport ? "value" : "textContent";
|
|
1649
|
+
const { options, multiple } = selectElement;
|
|
1650
|
+
if (!multiple) {
|
|
1651
|
+
return options.selectedIndex === -1
|
|
1652
|
+
? null
|
|
1653
|
+
: options[options.selectedIndex][name];
|
|
1654
|
+
}
|
|
1655
|
+
return Array.prototype.filter
|
|
1656
|
+
.call(options, option => option.selected)
|
|
1657
|
+
.map(option => option[name]);
|
|
1658
|
+
};
|
|
1659
|
+
let selectedValues = getValue(/* isExport */ false);
|
|
1660
|
+
const getItems = event => {
|
|
1661
|
+
const options = event.target.options;
|
|
1662
|
+
return Array.prototype.map.call(options, option => ({
|
|
1663
|
+
displayValue: option.textContent,
|
|
1664
|
+
exportValue: option.value
|
|
1665
|
+
}));
|
|
1666
|
+
};
|
|
1667
|
+
if (this.enableScripting && this.hasJSActions) {
|
|
1668
|
+
selectElement.addEventListener("updatefromsandbox", jsEvent => {
|
|
1669
|
+
const actions = {
|
|
1670
|
+
value(event) {
|
|
1671
|
+
removeEmptyEntry === null || removeEmptyEntry === void 0 ? void 0 : removeEmptyEntry();
|
|
1672
|
+
const value = event.detail.value;
|
|
1673
|
+
const values = new Set(Array.isArray(value) ? value : [value]);
|
|
1674
|
+
for (const option of selectElement.options) {
|
|
1675
|
+
option.selected = values.has(option.value);
|
|
1676
|
+
}
|
|
1677
|
+
storage.setValue(id, {
|
|
1678
|
+
value: getValue(/* isExport */ true)
|
|
1679
|
+
});
|
|
1680
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1681
|
+
},
|
|
1682
|
+
multipleSelection() {
|
|
1683
|
+
selectElement.multiple = true;
|
|
1684
|
+
},
|
|
1685
|
+
remove(event) {
|
|
1686
|
+
const options = selectElement.options;
|
|
1687
|
+
const index = event.detail.remove;
|
|
1688
|
+
options[index].selected = false;
|
|
1689
|
+
selectElement.remove(index);
|
|
1690
|
+
if (options.length > 0) {
|
|
1691
|
+
const i = Array.prototype.findIndex.call(options, option => option.selected);
|
|
1692
|
+
if (i === -1) {
|
|
1693
|
+
options[0].selected = true;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
storage.setValue(id, {
|
|
1697
|
+
value: getValue(/* isExport */ true),
|
|
1698
|
+
items: getItems(event)
|
|
1699
|
+
});
|
|
1700
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1701
|
+
},
|
|
1702
|
+
clear() {
|
|
1703
|
+
while (selectElement.length !== 0) {
|
|
1704
|
+
selectElement.remove(0);
|
|
1705
|
+
}
|
|
1706
|
+
storage.setValue(id, { value: null, items: [] });
|
|
1707
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1708
|
+
},
|
|
1709
|
+
insert(event) {
|
|
1710
|
+
const { index, displayValue, exportValue } = event.detail.insert;
|
|
1711
|
+
const selectChild = selectElement.children[index];
|
|
1712
|
+
const optionElement = document.createElement("option");
|
|
1713
|
+
optionElement.textContent = displayValue;
|
|
1714
|
+
optionElement.value = exportValue;
|
|
1715
|
+
if (selectChild) {
|
|
1716
|
+
selectChild.before(optionElement);
|
|
1717
|
+
}
|
|
1718
|
+
else {
|
|
1719
|
+
selectElement.append(optionElement);
|
|
1720
|
+
}
|
|
1721
|
+
storage.setValue(id, {
|
|
1722
|
+
value: getValue(/* isExport */ true),
|
|
1723
|
+
items: getItems(event)
|
|
1724
|
+
});
|
|
1725
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1726
|
+
},
|
|
1727
|
+
items(event) {
|
|
1728
|
+
const { items } = event.detail;
|
|
1729
|
+
while (selectElement.length !== 0) {
|
|
1730
|
+
selectElement.remove(0);
|
|
1731
|
+
}
|
|
1732
|
+
for (const item of items) {
|
|
1733
|
+
const { displayValue, exportValue } = item;
|
|
1734
|
+
const optionElement = document.createElement("option");
|
|
1735
|
+
optionElement.textContent = displayValue;
|
|
1736
|
+
optionElement.value = exportValue;
|
|
1737
|
+
selectElement.append(optionElement);
|
|
1738
|
+
}
|
|
1739
|
+
if (selectElement.options.length > 0) {
|
|
1740
|
+
selectElement.options[0].selected = true;
|
|
1741
|
+
}
|
|
1742
|
+
storage.setValue(id, {
|
|
1743
|
+
value: getValue(/* isExport */ true),
|
|
1744
|
+
items: getItems(event)
|
|
1745
|
+
});
|
|
1746
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1747
|
+
},
|
|
1748
|
+
indices(event) {
|
|
1749
|
+
const indices = new Set(event.detail.indices);
|
|
1750
|
+
for (const option of event.target.options) {
|
|
1751
|
+
option.selected = indices.has(option.index);
|
|
1752
|
+
}
|
|
1753
|
+
storage.setValue(id, {
|
|
1754
|
+
value: getValue(/* isExport */ true)
|
|
1755
|
+
});
|
|
1756
|
+
selectedValues = getValue(/* isExport */ false);
|
|
1757
|
+
},
|
|
1758
|
+
editable(event) {
|
|
1759
|
+
event.target.disabled = !event.detail.editable;
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
this._dispatchEventFromSandbox(actions, jsEvent);
|
|
1763
|
+
});
|
|
1764
|
+
selectElement.addEventListener("input", event => {
|
|
1765
|
+
var _a;
|
|
1766
|
+
const exportValue = getValue(/* isExport */ true);
|
|
1767
|
+
const change = getValue(/* isExport */ false);
|
|
1768
|
+
storage.setValue(id, { value: exportValue });
|
|
1769
|
+
event.preventDefault();
|
|
1770
|
+
(_a = this.linkService.eventBus) === null || _a === void 0 ? void 0 : _a.dispatch("dispatcheventinsandbox", {
|
|
1771
|
+
source: this,
|
|
1772
|
+
detail: {
|
|
1773
|
+
id,
|
|
1774
|
+
name: "Keystroke",
|
|
1775
|
+
value: selectedValues,
|
|
1776
|
+
change,
|
|
1777
|
+
changeEx: exportValue,
|
|
1778
|
+
willCommit: false,
|
|
1779
|
+
commitKey: 1,
|
|
1780
|
+
keyDown: false
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
});
|
|
1784
|
+
this._setEventListeners(selectElement, null, [
|
|
1785
|
+
["focus", "Focus"],
|
|
1786
|
+
["blur", "Blur"],
|
|
1787
|
+
["mousedown", "Mouse Down"],
|
|
1788
|
+
["mouseenter", "Mouse Enter"],
|
|
1789
|
+
["mouseleave", "Mouse Exit"],
|
|
1790
|
+
["mouseup", "Mouse Up"],
|
|
1791
|
+
["input", "Action"],
|
|
1792
|
+
["input", "Validate"]
|
|
1793
|
+
], event => event.target.value);
|
|
1794
|
+
}
|
|
1795
|
+
else {
|
|
1796
|
+
selectElement.addEventListener("input", function () {
|
|
1797
|
+
storage.setValue(id, { value: getValue(/* isExport */ true) });
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
if (this.data.combo) {
|
|
1801
|
+
this._setTextStyle(selectElement);
|
|
1802
|
+
}
|
|
1803
|
+
else {
|
|
1804
|
+
// Just use the default font size...
|
|
1805
|
+
// it's a bit hard to guess what is a good size.
|
|
1806
|
+
}
|
|
1807
|
+
this._setBackgroundColor(selectElement);
|
|
1808
|
+
this._setDefaultPropertiesFromJS(selectElement);
|
|
1809
|
+
this.container.append(selectElement);
|
|
1810
|
+
return this.container;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1798
1813
|
class PopupAnnotationElement extends AnnotationElement {
|
|
1799
1814
|
// todo: props
|
|
1800
1815
|
constructor(parameters) {
|
|
@@ -2679,7 +2694,7 @@ class AnnotationLayer {
|
|
|
2679
2694
|
imageResourcesPath: params.imageResourcesPath || "",
|
|
2680
2695
|
renderForms: params.renderForms !== false,
|
|
2681
2696
|
svgFactory: new DOMSVGFactory(),
|
|
2682
|
-
annotationStorage: params.annotationStorage,
|
|
2697
|
+
annotationStorage: params.annotationStorage || new AnnotationStorage(),
|
|
2683
2698
|
enableScripting: params.enableScripting === true,
|
|
2684
2699
|
hasJSActions: params.hasJSActions,
|
|
2685
2700
|
fieldObjects: params.fieldObjects,
|
|
@@ -2751,6 +2766,12 @@ class AnnotationLayer {
|
|
|
2751
2766
|
getEditableAnnotation(id) {
|
|
2752
2767
|
return __classPrivateFieldGet(this, _AnnotationLayer_editableAnnotations, "f").get(id);
|
|
2753
2768
|
}
|
|
2769
|
+
destroy() {
|
|
2770
|
+
var _a, _b;
|
|
2771
|
+
(_a = __classPrivateFieldGet(this, _AnnotationLayer_annotationCanvasMap, "f")) === null || _a === void 0 ? void 0 : _a.clear();
|
|
2772
|
+
(_b = this.div) === null || _b === void 0 ? void 0 : _b.remove();
|
|
2773
|
+
this.div = null;
|
|
2774
|
+
}
|
|
2754
2775
|
}
|
|
2755
2776
|
_AnnotationLayer_accessibilityManager = new WeakMap(), _AnnotationLayer_annotationCanvasMap = new WeakMap(), _AnnotationLayer_editableAnnotations = new WeakMap(), _AnnotationLayer_instances = new WeakSet(), _AnnotationLayer_appendElement = function _AnnotationLayer_appendElement(element, id) {
|
|
2756
2777
|
var _a;
|