mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Editor] Provide an element to render in the annotation layer after a freetext has been edited (bug 1890535)
This commit is contained in:
parent
7290faf840
commit
71ea8499f0
11 changed files with 379 additions and 42 deletions
|
@ -94,11 +94,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
canvas {
|
||||
.annotationContent {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
|
||||
&.freetext {
|
||||
background: transparent;
|
||||
border: none;
|
||||
inset: 0;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
font: 10px sans-serif;
|
||||
line-height: 1.35;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
section {
|
||||
|
@ -107,6 +118,12 @@
|
|||
pointer-events: auto;
|
||||
box-sizing: border-box;
|
||||
transform-origin: 0 0;
|
||||
|
||||
&:has(div.annotationContent) {
|
||||
canvas.annotationContent {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a {
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
|
||||
// eslint-disable-next-line max-len
|
||||
/** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */
|
||||
|
||||
import { AnnotationLayer } from "pdfjs-lib";
|
||||
import { PresentationModeState } from "./ui_utils.js";
|
||||
|
@ -41,6 +43,7 @@ import { PresentationModeState } from "./ui_utils.js";
|
|||
* [fieldObjectsPromise]
|
||||
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
|
||||
* @property {TextAccessibilityManager} [accessibilityManager]
|
||||
* @property {AnnotationEditorUIManager} [annotationEditorUIManager]
|
||||
* @property {function} [onAppend]
|
||||
*/
|
||||
|
||||
|
@ -64,6 +67,7 @@ class AnnotationLayerBuilder {
|
|||
fieldObjectsPromise = null,
|
||||
annotationCanvasMap = null,
|
||||
accessibilityManager = null,
|
||||
annotationEditorUIManager = null,
|
||||
onAppend = null,
|
||||
}) {
|
||||
this.pdfPage = pdfPage;
|
||||
|
@ -77,6 +81,7 @@ class AnnotationLayerBuilder {
|
|||
this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
|
||||
this._annotationCanvasMap = annotationCanvasMap;
|
||||
this._accessibilityManager = accessibilityManager;
|
||||
this._annotationEditorUIManager = annotationEditorUIManager;
|
||||
this.#onAppend = onAppend;
|
||||
|
||||
this.annotationLayer = null;
|
||||
|
@ -128,6 +133,7 @@ class AnnotationLayerBuilder {
|
|||
div,
|
||||
accessibilityManager: this._accessibilityManager,
|
||||
annotationCanvasMap: this._annotationCanvasMap,
|
||||
annotationEditorUIManager: this._annotationEditorUIManager,
|
||||
page: this.pdfPage,
|
||||
viewport: viewport.clone({ dontFlip: true }),
|
||||
});
|
||||
|
|
|
@ -938,6 +938,7 @@ class PDFPageView {
|
|||
) {
|
||||
const {
|
||||
annotationStorage,
|
||||
annotationEditorUIManager,
|
||||
downloadManager,
|
||||
enableScripting,
|
||||
fieldObjectsPromise,
|
||||
|
@ -958,6 +959,7 @@ class PDFPageView {
|
|||
fieldObjectsPromise,
|
||||
annotationCanvasMap: this._annotationCanvasMap,
|
||||
accessibilityManager: this._accessibilityManager,
|
||||
annotationEditorUIManager,
|
||||
onAppend: annotationLayerDiv => {
|
||||
this.#addLayer(annotationLayerDiv, "annotationLayer");
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue