@chialab/pdfjs-lib 1.0.0-alpha.15 → 1.0.0-alpha.16
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/browser/{chunk-TKDBOXH4.js → chunk-O4CM6PII.js} +89 -1
- package/dist/browser/index.js +410 -193
- package/dist/browser/worker.js +283 -12
- package/dist/lib/SvgCanvasContext.d.ts +20 -5
- package/dist/node/{chunk-MAMMG4XK.js → chunk-4FQTXXTH.js} +89 -1
- package/dist/node/index.js +410 -193
- package/dist/node/worker.js +283 -12
- package/dist/pdf.js/src/display/annotation_layer.d.ts +1 -2
- package/dist/pdf.js/src/display/editor/editor.d.ts +11 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +2 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +2 -0
- package/dist/pdf.js/src/display/editor/stamp.d.ts +2 -0
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +2 -0
- package/dist/pdf.js/src/display/editor/tools.d.ts +5 -2
- package/dist/pdf.js/src/shared/scripting_utils.d.ts +2 -0
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
AnnotationPrefix,
|
|
9
9
|
AnnotationType,
|
|
10
10
|
BaseException,
|
|
11
|
+
ColorConverters,
|
|
11
12
|
DrawOPS,
|
|
12
13
|
FONT_IDENTITY_MATRIX,
|
|
13
14
|
FeatureTest,
|
|
@@ -45,7 +46,7 @@ import {
|
|
|
45
46
|
updateUrlHash,
|
|
46
47
|
warn,
|
|
47
48
|
wrapReason
|
|
48
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-O4CM6PII.js";
|
|
49
50
|
import {
|
|
50
51
|
__privateAdd,
|
|
51
52
|
__privateGet,
|
|
@@ -301,22 +302,71 @@ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
|
|
|
301
302
|
warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
|
|
302
303
|
return defaultFilename;
|
|
303
304
|
}
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
if (suggestedFilename) {
|
|
309
|
-
suggestedFilename = suggestedFilename[0];
|
|
310
|
-
if (suggestedFilename.includes("%")) {
|
|
305
|
+
const getURL = (urlString) => {
|
|
306
|
+
try {
|
|
307
|
+
return new URL(urlString);
|
|
308
|
+
} catch {
|
|
311
309
|
try {
|
|
312
|
-
|
|
313
|
-
decodeURIComponent(suggestedFilename)
|
|
314
|
-
)[0];
|
|
310
|
+
return new URL(decodeURIComponent(urlString));
|
|
315
311
|
} catch {
|
|
312
|
+
try {
|
|
313
|
+
return new URL(urlString, "https://foo.bar");
|
|
314
|
+
} catch {
|
|
315
|
+
try {
|
|
316
|
+
return new URL(decodeURIComponent(urlString), "https://foo.bar");
|
|
317
|
+
} catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
316
321
|
}
|
|
317
322
|
}
|
|
323
|
+
};
|
|
324
|
+
const newURL = getURL(url);
|
|
325
|
+
if (!newURL) {
|
|
326
|
+
return defaultFilename;
|
|
327
|
+
}
|
|
328
|
+
const decode = (name) => {
|
|
329
|
+
try {
|
|
330
|
+
let decoded = decodeURIComponent(name);
|
|
331
|
+
if (decoded.includes("/")) {
|
|
332
|
+
decoded = decoded.split("/").at(-1);
|
|
333
|
+
if (decoded.test(/^\.pdf$/i)) {
|
|
334
|
+
return decoded;
|
|
335
|
+
}
|
|
336
|
+
return name;
|
|
337
|
+
}
|
|
338
|
+
return decoded;
|
|
339
|
+
} catch {
|
|
340
|
+
return name;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const pdfRegex = /\.pdf$/i;
|
|
344
|
+
const filename = newURL.pathname.split("/").at(-1);
|
|
345
|
+
if (pdfRegex.test(filename)) {
|
|
346
|
+
return decode(filename);
|
|
347
|
+
}
|
|
348
|
+
if (newURL.searchParams.size > 0) {
|
|
349
|
+
const values = Array.from(newURL.searchParams.values()).reverse();
|
|
350
|
+
for (const value of values) {
|
|
351
|
+
if (pdfRegex.test(value)) {
|
|
352
|
+
return decode(value);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const keys = Array.from(newURL.searchParams.keys()).reverse();
|
|
356
|
+
for (const key of keys) {
|
|
357
|
+
if (pdfRegex.test(key)) {
|
|
358
|
+
return decode(key);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (newURL.hash) {
|
|
363
|
+
const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
|
364
|
+
const hashFilename = reFilename.exec(newURL.hash);
|
|
365
|
+
if (hashFilename) {
|
|
366
|
+
return decode(hashFilename[0]);
|
|
367
|
+
}
|
|
318
368
|
}
|
|
319
|
-
return
|
|
369
|
+
return defaultFilename;
|
|
320
370
|
}
|
|
321
371
|
var StatTimer = class {
|
|
322
372
|
constructor() {
|
|
@@ -570,7 +620,7 @@ var SupportedImageMimeTypes = [
|
|
|
570
620
|
];
|
|
571
621
|
|
|
572
622
|
// src/pdf.js/src/display/editor/toolbar.js
|
|
573
|
-
var _toolbar, _colorPicker, _editor, _buttons, _altText, _signatureDescriptionButton, _l10nRemove, _EditorToolbar_static, pointerDown_fn, _EditorToolbar_instances, focusIn_fn, focusOut_fn, addListenersToElement_fn,
|
|
623
|
+
var _toolbar, _colorPicker, _editor, _buttons, _altText, _signatureDescriptionButton, _l10nRemove, _EditorToolbar_static, pointerDown_fn, _EditorToolbar_instances, focusIn_fn, focusOut_fn, addListenersToElement_fn, divider_get;
|
|
574
624
|
var _EditorToolbar = class _EditorToolbar {
|
|
575
625
|
constructor(editor) {
|
|
576
626
|
__privateAdd(this, _EditorToolbar_instances);
|
|
@@ -608,7 +658,6 @@ var _EditorToolbar = class _EditorToolbar {
|
|
|
608
658
|
style.insetInlineEnd = `${100 * x}%`;
|
|
609
659
|
style.top = `calc(${100 * position[1]}% + var(--editor-toolbar-vert-offset))`;
|
|
610
660
|
}
|
|
611
|
-
__privateMethod(this, _EditorToolbar_instances, addDeleteButton_fn).call(this);
|
|
612
661
|
return editToolbar;
|
|
613
662
|
}
|
|
614
663
|
get div() {
|
|
@@ -622,22 +671,54 @@ var _EditorToolbar = class _EditorToolbar {
|
|
|
622
671
|
__privateGet(this, _toolbar).classList.remove("hidden");
|
|
623
672
|
__privateGet(this, _altText)?.shown();
|
|
624
673
|
}
|
|
674
|
+
addDeleteButton() {
|
|
675
|
+
const { editorType, _uiManager: _uiManager4 } = __privateGet(this, _editor);
|
|
676
|
+
const button = document.createElement("button");
|
|
677
|
+
button.className = "delete";
|
|
678
|
+
button.tabIndex = 0;
|
|
679
|
+
button.setAttribute("data-l10n-id", __privateGet(_EditorToolbar, _l10nRemove)[editorType]);
|
|
680
|
+
__privateMethod(this, _EditorToolbar_instances, addListenersToElement_fn).call(this, button);
|
|
681
|
+
button.addEventListener(
|
|
682
|
+
"click",
|
|
683
|
+
(e) => {
|
|
684
|
+
_uiManager4.delete();
|
|
685
|
+
},
|
|
686
|
+
{ signal: _uiManager4._signal }
|
|
687
|
+
);
|
|
688
|
+
__privateGet(this, _buttons).append(button);
|
|
689
|
+
}
|
|
625
690
|
async addAltText(altText) {
|
|
626
691
|
const button = await altText.render();
|
|
627
692
|
__privateMethod(this, _EditorToolbar_instances, addListenersToElement_fn).call(this, button);
|
|
628
|
-
__privateGet(this, _buttons).
|
|
693
|
+
__privateGet(this, _buttons).append(button, __privateGet(this, _EditorToolbar_instances, divider_get));
|
|
629
694
|
__privateSet(this, _altText, altText);
|
|
630
695
|
}
|
|
631
696
|
addColorPicker(colorPicker) {
|
|
632
697
|
__privateSet(this, _colorPicker, colorPicker);
|
|
633
698
|
const button = colorPicker.renderButton();
|
|
634
699
|
__privateMethod(this, _EditorToolbar_instances, addListenersToElement_fn).call(this, button);
|
|
635
|
-
__privateGet(this, _buttons).
|
|
700
|
+
__privateGet(this, _buttons).append(button, __privateGet(this, _EditorToolbar_instances, divider_get));
|
|
636
701
|
}
|
|
637
702
|
async addEditSignatureButton(signatureManager) {
|
|
638
703
|
const button = __privateSet(this, _signatureDescriptionButton, await signatureManager.renderEditButton(__privateGet(this, _editor)));
|
|
639
704
|
__privateMethod(this, _EditorToolbar_instances, addListenersToElement_fn).call(this, button);
|
|
640
|
-
__privateGet(this, _buttons).
|
|
705
|
+
__privateGet(this, _buttons).append(button, __privateGet(this, _EditorToolbar_instances, divider_get));
|
|
706
|
+
}
|
|
707
|
+
async addButton(name, tool) {
|
|
708
|
+
switch (name) {
|
|
709
|
+
case "colorPicker":
|
|
710
|
+
this.addColorPicker(tool);
|
|
711
|
+
break;
|
|
712
|
+
case "altText":
|
|
713
|
+
await this.addAltText(tool);
|
|
714
|
+
break;
|
|
715
|
+
case "editSignature":
|
|
716
|
+
await this.addEditSignatureButton(tool);
|
|
717
|
+
break;
|
|
718
|
+
case "delete":
|
|
719
|
+
this.addDeleteButton();
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
641
722
|
}
|
|
642
723
|
updateEditSignatureButton(description) {
|
|
643
724
|
if (__privateGet(this, _signatureDescriptionButton)) {
|
|
@@ -682,22 +763,6 @@ addListenersToElement_fn = function(element) {
|
|
|
682
763
|
});
|
|
683
764
|
element.addEventListener("contextmenu", noContextMenu, { signal });
|
|
684
765
|
};
|
|
685
|
-
addDeleteButton_fn = function() {
|
|
686
|
-
const { editorType, _uiManager: _uiManager4 } = __privateGet(this, _editor);
|
|
687
|
-
const button = document.createElement("button");
|
|
688
|
-
button.className = "delete";
|
|
689
|
-
button.tabIndex = 0;
|
|
690
|
-
button.setAttribute("data-l10n-id", __privateGet(_EditorToolbar, _l10nRemove)[editorType]);
|
|
691
|
-
__privateMethod(this, _EditorToolbar_instances, addListenersToElement_fn).call(this, button);
|
|
692
|
-
button.addEventListener(
|
|
693
|
-
"click",
|
|
694
|
-
(e) => {
|
|
695
|
-
_uiManager4.delete();
|
|
696
|
-
},
|
|
697
|
-
{ signal: _uiManager4._signal }
|
|
698
|
-
);
|
|
699
|
-
__privateGet(this, _buttons).append(button);
|
|
700
|
-
};
|
|
701
766
|
divider_get = function() {
|
|
702
767
|
const divider = document.createElement("div");
|
|
703
768
|
divider.className = "divider";
|
|
@@ -1242,9 +1307,9 @@ __publicField(_ColorManager, "_colorsMapping", /* @__PURE__ */ new Map([
|
|
|
1242
1307
|
["Canvas", [255, 255, 255]]
|
|
1243
1308
|
]));
|
|
1244
1309
|
var ColorManager = _ColorManager;
|
|
1245
|
-
var _abortController, _activeEditor, _allEditors, _allLayers, _altTextManager, _annotationStorage, _changedExistingAnnotations, _commandManager, _copyPasteAC, _currentDrawingSession, _currentPageIndex, _deletedAnnotationsElementIds, _draggingEditors, _editorTypes, _editorsToRescale, _enableHighlightFloatingButton, _enableUpdatedAddImage, _enableNewAltTextWhenAddingImage, _filterFactory, _focusMainContainerTimeoutId, _focusManagerAC, _highlightColors, _highlightWhenShiftUp, _highlightToolbar, _idManager, _isEnabled, _isWaiting, _keyboardManagerAC, _lastActiveElement, _mainHighlightColorPicker, _missingCanvases, _mlManager, _mode, _selectedEditors, _selectedTextNode, _signatureManager, _pageColors, _showAllStates, _previousStates, _translation, _translationTimeoutId, _container, _viewer, _updateModeCapability, _AnnotationEditorUIManager_instances, getAnchorElementForSelection_fn, getLayerForTextLayer_fn, displayHighlightToolbar_fn, selectionChange_fn, onSelectEnd_fn, addSelectionListener_fn, addFocusManager_fn, removeFocusManager_fn, addKeyboardManager_fn, removeKeyboardManager_fn, addCopyPasteListeners_fn, removeCopyPasteListeners_fn, addDragAndDropListeners_fn, dispatchUpdateStates_fn, dispatchUpdateUI_fn, enableAll_fn, disableAll_fn, addEditorToLayer_fn, lastSelectedEditor_get, isEmpty_fn, selectEditors_fn;
|
|
1310
|
+
var _abortController, _activeEditor, _allEditors, _allLayers, _altTextManager, _annotationStorage, _changedExistingAnnotations, _commandManager, _copyPasteAC, _currentDrawingSession, _currentPageIndex, _deletedAnnotationsElementIds, _draggingEditors, _editorTypes, _editorsToRescale, _enableHighlightFloatingButton, _enableUpdatedAddImage, _enableNewAltTextWhenAddingImage, _filterFactory, _focusMainContainerTimeoutId, _focusManagerAC, _highlightColors, _highlightWhenShiftUp, _highlightToolbar, _idManager, _isEnabled, _isWaiting, _keyboardManagerAC, _lastActiveElement, _mainHighlightColorPicker, _missingCanvases, _mlManager, _mode, _selectedEditors, _selectedTextNode, _signatureManager, _pageColors, _showAllStates, _previousStates, _translation, _translationTimeoutId, _container, _viewer, _viewerAlert, _updateModeCapability, _AnnotationEditorUIManager_instances, getAnchorElementForSelection_fn, getLayerForTextLayer_fn, displayHighlightToolbar_fn, selectionChange_fn, onSelectEnd_fn, addSelectionListener_fn, addFocusManager_fn, removeFocusManager_fn, addKeyboardManager_fn, removeKeyboardManager_fn, addCopyPasteListeners_fn, removeCopyPasteListeners_fn, addDragAndDropListeners_fn, dispatchUpdateStates_fn, dispatchUpdateUI_fn, enableAll_fn, disableAll_fn, addEditorToLayer_fn, lastSelectedEditor_get, isEmpty_fn, selectEditors_fn;
|
|
1246
1311
|
var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
1247
|
-
constructor(container, viewer, altTextManager, signatureManager, eventBus, pdfDocument, pageColors, highlightColors, enableHighlightFloatingButton, enableUpdatedAddImage, enableNewAltTextWhenAddingImage, mlManager, editorUndoBar, supportsPinchToZoom) {
|
|
1312
|
+
constructor(container, viewer, viewerAlert, altTextManager, signatureManager, eventBus, pdfDocument, pageColors, highlightColors, enableHighlightFloatingButton, enableUpdatedAddImage, enableNewAltTextWhenAddingImage, mlManager, editorUndoBar, supportsPinchToZoom) {
|
|
1248
1313
|
__privateAdd(this, _AnnotationEditorUIManager_instances);
|
|
1249
1314
|
__privateAdd(this, _abortController, new AbortController());
|
|
1250
1315
|
__privateAdd(this, _activeEditor, null);
|
|
@@ -1297,10 +1362,12 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1297
1362
|
__privateAdd(this, _translationTimeoutId, null);
|
|
1298
1363
|
__privateAdd(this, _container, null);
|
|
1299
1364
|
__privateAdd(this, _viewer, null);
|
|
1365
|
+
__privateAdd(this, _viewerAlert, null);
|
|
1300
1366
|
__privateAdd(this, _updateModeCapability, null);
|
|
1301
1367
|
const signal = this._signal = __privateGet(this, _abortController).signal;
|
|
1302
1368
|
__privateSet(this, _container, container);
|
|
1303
1369
|
__privateSet(this, _viewer, viewer);
|
|
1370
|
+
__privateSet(this, _viewerAlert, viewerAlert);
|
|
1304
1371
|
__privateSet(this, _altTextManager, altTextManager);
|
|
1305
1372
|
__privateSet(this, _signatureManager, signatureManager);
|
|
1306
1373
|
this._eventBus = eventBus;
|
|
@@ -1527,7 +1594,11 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1527
1594
|
this,
|
|
1528
1595
|
"highlightColors",
|
|
1529
1596
|
__privateGet(this, _highlightColors) ? new Map(
|
|
1530
|
-
__privateGet(this, _highlightColors).split(",").map((pair) =>
|
|
1597
|
+
__privateGet(this, _highlightColors).split(",").map((pair) => {
|
|
1598
|
+
pair = pair.split("=").map((x) => x.trim());
|
|
1599
|
+
pair[1] = pair[1].toUpperCase();
|
|
1600
|
+
return pair;
|
|
1601
|
+
})
|
|
1531
1602
|
) : null
|
|
1532
1603
|
);
|
|
1533
1604
|
}
|
|
@@ -1678,6 +1749,18 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1678
1749
|
__privateGet(this, _annotationStorage).setValue(editor.id, editor);
|
|
1679
1750
|
}
|
|
1680
1751
|
}
|
|
1752
|
+
a11yAlert(messageId, args = null) {
|
|
1753
|
+
const viewerAlert = __privateGet(this, _viewerAlert);
|
|
1754
|
+
if (!viewerAlert) {
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
viewerAlert.setAttribute("data-l10n-id", messageId);
|
|
1758
|
+
if (args) {
|
|
1759
|
+
viewerAlert.setAttribute("data-l10n-args", JSON.stringify(args));
|
|
1760
|
+
} else {
|
|
1761
|
+
viewerAlert.removeAttribute("data-l10n-args");
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1681
1764
|
blur() {
|
|
1682
1765
|
this.isShiftKeyDown = false;
|
|
1683
1766
|
if (__privateGet(this, _highlightWhenShiftUp)) {
|
|
@@ -1952,8 +2035,10 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1952
2035
|
* @param {string|null} editId
|
|
1953
2036
|
* @param {boolean} [isFromKeyboard] - true if the mode change is due to a
|
|
1954
2037
|
* keyboard action.
|
|
2038
|
+
* @param {boolean} [mustEnterInEditMode] - true if the editor must enter in
|
|
2039
|
+
* edit mode.
|
|
1955
2040
|
*/
|
|
1956
|
-
async updateMode(mode, editId = null, isFromKeyboard = false) {
|
|
2041
|
+
async updateMode(mode, editId = null, isFromKeyboard = false, mustEnterInEditMode = false) {
|
|
1957
2042
|
if (__privateGet(this, _mode) === mode) {
|
|
1958
2043
|
return;
|
|
1959
2044
|
}
|
|
@@ -1992,7 +2077,9 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
1992
2077
|
for (const editor of __privateGet(this, _allEditors).values()) {
|
|
1993
2078
|
if (editor.annotationElementId === editId || editor.id === editId) {
|
|
1994
2079
|
this.setSelected(editor);
|
|
1995
|
-
|
|
2080
|
+
if (mustEnterInEditMode) {
|
|
2081
|
+
editor.enterInEditMode();
|
|
2082
|
+
}
|
|
1996
2083
|
} else {
|
|
1997
2084
|
editor.unselect();
|
|
1998
2085
|
}
|
|
@@ -2212,6 +2299,10 @@ var _AnnotationEditorUIManager = class _AnnotationEditorUIManager {
|
|
|
2212
2299
|
* @param {AnnotationEditor} editor
|
|
2213
2300
|
*/
|
|
2214
2301
|
setSelected(editor) {
|
|
2302
|
+
this.updateToolbar({
|
|
2303
|
+
mode: editor.mode,
|
|
2304
|
+
editId: editor.id
|
|
2305
|
+
});
|
|
2215
2306
|
__privateGet(this, _currentDrawingSession)?.commitOrRemove();
|
|
2216
2307
|
for (const ed of __privateGet(this, _selectedEditors)) {
|
|
2217
2308
|
if (ed !== editor) {
|
|
@@ -2675,6 +2766,7 @@ _translation = new WeakMap();
|
|
|
2675
2766
|
_translationTimeoutId = new WeakMap();
|
|
2676
2767
|
_container = new WeakMap();
|
|
2677
2768
|
_viewer = new WeakMap();
|
|
2769
|
+
_viewerAlert = new WeakMap();
|
|
2678
2770
|
_updateModeCapability = new WeakMap();
|
|
2679
2771
|
_AnnotationEditorUIManager_instances = new WeakSet();
|
|
2680
2772
|
getAnchorElementForSelection_fn = function({ anchorNode }) {
|
|
@@ -3474,6 +3566,7 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3474
3566
|
this._willKeepAspectRatio = false;
|
|
3475
3567
|
this._initialOptions.isCentered = parameters.isCentered;
|
|
3476
3568
|
this._structTreeParentId = null;
|
|
3569
|
+
this.annotationElementId = parameters.annotationElementId || null;
|
|
3477
3570
|
const {
|
|
3478
3571
|
rotation,
|
|
3479
3572
|
rawDims: { pageWidth, pageHeight, pageX, pageY }
|
|
@@ -3522,6 +3615,9 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3522
3615
|
get editorType() {
|
|
3523
3616
|
return Object.getPrototypeOf(this).constructor._type;
|
|
3524
3617
|
}
|
|
3618
|
+
get mode() {
|
|
3619
|
+
return Object.getPrototypeOf(this).constructor._editorType;
|
|
3620
|
+
}
|
|
3525
3621
|
static get isDrawer() {
|
|
3526
3622
|
return false;
|
|
3527
3623
|
}
|
|
@@ -3713,6 +3809,9 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3713
3809
|
* Commit the data contained in this editor.
|
|
3714
3810
|
*/
|
|
3715
3811
|
commit() {
|
|
3812
|
+
if (!this.isInEditMode()) {
|
|
3813
|
+
return;
|
|
3814
|
+
}
|
|
3716
3815
|
this.addToAnnotationStorage();
|
|
3717
3816
|
}
|
|
3718
3817
|
addToAnnotationStorage() {
|
|
@@ -3968,6 +4067,13 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3968
4067
|
altTextFinish() {
|
|
3969
4068
|
__privateGet(this, _altText3)?.finish();
|
|
3970
4069
|
}
|
|
4070
|
+
/**
|
|
4071
|
+
* Get the toolbar buttons for this editor.
|
|
4072
|
+
* @returns {Array<Array<string|object>>|null}
|
|
4073
|
+
*/
|
|
4074
|
+
get toolbarButtons() {
|
|
4075
|
+
return null;
|
|
4076
|
+
}
|
|
3971
4077
|
/**
|
|
3972
4078
|
* Add a toolbar for this editor.
|
|
3973
4079
|
* @returns {Promise<EditorToolbar|null>}
|
|
@@ -3978,9 +4084,13 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3978
4084
|
}
|
|
3979
4085
|
this._editToolbar = new EditorToolbar(this);
|
|
3980
4086
|
this.div.append(this._editToolbar.render());
|
|
3981
|
-
|
|
3982
|
-
|
|
4087
|
+
const { toolbarButtons } = this;
|
|
4088
|
+
if (toolbarButtons) {
|
|
4089
|
+
for (const [name, tool] of toolbarButtons) {
|
|
4090
|
+
await this._editToolbar.addButton(name, tool);
|
|
4091
|
+
}
|
|
3983
4092
|
}
|
|
4093
|
+
this._editToolbar.addButton("delete");
|
|
3984
4094
|
return this._editToolbar;
|
|
3985
4095
|
}
|
|
3986
4096
|
removeEditToolbar() {
|
|
@@ -4002,17 +4112,20 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4002
4112
|
getClientDimensions() {
|
|
4003
4113
|
return this.div.getBoundingClientRect();
|
|
4004
4114
|
}
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4115
|
+
/**
|
|
4116
|
+
* Create the alt text for this editor.
|
|
4117
|
+
* @returns {object}
|
|
4118
|
+
*/
|
|
4119
|
+
createAltText() {
|
|
4120
|
+
if (!__privateGet(this, _altText3)) {
|
|
4121
|
+
AltText.initialize(_AnnotationEditor._l10n);
|
|
4122
|
+
__privateSet(this, _altText3, new AltText(this));
|
|
4123
|
+
if (__privateGet(this, _accessibilityData)) {
|
|
4124
|
+
__privateGet(this, _altText3).data = __privateGet(this, _accessibilityData);
|
|
4125
|
+
__privateSet(this, _accessibilityData, null);
|
|
4126
|
+
}
|
|
4014
4127
|
}
|
|
4015
|
-
|
|
4128
|
+
return __privateGet(this, _altText3);
|
|
4016
4129
|
}
|
|
4017
4130
|
get altTextData() {
|
|
4018
4131
|
return __privateGet(this, _altText3)?.data;
|
|
@@ -4314,7 +4427,8 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4314
4427
|
const editor = new this.prototype.constructor({
|
|
4315
4428
|
parent,
|
|
4316
4429
|
id: parent.getNextId(),
|
|
4317
|
-
uiManager
|
|
4430
|
+
uiManager,
|
|
4431
|
+
annotationElementId: data.annotationElementId
|
|
4318
4432
|
});
|
|
4319
4433
|
editor.rotation = data.rotation;
|
|
4320
4434
|
__privateSet(editor, _accessibilityData, data.accessibilityData);
|
|
@@ -13904,74 +14018,6 @@ var InternalRenderTask = _InternalRenderTask;
|
|
|
13904
14018
|
var version = false ? null : null;
|
|
13905
14019
|
var build = false ? null : null;
|
|
13906
14020
|
|
|
13907
|
-
// src/pdf.js/src/shared/scripting_utils.js
|
|
13908
|
-
function makeColorComp(n) {
|
|
13909
|
-
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
13910
|
-
}
|
|
13911
|
-
function scaleAndClamp(x) {
|
|
13912
|
-
return Math.max(0, Math.min(255, 255 * x));
|
|
13913
|
-
}
|
|
13914
|
-
var ColorConverters = class {
|
|
13915
|
-
static CMYK_G([c, y, m, k]) {
|
|
13916
|
-
return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
|
|
13917
|
-
}
|
|
13918
|
-
static G_CMYK([g]) {
|
|
13919
|
-
return ["CMYK", 0, 0, 0, 1 - g];
|
|
13920
|
-
}
|
|
13921
|
-
static G_RGB([g]) {
|
|
13922
|
-
return ["RGB", g, g, g];
|
|
13923
|
-
}
|
|
13924
|
-
static G_rgb([g]) {
|
|
13925
|
-
g = scaleAndClamp(g);
|
|
13926
|
-
return [g, g, g];
|
|
13927
|
-
}
|
|
13928
|
-
static G_HTML([g]) {
|
|
13929
|
-
const G = makeColorComp(g);
|
|
13930
|
-
return `#${G}${G}${G}`;
|
|
13931
|
-
}
|
|
13932
|
-
static RGB_G([r, g, b]) {
|
|
13933
|
-
return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
|
|
13934
|
-
}
|
|
13935
|
-
static RGB_rgb(color) {
|
|
13936
|
-
return color.map(scaleAndClamp);
|
|
13937
|
-
}
|
|
13938
|
-
static RGB_HTML(color) {
|
|
13939
|
-
return `#${color.map(makeColorComp).join("")}`;
|
|
13940
|
-
}
|
|
13941
|
-
static T_HTML() {
|
|
13942
|
-
return "#00000000";
|
|
13943
|
-
}
|
|
13944
|
-
static T_rgb() {
|
|
13945
|
-
return [null];
|
|
13946
|
-
}
|
|
13947
|
-
static CMYK_RGB([c, y, m, k]) {
|
|
13948
|
-
return [
|
|
13949
|
-
"RGB",
|
|
13950
|
-
1 - Math.min(1, c + k),
|
|
13951
|
-
1 - Math.min(1, m + k),
|
|
13952
|
-
1 - Math.min(1, y + k)
|
|
13953
|
-
];
|
|
13954
|
-
}
|
|
13955
|
-
static CMYK_rgb([c, y, m, k]) {
|
|
13956
|
-
return [
|
|
13957
|
-
scaleAndClamp(1 - Math.min(1, c + k)),
|
|
13958
|
-
scaleAndClamp(1 - Math.min(1, m + k)),
|
|
13959
|
-
scaleAndClamp(1 - Math.min(1, y + k))
|
|
13960
|
-
];
|
|
13961
|
-
}
|
|
13962
|
-
static CMYK_HTML(components) {
|
|
13963
|
-
const rgb = this.CMYK_RGB(components).slice(1);
|
|
13964
|
-
return this.RGB_HTML(rgb);
|
|
13965
|
-
}
|
|
13966
|
-
static RGB_CMYK([r, g, b]) {
|
|
13967
|
-
const c = 1 - r;
|
|
13968
|
-
const m = 1 - g;
|
|
13969
|
-
const y = 1 - b;
|
|
13970
|
-
const k = Math.min(c, m, y);
|
|
13971
|
-
return ["CMYK", c, m, y, k];
|
|
13972
|
-
}
|
|
13973
|
-
};
|
|
13974
|
-
|
|
13975
14021
|
// src/pdf.js/src/display/svg_factory.js
|
|
13976
14022
|
var BaseSVGFactory = class {
|
|
13977
14023
|
constructor() {
|
|
@@ -14222,7 +14268,6 @@ var XfaLayer = class {
|
|
|
14222
14268
|
};
|
|
14223
14269
|
|
|
14224
14270
|
// src/pdf.js/src/display/annotation_layer.js
|
|
14225
|
-
var DEFAULT_TAB_INDEX = 1e3;
|
|
14226
14271
|
var DEFAULT_FONT_SIZE2 = 9;
|
|
14227
14272
|
var GetElementsByNameSet = /* @__PURE__ */ new WeakSet();
|
|
14228
14273
|
var AnnotationElementFactory = class {
|
|
@@ -14321,8 +14366,8 @@ var _AnnotationElement = class _AnnotationElement {
|
|
|
14321
14366
|
this._createQuadrilaterals();
|
|
14322
14367
|
}
|
|
14323
14368
|
}
|
|
14324
|
-
static _hasPopupData({
|
|
14325
|
-
return !!(
|
|
14369
|
+
static _hasPopupData({ contentsObj, richText }) {
|
|
14370
|
+
return !!(contentsObj?.str || richText?.str);
|
|
14326
14371
|
}
|
|
14327
14372
|
get _isEditable() {
|
|
14328
14373
|
return this.data.isEditable;
|
|
@@ -14367,7 +14412,7 @@ var _AnnotationElement = class _AnnotationElement {
|
|
|
14367
14412
|
const container = document.createElement("section");
|
|
14368
14413
|
container.setAttribute("data-annotation-id", data.id);
|
|
14369
14414
|
if (!(this instanceof WidgetAnnotationElement)) {
|
|
14370
|
-
container.tabIndex =
|
|
14415
|
+
container.tabIndex = 0;
|
|
14371
14416
|
}
|
|
14372
14417
|
const { style } = container;
|
|
14373
14418
|
style.zIndex = this.parent.zIndex++;
|
|
@@ -14606,6 +14651,7 @@ var _AnnotationElement = class _AnnotationElement {
|
|
|
14606
14651
|
svg.classList.add("quadrilateralsContainer");
|
|
14607
14652
|
svg.setAttribute("width", 0);
|
|
14608
14653
|
svg.setAttribute("height", 0);
|
|
14654
|
+
svg.role = "none";
|
|
14609
14655
|
const defs = svgFactory.createElement("defs");
|
|
14610
14656
|
svg.append(defs);
|
|
14611
14657
|
const clipPath = svgFactory.createElement("clipPath");
|
|
@@ -14659,7 +14705,8 @@ var _AnnotationElement = class _AnnotationElement {
|
|
|
14659
14705
|
parentRect: data.rect,
|
|
14660
14706
|
borderStyle: 0,
|
|
14661
14707
|
id: `popup_${data.id}`,
|
|
14662
|
-
rotation: data.rotation
|
|
14708
|
+
rotation: data.rotation,
|
|
14709
|
+
noRotate: true
|
|
14663
14710
|
},
|
|
14664
14711
|
parent: this.parent,
|
|
14665
14712
|
elements: [this]
|
|
@@ -14762,7 +14809,8 @@ var _AnnotationElement = class _AnnotationElement {
|
|
|
14762
14809
|
this.linkService.eventBus?.dispatch("switchannotationeditormode", {
|
|
14763
14810
|
source: this,
|
|
14764
14811
|
mode,
|
|
14765
|
-
editId
|
|
14812
|
+
editId,
|
|
14813
|
+
mustEnterInEditMode: true
|
|
14766
14814
|
});
|
|
14767
14815
|
});
|
|
14768
14816
|
}
|
|
@@ -15269,7 +15317,11 @@ var TextWidgetAnnotationElement = class extends WidgetAnnotationElement {
|
|
|
15269
15317
|
element.setAttribute("data-element-id", id);
|
|
15270
15318
|
element.disabled = this.data.readOnly;
|
|
15271
15319
|
element.name = this.data.fieldName;
|
|
15272
|
-
element.tabIndex =
|
|
15320
|
+
element.tabIndex = 0;
|
|
15321
|
+
const format = this.data.dateFormat || this.data.timeFormat;
|
|
15322
|
+
if (format) {
|
|
15323
|
+
element.title = format;
|
|
15324
|
+
}
|
|
15273
15325
|
this._setRequired(element, this.data.required);
|
|
15274
15326
|
if (maxLen) {
|
|
15275
15327
|
element.maxLength = maxLen;
|
|
@@ -15541,7 +15593,7 @@ var CheckboxWidgetAnnotationElement = class extends WidgetAnnotationElement {
|
|
|
15541
15593
|
element.setAttribute("checked", true);
|
|
15542
15594
|
}
|
|
15543
15595
|
element.setAttribute("exportValue", data.exportValue);
|
|
15544
|
-
element.tabIndex =
|
|
15596
|
+
element.tabIndex = 0;
|
|
15545
15597
|
element.addEventListener("change", (event) => {
|
|
15546
15598
|
const { name, checked } = event.target;
|
|
15547
15599
|
for (const checkbox of this._getElementsByName(
|
|
@@ -15628,7 +15680,7 @@ var RadioButtonWidgetAnnotationElement = class extends WidgetAnnotationElement {
|
|
|
15628
15680
|
if (value) {
|
|
15629
15681
|
element.setAttribute("checked", true);
|
|
15630
15682
|
}
|
|
15631
|
-
element.tabIndex =
|
|
15683
|
+
element.tabIndex = 0;
|
|
15632
15684
|
element.addEventListener("change", (event) => {
|
|
15633
15685
|
const { name, checked } = event.target;
|
|
15634
15686
|
for (const radio of this._getElementsByName(
|
|
@@ -15717,7 +15769,7 @@ var ChoiceWidgetAnnotationElement = class extends WidgetAnnotationElement {
|
|
|
15717
15769
|
selectElement.disabled = this.data.readOnly;
|
|
15718
15770
|
this._setRequired(selectElement, this.data.required);
|
|
15719
15771
|
selectElement.name = this.data.fieldName;
|
|
15720
|
-
selectElement.tabIndex =
|
|
15772
|
+
selectElement.tabIndex = 0;
|
|
15721
15773
|
let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;
|
|
15722
15774
|
if (!this.data.combo) {
|
|
15723
15775
|
selectElement.size = this.data.options.length;
|
|
@@ -15972,7 +16024,9 @@ var PopupAnnotationElement = class extends AnnotationElement {
|
|
|
15972
16024
|
this.popup = null;
|
|
15973
16025
|
}
|
|
15974
16026
|
render() {
|
|
15975
|
-
this
|
|
16027
|
+
const { container } = this;
|
|
16028
|
+
container.classList.add("popupAnnotation");
|
|
16029
|
+
container.role = "comment";
|
|
15976
16030
|
const popup = this.popup = new PopupElement({
|
|
15977
16031
|
container: this.container,
|
|
15978
16032
|
color: this.data.color,
|
|
@@ -16086,7 +16140,7 @@ var PopupElement = class {
|
|
|
16086
16140
|
({ dir: title.dir, str: title.textContent } = __privateGet(this, _titleObj));
|
|
16087
16141
|
popup.append(header);
|
|
16088
16142
|
if (__privateGet(this, _dateObj)) {
|
|
16089
|
-
const modificationDate = document.createElement("
|
|
16143
|
+
const modificationDate = document.createElement("time");
|
|
16090
16144
|
modificationDate.classList.add("popupDate");
|
|
16091
16145
|
modificationDate.setAttribute(
|
|
16092
16146
|
"data-l10n-id",
|
|
@@ -16096,6 +16150,7 @@ var PopupElement = class {
|
|
|
16096
16150
|
"data-l10n-args",
|
|
16097
16151
|
JSON.stringify({ dateObj: __privateGet(this, _dateObj).valueOf() })
|
|
16098
16152
|
);
|
|
16153
|
+
modificationDate.dateTime = __privateGet(this, _dateObj).toISOString();
|
|
16099
16154
|
header.append(modificationDate);
|
|
16100
16155
|
}
|
|
16101
16156
|
const html = __privateGet(this, _PopupElement_instances, html_get);
|
|
@@ -16659,11 +16714,20 @@ var HighlightAnnotationElement = class extends AnnotationElement {
|
|
|
16659
16714
|
this.annotationEditorType = AnnotationEditorType.HIGHLIGHT;
|
|
16660
16715
|
}
|
|
16661
16716
|
render() {
|
|
16662
|
-
|
|
16717
|
+
const {
|
|
16718
|
+
data: { overlaidText, popupRef }
|
|
16719
|
+
} = this;
|
|
16720
|
+
if (!popupRef && this.hasPopupData) {
|
|
16663
16721
|
this._createPopup();
|
|
16664
16722
|
}
|
|
16665
16723
|
this.container.classList.add("highlightAnnotation");
|
|
16666
16724
|
this._editOnDoubleClick();
|
|
16725
|
+
if (overlaidText) {
|
|
16726
|
+
const mark = document.createElement("mark");
|
|
16727
|
+
mark.classList.add("overlaidText");
|
|
16728
|
+
mark.textContent = overlaidText;
|
|
16729
|
+
this.container.append(mark);
|
|
16730
|
+
}
|
|
16667
16731
|
return this.container;
|
|
16668
16732
|
}
|
|
16669
16733
|
};
|
|
@@ -16676,10 +16740,19 @@ var UnderlineAnnotationElement = class extends AnnotationElement {
|
|
|
16676
16740
|
});
|
|
16677
16741
|
}
|
|
16678
16742
|
render() {
|
|
16679
|
-
|
|
16743
|
+
const {
|
|
16744
|
+
data: { overlaidText, popupRef }
|
|
16745
|
+
} = this;
|
|
16746
|
+
if (!popupRef && this.hasPopupData) {
|
|
16680
16747
|
this._createPopup();
|
|
16681
16748
|
}
|
|
16682
16749
|
this.container.classList.add("underlineAnnotation");
|
|
16750
|
+
if (overlaidText) {
|
|
16751
|
+
const underline = document.createElement("u");
|
|
16752
|
+
underline.classList.add("overlaidText");
|
|
16753
|
+
underline.textContent = overlaidText;
|
|
16754
|
+
this.container.append(underline);
|
|
16755
|
+
}
|
|
16683
16756
|
return this.container;
|
|
16684
16757
|
}
|
|
16685
16758
|
};
|
|
@@ -16692,10 +16765,19 @@ var SquigglyAnnotationElement = class extends AnnotationElement {
|
|
|
16692
16765
|
});
|
|
16693
16766
|
}
|
|
16694
16767
|
render() {
|
|
16695
|
-
|
|
16768
|
+
const {
|
|
16769
|
+
data: { overlaidText, popupRef }
|
|
16770
|
+
} = this;
|
|
16771
|
+
if (!popupRef && this.hasPopupData) {
|
|
16696
16772
|
this._createPopup();
|
|
16697
16773
|
}
|
|
16698
16774
|
this.container.classList.add("squigglyAnnotation");
|
|
16775
|
+
if (overlaidText) {
|
|
16776
|
+
const underline = document.createElement("u");
|
|
16777
|
+
underline.classList.add("overlaidText");
|
|
16778
|
+
underline.textContent = overlaidText;
|
|
16779
|
+
this.container.append(underline);
|
|
16780
|
+
}
|
|
16699
16781
|
return this.container;
|
|
16700
16782
|
}
|
|
16701
16783
|
};
|
|
@@ -16708,10 +16790,19 @@ var StrikeOutAnnotationElement = class extends AnnotationElement {
|
|
|
16708
16790
|
});
|
|
16709
16791
|
}
|
|
16710
16792
|
render() {
|
|
16711
|
-
|
|
16793
|
+
const {
|
|
16794
|
+
data: { overlaidText, popupRef }
|
|
16795
|
+
} = this;
|
|
16796
|
+
if (!popupRef && this.hasPopupData) {
|
|
16712
16797
|
this._createPopup();
|
|
16713
16798
|
}
|
|
16714
16799
|
this.container.classList.add("strikeoutAnnotation");
|
|
16800
|
+
if (overlaidText) {
|
|
16801
|
+
const strikeout = document.createElement("s");
|
|
16802
|
+
strikeout.classList.add("overlaidText");
|
|
16803
|
+
strikeout.textContent = overlaidText;
|
|
16804
|
+
this.container.append(strikeout);
|
|
16805
|
+
}
|
|
16715
16806
|
return this.container;
|
|
16716
16807
|
}
|
|
16717
16808
|
};
|
|
@@ -16890,7 +16981,7 @@ var _AnnotationLayer = class _AnnotationLayer {
|
|
|
16890
16981
|
if (data.hidden) {
|
|
16891
16982
|
rendered.style.visibility = "hidden";
|
|
16892
16983
|
}
|
|
16893
|
-
await __privateMethod(this, _AnnotationLayer_instances, appendElement_fn).call(this, rendered, data.id);
|
|
16984
|
+
await __privateMethod(this, _AnnotationLayer_instances, appendElement_fn).call(this, rendered, data.id, elementParams.elements);
|
|
16894
16985
|
if (element._isEditable) {
|
|
16895
16986
|
__privateGet(this, _editableAnnotations).set(element.data.id, element);
|
|
16896
16987
|
this._annotationEditorUIManager?.renderAnnotationElement(element);
|
|
@@ -16921,7 +17012,7 @@ var _AnnotationLayer = class _AnnotationLayer {
|
|
|
16921
17012
|
continue;
|
|
16922
17013
|
}
|
|
16923
17014
|
const rendered = element.render();
|
|
16924
|
-
await __privateMethod(this, _AnnotationLayer_instances, appendElement_fn).call(this, rendered, data.id);
|
|
17015
|
+
await __privateMethod(this, _AnnotationLayer_instances, appendElement_fn).call(this, rendered, data.id, null);
|
|
16925
17016
|
}
|
|
16926
17017
|
}
|
|
16927
17018
|
/**
|
|
@@ -16966,7 +17057,7 @@ _annotationCanvasMap = new WeakMap();
|
|
|
16966
17057
|
_editableAnnotations = new WeakMap();
|
|
16967
17058
|
_structTreeLayer = new WeakMap();
|
|
16968
17059
|
_AnnotationLayer_instances = new WeakSet();
|
|
16969
|
-
appendElement_fn = async function(element, id) {
|
|
17060
|
+
appendElement_fn = async function(element, id, popupElements) {
|
|
16970
17061
|
const contentElement = element.firstChild || element;
|
|
16971
17062
|
const annotationId = contentElement.id = `${AnnotationPrefix}${id}`;
|
|
16972
17063
|
const ariaAttributes = await __privateGet(this, _structTreeLayer)?.getAriaAttributes(annotationId);
|
|
@@ -16975,14 +17066,18 @@ appendElement_fn = async function(element, id) {
|
|
|
16975
17066
|
contentElement.setAttribute(key, value);
|
|
16976
17067
|
}
|
|
16977
17068
|
}
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
element
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
17069
|
+
if (popupElements) {
|
|
17070
|
+
popupElements.at(-1).container.after(element);
|
|
17071
|
+
} else {
|
|
17072
|
+
this.div.append(element);
|
|
17073
|
+
__privateGet(this, _accessibilityManager)?.moveElementInDOM(
|
|
17074
|
+
this.div,
|
|
17075
|
+
element,
|
|
17076
|
+
contentElement,
|
|
17077
|
+
/* isRemovable = */
|
|
17078
|
+
false
|
|
17079
|
+
);
|
|
17080
|
+
}
|
|
16986
17081
|
};
|
|
16987
17082
|
setAnnotationCanvasMap_fn = function() {
|
|
16988
17083
|
if (!__privateGet(this, _annotationCanvasMap)) {
|
|
@@ -17038,6 +17133,9 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17038
17133
|
__privateAdd(this, _fontSize);
|
|
17039
17134
|
__privateSet(this, _color2, params.color || _FreeTextEditor._defaultColor || AnnotationEditor._defaultLineColor);
|
|
17040
17135
|
__privateSet(this, _fontSize, params.fontSize || _FreeTextEditor._defaultFontSize);
|
|
17136
|
+
if (!this.annotationElementId) {
|
|
17137
|
+
this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert");
|
|
17138
|
+
}
|
|
17041
17139
|
}
|
|
17042
17140
|
static get _keyboardManager() {
|
|
17043
17141
|
const proto = _FreeTextEditor.prototype;
|
|
@@ -17545,6 +17643,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17545
17643
|
pageIndex: pageNumber - 1,
|
|
17546
17644
|
rect: rect.slice(0),
|
|
17547
17645
|
rotation,
|
|
17646
|
+
annotationElementId: id,
|
|
17548
17647
|
id,
|
|
17549
17648
|
deleted: false,
|
|
17550
17649
|
popupRef
|
|
@@ -17554,7 +17653,6 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17554
17653
|
__privateSet(editor, _fontSize, data.fontSize);
|
|
17555
17654
|
__privateSet(editor, _color2, Util.makeHexColor(...data.color));
|
|
17556
17655
|
__privateSet(editor, _content, __privateMethod(_a2 = _FreeTextEditor, _FreeTextEditor_static, deserializeContent_fn).call(_a2, data.value));
|
|
17557
|
-
editor.annotationElementId = data.id || null;
|
|
17558
17656
|
editor._initialData = initialData;
|
|
17559
17657
|
return editor;
|
|
17560
17658
|
}
|
|
@@ -18691,7 +18789,7 @@ var _ColorPicker = class _ColorPicker {
|
|
|
18691
18789
|
}
|
|
18692
18790
|
__privateSet(this, _uiManager2, editor?._uiManager || uiManager);
|
|
18693
18791
|
__privateSet(this, _eventBus, __privateGet(this, _uiManager2)._eventBus);
|
|
18694
|
-
__privateSet(this, _defaultColor, editor?.color || __privateGet(this, _uiManager2)?.highlightColors.values().next().value || "#FFFF98");
|
|
18792
|
+
__privateSet(this, _defaultColor, editor?.color?.toUpperCase() || __privateGet(this, _uiManager2)?.highlightColors.values().next().value || "#FFFF98");
|
|
18695
18793
|
__privateGet(_ColorPicker, _l10nColor) || __privateSet(_ColorPicker, _l10nColor, Object.freeze({
|
|
18696
18794
|
blue: "pdfjs-editor-colorpicker-blue",
|
|
18697
18795
|
green: "pdfjs-editor-colorpicker-green",
|
|
@@ -18728,21 +18826,24 @@ var _ColorPicker = class _ColorPicker {
|
|
|
18728
18826
|
button.className = "colorPicker";
|
|
18729
18827
|
button.tabIndex = "0";
|
|
18730
18828
|
button.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-button");
|
|
18731
|
-
button.
|
|
18829
|
+
button.ariaHasPopup = "true";
|
|
18830
|
+
if (__privateGet(this, _editor3)) {
|
|
18831
|
+
button.ariaControls = `${__privateGet(this, _editor3).id}_colorpicker_dropdown`;
|
|
18832
|
+
}
|
|
18732
18833
|
const signal = __privateGet(this, _uiManager2)._signal;
|
|
18733
18834
|
button.addEventListener("click", __privateMethod(this, _ColorPicker_instances, openDropdown_fn).bind(this), { signal });
|
|
18734
18835
|
button.addEventListener("keydown", __privateMethod(this, _ColorPicker_instances, keyDown_fn2).bind(this), { signal });
|
|
18735
18836
|
const swatch = __privateSet(this, _buttonSwatch, document.createElement("span"));
|
|
18736
18837
|
swatch.className = "swatch";
|
|
18737
|
-
swatch.
|
|
18838
|
+
swatch.ariaHidden = "true";
|
|
18738
18839
|
swatch.style.backgroundColor = __privateGet(this, _defaultColor);
|
|
18739
18840
|
button.append(swatch);
|
|
18740
18841
|
return button;
|
|
18741
18842
|
}
|
|
18742
18843
|
renderMainDropdown() {
|
|
18743
18844
|
const dropdown = __privateSet(this, _dropdown, __privateMethod(this, _ColorPicker_instances, getDropdownRoot_fn).call(this));
|
|
18744
|
-
dropdown.
|
|
18745
|
-
dropdown.
|
|
18845
|
+
dropdown.ariaOrientation = "horizontal";
|
|
18846
|
+
dropdown.ariaLabelledBy = "highlightColorPickerLabel";
|
|
18746
18847
|
return dropdown;
|
|
18747
18848
|
}
|
|
18748
18849
|
_colorSelectFromKeyboard(event) {
|
|
@@ -18795,6 +18896,7 @@ var _ColorPicker = class _ColorPicker {
|
|
|
18795
18896
|
}
|
|
18796
18897
|
hideDropdown() {
|
|
18797
18898
|
__privateGet(this, _dropdown)?.classList.add("hidden");
|
|
18899
|
+
__privateGet(this, _button).ariaExpanded = "false";
|
|
18798
18900
|
__privateGet(this, _openDropdownAC)?.abort();
|
|
18799
18901
|
__privateSet(this, _openDropdownAC, null);
|
|
18800
18902
|
}
|
|
@@ -18821,7 +18923,7 @@ var _ColorPicker = class _ColorPicker {
|
|
|
18821
18923
|
}
|
|
18822
18924
|
const i = __privateGet(this, _uiManager2).highlightColors.values();
|
|
18823
18925
|
for (const child of __privateGet(this, _dropdown).children) {
|
|
18824
|
-
child.
|
|
18926
|
+
child.ariaSelected = i.next().value === color.toUpperCase();
|
|
18825
18927
|
}
|
|
18826
18928
|
}
|
|
18827
18929
|
destroy() {
|
|
@@ -18851,9 +18953,12 @@ getDropdownRoot_fn = function() {
|
|
|
18851
18953
|
div.addEventListener("contextmenu", noContextMenu, { signal });
|
|
18852
18954
|
div.className = "dropdown";
|
|
18853
18955
|
div.role = "listbox";
|
|
18854
|
-
div.
|
|
18855
|
-
div.
|
|
18956
|
+
div.ariaMultiSelectable = "false";
|
|
18957
|
+
div.ariaOrientation = "vertical";
|
|
18856
18958
|
div.setAttribute("data-l10n-id", "pdfjs-editor-colorpicker-dropdown");
|
|
18959
|
+
if (__privateGet(this, _editor3)) {
|
|
18960
|
+
div.id = `${__privateGet(this, _editor3).id}_colorpicker_dropdown`;
|
|
18961
|
+
}
|
|
18857
18962
|
for (const [name, color] of __privateGet(this, _uiManager2).highlightColors) {
|
|
18858
18963
|
const button = document.createElement("button");
|
|
18859
18964
|
button.tabIndex = "0";
|
|
@@ -18865,7 +18970,7 @@ getDropdownRoot_fn = function() {
|
|
|
18865
18970
|
button.append(swatch);
|
|
18866
18971
|
swatch.className = "swatch";
|
|
18867
18972
|
swatch.style.backgroundColor = color;
|
|
18868
|
-
button.
|
|
18973
|
+
button.ariaSelected = color === __privateGet(this, _defaultColor);
|
|
18869
18974
|
button.addEventListener("click", __privateMethod(this, _ColorPicker_instances, colorSelect_fn).bind(this, color), {
|
|
18870
18975
|
signal
|
|
18871
18976
|
});
|
|
@@ -18897,6 +19002,7 @@ openDropdown_fn = function(event) {
|
|
|
18897
19002
|
signal: __privateGet(this, _uiManager2).combinedSignal(__privateGet(this, _openDropdownAC))
|
|
18898
19003
|
});
|
|
18899
19004
|
}
|
|
19005
|
+
__privateGet(this, _button).ariaExpanded = "true";
|
|
18900
19006
|
if (__privateGet(this, _dropdown)) {
|
|
18901
19007
|
__privateGet(this, _dropdown).classList.remove("hidden");
|
|
18902
19008
|
return;
|
|
@@ -18961,6 +19067,9 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
18961
19067
|
__privateMethod(this, _HighlightEditor_instances, addToDrawLayer_fn).call(this);
|
|
18962
19068
|
this.rotate(this.rotation);
|
|
18963
19069
|
}
|
|
19070
|
+
if (!this.annotationElementId) {
|
|
19071
|
+
this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert");
|
|
19072
|
+
}
|
|
18964
19073
|
}
|
|
18965
19074
|
static get _keyboardManager() {
|
|
18966
19075
|
const proto = _HighlightEditor.prototype;
|
|
@@ -19056,16 +19165,14 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19056
19165
|
];
|
|
19057
19166
|
}
|
|
19058
19167
|
/** @inheritdoc */
|
|
19059
|
-
|
|
19060
|
-
const toolbar = await super.addEditToolbar();
|
|
19061
|
-
if (!toolbar) {
|
|
19062
|
-
return null;
|
|
19063
|
-
}
|
|
19168
|
+
get toolbarButtons() {
|
|
19064
19169
|
if (this._uiManager.highlightColors) {
|
|
19065
|
-
__privateSet(this, _colorPicker2, new ColorPicker({
|
|
19066
|
-
|
|
19170
|
+
const colorPicker = __privateSet(this, _colorPicker2, new ColorPicker({
|
|
19171
|
+
editor: this
|
|
19172
|
+
}));
|
|
19173
|
+
return [["colorPicker", colorPicker]];
|
|
19067
19174
|
}
|
|
19068
|
-
return
|
|
19175
|
+
return super.toolbarButtons;
|
|
19069
19176
|
}
|
|
19070
19177
|
/** @inheritdoc */
|
|
19071
19178
|
disableEditing() {
|
|
@@ -19358,6 +19465,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19358
19465
|
pageIndex: pageNumber - 1,
|
|
19359
19466
|
rect: rect.slice(0),
|
|
19360
19467
|
rotation,
|
|
19468
|
+
annotationElementId: id,
|
|
19361
19469
|
id,
|
|
19362
19470
|
deleted: false,
|
|
19363
19471
|
popupRef
|
|
@@ -19386,6 +19494,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19386
19494
|
pageIndex: pageNumber - 1,
|
|
19387
19495
|
rect: rect.slice(0),
|
|
19388
19496
|
rotation,
|
|
19497
|
+
annotationElementId: id,
|
|
19389
19498
|
id,
|
|
19390
19499
|
deleted: false,
|
|
19391
19500
|
popupRef
|
|
@@ -19398,7 +19507,6 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19398
19507
|
if (inkLists) {
|
|
19399
19508
|
__privateSet(editor, _thickness2, data.thickness);
|
|
19400
19509
|
}
|
|
19401
|
-
editor.annotationElementId = data.id || null;
|
|
19402
19510
|
editor._initialData = initialData;
|
|
19403
19511
|
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
19404
19512
|
const [pageX, pageY] = editor.pageTranslation;
|
|
@@ -20498,6 +20606,9 @@ _DrawingEditor_instances = new WeakSet();
|
|
|
20498
20606
|
createDrawOutlines_fn = function({ drawOutlines, drawId, drawingOptions }) {
|
|
20499
20607
|
__privateSet(this, _drawOutlines, drawOutlines);
|
|
20500
20608
|
this._drawingOptions || (this._drawingOptions = drawingOptions);
|
|
20609
|
+
if (!this.annotationElementId) {
|
|
20610
|
+
this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`);
|
|
20611
|
+
}
|
|
20501
20612
|
if (drawId >= 0) {
|
|
20502
20613
|
this._drawId = drawId;
|
|
20503
20614
|
this.parent.drawLayer.finalizeDraw(
|
|
@@ -21524,13 +21635,13 @@ var _InkEditor = class _InkEditor extends DrawingEditor {
|
|
|
21524
21635
|
pageIndex: pageNumber - 1,
|
|
21525
21636
|
rect: rect.slice(0),
|
|
21526
21637
|
rotation,
|
|
21638
|
+
annotationElementId: id,
|
|
21527
21639
|
id,
|
|
21528
21640
|
deleted: false,
|
|
21529
21641
|
popupRef
|
|
21530
21642
|
};
|
|
21531
21643
|
}
|
|
21532
21644
|
const editor = await super.deserialize(data, parent, uiManager);
|
|
21533
|
-
editor.annotationElementId = data.id || null;
|
|
21534
21645
|
editor._initialData = initialData;
|
|
21535
21646
|
return editor;
|
|
21536
21647
|
}
|
|
@@ -22469,26 +22580,17 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22469
22580
|
return { areContours, outline: outlineData.outline };
|
|
22470
22581
|
}
|
|
22471
22582
|
/** @inheritdoc */
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
return null;
|
|
22476
|
-
}
|
|
22477
|
-
if (this._uiManager.signatureManager && __privateGet(this, _description) !== null) {
|
|
22478
|
-
await toolbar.addEditSignatureButton(
|
|
22479
|
-
this._uiManager.signatureManager,
|
|
22480
|
-
__privateGet(this, _signatureUUID),
|
|
22481
|
-
__privateGet(this, _description)
|
|
22482
|
-
);
|
|
22483
|
-
toolbar.show();
|
|
22583
|
+
get toolbarButtons() {
|
|
22584
|
+
if (this._uiManager.signatureManager) {
|
|
22585
|
+
return [["editSignature", this._uiManager.signatureManager]];
|
|
22484
22586
|
}
|
|
22485
|
-
return
|
|
22587
|
+
return super.toolbarButtons;
|
|
22486
22588
|
}
|
|
22487
22589
|
addSignature(data, heightInPage, description, uuid) {
|
|
22488
22590
|
const { x: savedX, y: savedY } = this;
|
|
22489
22591
|
const { outline } = __privateSet(this, _signatureData, data);
|
|
22490
22592
|
__privateSet(this, _isExtracted, outline instanceof ContourDrawOutline);
|
|
22491
|
-
|
|
22593
|
+
this.description = description;
|
|
22492
22594
|
this.div.setAttribute("data-l10n-args", JSON.stringify({ description }));
|
|
22493
22595
|
let drawingOptions;
|
|
22494
22596
|
if (__privateGet(this, _isExtracted)) {
|
|
@@ -22798,6 +22900,10 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22798
22900
|
return !(__privateGet(this, _bitmapPromise) || __privateGet(this, _bitmap) || __privateGet(this, _bitmapUrl) || __privateGet(this, _bitmapFile) || __privateGet(this, _bitmapId) || __privateGet(this, _missingCanvas));
|
|
22799
22901
|
}
|
|
22800
22902
|
/** @inheritdoc */
|
|
22903
|
+
get toolbarButtons() {
|
|
22904
|
+
return [["altText", this.createAltText()]];
|
|
22905
|
+
}
|
|
22906
|
+
/** @inheritdoc */
|
|
22801
22907
|
get isResizable() {
|
|
22802
22908
|
return true;
|
|
22803
22909
|
}
|
|
@@ -22813,7 +22919,7 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22813
22919
|
}
|
|
22814
22920
|
super.render();
|
|
22815
22921
|
this.div.hidden = true;
|
|
22816
|
-
this.
|
|
22922
|
+
this.createAltText();
|
|
22817
22923
|
if (!__privateGet(this, _missingCanvas)) {
|
|
22818
22924
|
if (__privateGet(this, _bitmap)) {
|
|
22819
22925
|
__privateMethod(this, _StampEditor_instances, createCanvas_fn).call(this);
|
|
@@ -22992,6 +23098,7 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22992
23098
|
pageIndex: pageNumber - 1,
|
|
22993
23099
|
rect: rect2.slice(0),
|
|
22994
23100
|
rotation,
|
|
23101
|
+
annotationElementId: id,
|
|
22995
23102
|
id,
|
|
22996
23103
|
deleted: false,
|
|
22997
23104
|
accessibilityData: {
|
|
@@ -23020,7 +23127,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23020
23127
|
const [parentWidth, parentHeight] = editor.pageDimensions;
|
|
23021
23128
|
editor.width = (rect[2] - rect[0]) / parentWidth;
|
|
23022
23129
|
editor.height = (rect[3] - rect[1]) / parentHeight;
|
|
23023
|
-
editor.annotationElementId = data.id || null;
|
|
23024
23130
|
if (accessibilityData) {
|
|
23025
23131
|
editor.altTextData = accessibilityData;
|
|
23026
23132
|
}
|
|
@@ -23139,12 +23245,14 @@ getBitmapDone_fn = function() {
|
|
|
23139
23245
|
return;
|
|
23140
23246
|
}
|
|
23141
23247
|
if (this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && __privateGet(this, _bitmap)) {
|
|
23142
|
-
this.
|
|
23143
|
-
|
|
23144
|
-
this
|
|
23145
|
-
|
|
23146
|
-
|
|
23147
|
-
|
|
23248
|
+
this.addEditToolbar().then(() => {
|
|
23249
|
+
this._editToolbar.hide();
|
|
23250
|
+
this._uiManager.editAltText(
|
|
23251
|
+
this,
|
|
23252
|
+
/* firstTime = */
|
|
23253
|
+
true
|
|
23254
|
+
);
|
|
23255
|
+
});
|
|
23148
23256
|
return;
|
|
23149
23257
|
}
|
|
23150
23258
|
if (!this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && __privateGet(this, _bitmap)) {
|
|
@@ -23277,6 +23385,9 @@ createCanvas_fn = function() {
|
|
|
23277
23385
|
if (__privateGet(this, _bitmapFileName)) {
|
|
23278
23386
|
this.div.setAttribute("aria-description", __privateGet(this, _bitmapFileName));
|
|
23279
23387
|
}
|
|
23388
|
+
if (!this.annotationElementId) {
|
|
23389
|
+
this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert");
|
|
23390
|
+
}
|
|
23280
23391
|
};
|
|
23281
23392
|
scaleBitmap_fn = function(width, height) {
|
|
23282
23393
|
const { width: bitmapWidth, height: bitmapHeight } = __privateGet(this, _bitmap);
|
|
@@ -23391,7 +23502,7 @@ __publicField(StampEditor, "_type", "stamp");
|
|
|
23391
23502
|
__publicField(StampEditor, "_editorType", AnnotationEditorType.STAMP);
|
|
23392
23503
|
|
|
23393
23504
|
// src/pdf.js/src/display/editor/annotation_editor_layer.js
|
|
23394
|
-
var _accessibilityManager2, _allowClick, _annotationLayer, _clickAC, _editorFocusTimeoutId, _editors, _hadPointerDown, _isDisabling, _isEnabling, _drawingAC, _focusedElement, _textLayer, _textSelectionAC, _uiManager3, _editorTypes2, _AnnotationEditorLayer_instances, textLayerPointerDown_fn, currentEditorType_get, createNewEditor_fn, getCenterPoint_fn, cleanup_fn;
|
|
23505
|
+
var _accessibilityManager2, _allowClick, _annotationLayer, _clickAC, _editorFocusTimeoutId, _editors, _hadPointerDown, _isDisabling, _isEnabling, _drawingAC, _focusedElement, _textLayer, _textSelectionAC, _textLayerDblClickAC, _lastPointerDownTimestamp, _uiManager3, _editorTypes2, _AnnotationEditorLayer_instances, textLayerPointerDown_fn, currentEditorType_get, createNewEditor_fn, getCenterPoint_fn, cleanup_fn;
|
|
23395
23506
|
var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
23396
23507
|
/**
|
|
23397
23508
|
* @param {AnnotationEditorLayerOptions} options
|
|
@@ -23422,6 +23533,8 @@ var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
|
23422
23533
|
__privateAdd(this, _focusedElement, null);
|
|
23423
23534
|
__privateAdd(this, _textLayer, null);
|
|
23424
23535
|
__privateAdd(this, _textSelectionAC, null);
|
|
23536
|
+
__privateAdd(this, _textLayerDblClickAC, null);
|
|
23537
|
+
__privateAdd(this, _lastPointerDownTimestamp, -1);
|
|
23425
23538
|
__privateAdd(this, _uiManager3);
|
|
23426
23539
|
const editorTypes = [...__privateGet(_AnnotationEditorLayer, _editorTypes2).values()];
|
|
23427
23540
|
if (!_AnnotationEditorLayer._initialized) {
|
|
@@ -23530,6 +23643,8 @@ var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
|
23530
23643
|
__privateSet(this, _isEnabling, true);
|
|
23531
23644
|
this.div.tabIndex = 0;
|
|
23532
23645
|
this.togglePointerEvents(true);
|
|
23646
|
+
__privateGet(this, _textLayerDblClickAC)?.abort();
|
|
23647
|
+
__privateSet(this, _textLayerDblClickAC, null);
|
|
23533
23648
|
const annotationElementIds = /* @__PURE__ */ new Set();
|
|
23534
23649
|
for (const editor of __privateGet(this, _editors).values()) {
|
|
23535
23650
|
editor.enableEditing();
|
|
@@ -23568,6 +23683,48 @@ var _AnnotationEditorLayer = class _AnnotationEditorLayer {
|
|
|
23568
23683
|
__privateSet(this, _isDisabling, true);
|
|
23569
23684
|
this.div.tabIndex = -1;
|
|
23570
23685
|
this.togglePointerEvents(false);
|
|
23686
|
+
if (__privateGet(this, _textLayer) && !__privateGet(this, _textLayerDblClickAC)) {
|
|
23687
|
+
__privateSet(this, _textLayerDblClickAC, new AbortController());
|
|
23688
|
+
const signal = __privateGet(this, _uiManager3).combinedSignal(__privateGet(this, _textLayerDblClickAC));
|
|
23689
|
+
__privateGet(this, _textLayer).div.addEventListener(
|
|
23690
|
+
"pointerdown",
|
|
23691
|
+
(e) => {
|
|
23692
|
+
const DBL_CLICK_THRESHOLD = 500;
|
|
23693
|
+
const { clientX, clientY, timeStamp } = e;
|
|
23694
|
+
const lastPointerDownTimestamp = __privateGet(this, _lastPointerDownTimestamp);
|
|
23695
|
+
if (timeStamp - lastPointerDownTimestamp > DBL_CLICK_THRESHOLD) {
|
|
23696
|
+
__privateSet(this, _lastPointerDownTimestamp, timeStamp);
|
|
23697
|
+
return;
|
|
23698
|
+
}
|
|
23699
|
+
__privateSet(this, _lastPointerDownTimestamp, -1);
|
|
23700
|
+
const { classList: classList2 } = this.div;
|
|
23701
|
+
classList2.toggle("getElements", true);
|
|
23702
|
+
const elements = document.elementsFromPoint(clientX, clientY);
|
|
23703
|
+
classList2.toggle("getElements", false);
|
|
23704
|
+
if (!this.div.contains(elements[0])) {
|
|
23705
|
+
return;
|
|
23706
|
+
}
|
|
23707
|
+
let id;
|
|
23708
|
+
const regex = new RegExp(`^${AnnotationEditorPrefix}[0-9]+$`);
|
|
23709
|
+
for (const element of elements) {
|
|
23710
|
+
if (regex.test(element.id)) {
|
|
23711
|
+
id = element.id;
|
|
23712
|
+
break;
|
|
23713
|
+
}
|
|
23714
|
+
}
|
|
23715
|
+
if (!id) {
|
|
23716
|
+
return;
|
|
23717
|
+
}
|
|
23718
|
+
const editor = __privateGet(this, _editors).get(id);
|
|
23719
|
+
if (editor?.annotationElementId === null) {
|
|
23720
|
+
e.stopPropagation();
|
|
23721
|
+
e.preventDefault();
|
|
23722
|
+
editor.dblclick();
|
|
23723
|
+
}
|
|
23724
|
+
},
|
|
23725
|
+
{ signal, capture: true }
|
|
23726
|
+
);
|
|
23727
|
+
}
|
|
23571
23728
|
const changedAnnotations = /* @__PURE__ */ new Map();
|
|
23572
23729
|
const resetAnnotations = /* @__PURE__ */ new Map();
|
|
23573
23730
|
for (const editor of __privateGet(this, _editors).values()) {
|
|
@@ -24111,6 +24268,8 @@ _drawingAC = new WeakMap();
|
|
|
24111
24268
|
_focusedElement = new WeakMap();
|
|
24112
24269
|
_textLayer = new WeakMap();
|
|
24113
24270
|
_textSelectionAC = new WeakMap();
|
|
24271
|
+
_textLayerDblClickAC = new WeakMap();
|
|
24272
|
+
_lastPointerDownTimestamp = new WeakMap();
|
|
24114
24273
|
_uiManager3 = new WeakMap();
|
|
24115
24274
|
_editorTypes2 = new WeakMap();
|
|
24116
24275
|
_AnnotationEditorLayer_instances = new WeakSet();
|
|
@@ -24583,7 +24742,7 @@ var SvgPattern = class {
|
|
|
24583
24742
|
this.transform = matrix;
|
|
24584
24743
|
}
|
|
24585
24744
|
};
|
|
24586
|
-
var
|
|
24745
|
+
var SvgLinearGradient = class {
|
|
24587
24746
|
constructor(x1, y1, x2, y2) {
|
|
24588
24747
|
__publicField(this, "x1");
|
|
24589
24748
|
__publicField(this, "y1");
|
|
@@ -24599,6 +24758,26 @@ var SvgGradient = class {
|
|
|
24599
24758
|
this.stops.push({ offset, color });
|
|
24600
24759
|
}
|
|
24601
24760
|
};
|
|
24761
|
+
var SvgRadialGradient = class {
|
|
24762
|
+
constructor(x0, y0, r0, x1, y1, r1) {
|
|
24763
|
+
__publicField(this, "x0");
|
|
24764
|
+
__publicField(this, "y0");
|
|
24765
|
+
__publicField(this, "r0");
|
|
24766
|
+
__publicField(this, "x1");
|
|
24767
|
+
__publicField(this, "y1");
|
|
24768
|
+
__publicField(this, "r1");
|
|
24769
|
+
__publicField(this, "stops", []);
|
|
24770
|
+
this.x0 = x0;
|
|
24771
|
+
this.y0 = y0;
|
|
24772
|
+
this.r0 = r0;
|
|
24773
|
+
this.x1 = x1;
|
|
24774
|
+
this.y1 = y1;
|
|
24775
|
+
this.r1 = r1;
|
|
24776
|
+
}
|
|
24777
|
+
addColorStop(offset, color) {
|
|
24778
|
+
this.stops.push({ offset, color });
|
|
24779
|
+
}
|
|
24780
|
+
};
|
|
24602
24781
|
function isSvgElement(node) {
|
|
24603
24782
|
return "children" in node;
|
|
24604
24783
|
}
|
|
@@ -25135,7 +25314,10 @@ var SvgCanvasContext = class {
|
|
|
25135
25314
|
return new SvgPattern(src, width, height);
|
|
25136
25315
|
}
|
|
25137
25316
|
createLinearGradient(x1, x2, y1, y2) {
|
|
25138
|
-
return new
|
|
25317
|
+
return new SvgLinearGradient(x1, y1, x2, y2);
|
|
25318
|
+
}
|
|
25319
|
+
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
25320
|
+
return new SvgRadialGradient(x0, y0, r0, x1, y1, r1);
|
|
25139
25321
|
}
|
|
25140
25322
|
clip(path, fillRule) {
|
|
25141
25323
|
if (typeof path === "string" || fillRule) {
|
|
@@ -25251,6 +25433,37 @@ var SvgCanvasContext = class {
|
|
|
25251
25433
|
}
|
|
25252
25434
|
_createGradientNode(gradient) {
|
|
25253
25435
|
const id = `pattern_${crypto.randomUUID()}`;
|
|
25436
|
+
if (gradient instanceof SvgRadialGradient) {
|
|
25437
|
+
return {
|
|
25438
|
+
tag: "radialGradient",
|
|
25439
|
+
attrs: {
|
|
25440
|
+
id,
|
|
25441
|
+
cx: `${gradient.x1}`,
|
|
25442
|
+
cy: `${gradient.y1}`,
|
|
25443
|
+
r: `${gradient.r1}`,
|
|
25444
|
+
fx: `${gradient.x0}`,
|
|
25445
|
+
fy: `${gradient.y0}`,
|
|
25446
|
+
gradientUnits: "userSpaceOnUse"
|
|
25447
|
+
},
|
|
25448
|
+
children: gradient.stops.map(({ offset, color }) => {
|
|
25449
|
+
const stopElement = {
|
|
25450
|
+
tag: "stop",
|
|
25451
|
+
attrs: {
|
|
25452
|
+
offset: `${offset}`,
|
|
25453
|
+
"stop-color": color
|
|
25454
|
+
}
|
|
25455
|
+
};
|
|
25456
|
+
if (color.startsWith("rgba(")) {
|
|
25457
|
+
const parsed = parseRGBAColor(color);
|
|
25458
|
+
stopElement.attrs["stop-color"] = `rgb(${parsed.r}, ${parsed.g}, ${parsed.b})`;
|
|
25459
|
+
stopElement.attrs["stop-opacity"] = `${parsed.a ?? 1}`;
|
|
25460
|
+
} else {
|
|
25461
|
+
stopElement.attrs["stop-color"] = color;
|
|
25462
|
+
}
|
|
25463
|
+
return stopElement;
|
|
25464
|
+
})
|
|
25465
|
+
};
|
|
25466
|
+
}
|
|
25254
25467
|
return {
|
|
25255
25468
|
tag: "linearGradient",
|
|
25256
25469
|
attrs: {
|
|
@@ -25294,7 +25507,11 @@ var SvgCanvasContext = class {
|
|
|
25294
25507
|
const pattern = this._createPatternNode(fillStyle, fillStyle.transform);
|
|
25295
25508
|
this._defs.children.push(pattern);
|
|
25296
25509
|
currentElement.attrs.fill = `url(#${pattern.attrs.id})`;
|
|
25297
|
-
} else if (fillStyle instanceof
|
|
25510
|
+
} else if (fillStyle instanceof SvgLinearGradient) {
|
|
25511
|
+
const gradient = this._createGradientNode(fillStyle);
|
|
25512
|
+
this._defs.children.push(gradient);
|
|
25513
|
+
currentElement.attrs.fill = `url(#${gradient.attrs.id})`;
|
|
25514
|
+
} else if (fillStyle instanceof SvgRadialGradient) {
|
|
25298
25515
|
const gradient = this._createGradientNode(fillStyle);
|
|
25299
25516
|
this._defs.children.push(gradient);
|
|
25300
25517
|
currentElement.attrs.fill = `url(#${gradient.attrs.id})`;
|
|
@@ -25316,7 +25533,7 @@ var SvgCanvasContext = class {
|
|
|
25316
25533
|
);
|
|
25317
25534
|
this._defs.children.push(pattern);
|
|
25318
25535
|
currentElement.attrs.stroke = `url(#${pattern.attrs.id})`;
|
|
25319
|
-
} else if (strokeStyle instanceof
|
|
25536
|
+
} else if (strokeStyle instanceof SvgLinearGradient) {
|
|
25320
25537
|
const gradient = this._createGradientNode(strokeStyle);
|
|
25321
25538
|
this._defs.children.push(gradient);
|
|
25322
25539
|
currentElement.attrs.fill = `url(#${gradient.attrs.id})`;
|