mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Enable automatic URL linking
Automatically detect links in the text content of a file and automatically generate link annotations at the appropriate locations to achieve automatic link detection and hyperlinking.
This commit is contained in:
parent
90a5c37cb0
commit
61ba1ea48c
20 changed files with 656 additions and 14 deletions
|
@ -3238,6 +3238,33 @@ class AnnotationLayer {
|
|||
this.#setAnnotationCanvasMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add link annotations to the annotation layer.
|
||||
*
|
||||
* @param {Array<Object>} annotations
|
||||
* @param {IPDFLinkService} linkService
|
||||
* @memberof AnnotationLayer
|
||||
*/
|
||||
async addLinkAnnotations(annotations, linkService) {
|
||||
const elementParams = {
|
||||
data: null,
|
||||
layer: this.div,
|
||||
linkService,
|
||||
svgFactory: new DOMSVGFactory(),
|
||||
parent: this,
|
||||
};
|
||||
for (const data of annotations) {
|
||||
elementParams.data = data;
|
||||
const element = AnnotationElementFactory.create(elementParams);
|
||||
|
||||
if (!element.isRenderable) {
|
||||
continue;
|
||||
}
|
||||
const rendered = element.render();
|
||||
await this.#appendElement(rendered, data.id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the annotation elements on existing annotation layer.
|
||||
*
|
||||
|
|
|
@ -24,9 +24,11 @@
|
|||
|
||||
import {
|
||||
AbortException,
|
||||
AnnotationBorderStyleType,
|
||||
AnnotationEditorParamsType,
|
||||
AnnotationEditorType,
|
||||
AnnotationMode,
|
||||
AnnotationType,
|
||||
createValidAbsoluteUrl,
|
||||
FeatureTest,
|
||||
ImageKind,
|
||||
|
@ -90,12 +92,14 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING || GENERIC")) {
|
|||
|
||||
export {
|
||||
AbortException,
|
||||
AnnotationBorderStyleType,
|
||||
AnnotationEditorLayer,
|
||||
AnnotationEditorParamsType,
|
||||
AnnotationEditorType,
|
||||
AnnotationEditorUIManager,
|
||||
AnnotationLayer,
|
||||
AnnotationMode,
|
||||
AnnotationType,
|
||||
build,
|
||||
ColorPicker,
|
||||
createValidAbsoluteUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue