[editor] Disable the editor-buttons in XFA documents
Given the differences between XFA documents and "normal" PDF documents, we don't support editing of the former ones. Hence, when a XFA-document is opened, we temporarily disable the editor-buttons.
This commit is contained in:
parent
9b22483e00
commit
d34e7fff01
13
web/app.js
13
web/app.js
@ -561,10 +561,6 @@ const PDFViewerApplication = {
|
|||||||
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppOptions.get("annotationEditorEnabled")) {
|
|
||||||
document.getElementById("editorModeButtons").classList.remove("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pdfDocumentProperties = new PDFDocumentProperties(
|
this.pdfDocumentProperties = new PDFDocumentProperties(
|
||||||
appConfig.documentProperties,
|
appConfig.documentProperties,
|
||||||
this.overlayManager,
|
this.overlayManager,
|
||||||
@ -1196,6 +1192,11 @@ const PDFViewerApplication = {
|
|||||||
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
this.toolbar.setPagesCount(pdfDocument.numPages, false);
|
||||||
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
|
||||||
|
|
||||||
|
if (pdfDocument.isPureXfa) {
|
||||||
|
console.warn("Warning: XFA-editing is not implemented.");
|
||||||
|
this.toolbar.updateEditorModeButtonsState(/* disabled = */ true);
|
||||||
|
}
|
||||||
|
|
||||||
let baseDocumentUrl;
|
let baseDocumentUrl;
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
baseDocumentUrl = null;
|
baseDocumentUrl = null;
|
||||||
@ -2237,6 +2238,10 @@ function webViewerInitialized() {
|
|||||||
appConfig.toolbar.viewFind.classList.add("hidden");
|
appConfig.toolbar.viewFind.classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PDFViewerApplication.pdfViewer.enableAnnotationEditor) {
|
||||||
|
appConfig.toolbar.editorModeButtons.classList.remove("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
appConfig.mainContainer.addEventListener(
|
appConfig.mainContainer.addEventListener(
|
||||||
"transitionend",
|
"transitionend",
|
||||||
function (evt) {
|
function (evt) {
|
||||||
|
@ -53,16 +53,16 @@ const OptionKind = {
|
|||||||
* primitive types and cannot rely on any imported types.
|
* primitive types and cannot rely on any imported types.
|
||||||
*/
|
*/
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
annotationMode: {
|
|
||||||
/** @type {number} */
|
|
||||||
value: 2,
|
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
|
||||||
},
|
|
||||||
annotationEditorEnabled: {
|
annotationEditorEnabled: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
|
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
|
annotationMode: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 2,
|
||||||
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
|
},
|
||||||
cursorToolOnLoad: {
|
cursorToolOnLoad: {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
value: 0,
|
value: 0,
|
||||||
|
@ -359,6 +359,13 @@ class BaseViewer {
|
|||||||
return this.#annotationMode === AnnotationMode.ENABLE_FORMS;
|
return this.#annotationMode === AnnotationMode.ENABLE_FORMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
get enableAnnotationEditor() {
|
||||||
|
return !!this.#annotationEditorUIManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
@ -719,9 +726,8 @@ class BaseViewer {
|
|||||||
const annotationLayerFactory =
|
const annotationLayerFactory =
|
||||||
this.#annotationMode !== AnnotationMode.DISABLE ? this : null;
|
this.#annotationMode !== AnnotationMode.DISABLE ? this : null;
|
||||||
const xfaLayerFactory = isPureXfa ? this : null;
|
const xfaLayerFactory = isPureXfa ? this : null;
|
||||||
const annotationEditorLayerFactory = this.#annotationEditorUIManager
|
const annotationEditorLayerFactory =
|
||||||
? this
|
this.#annotationEditorUIManager && !isPureXfa ? this : null;
|
||||||
: null;
|
|
||||||
|
|
||||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
const pageView = new PDFPageView({
|
const pageView = new PDFPageView({
|
||||||
|
@ -97,6 +97,8 @@ class Toolbar {
|
|||||||
next: options.next,
|
next: options.next,
|
||||||
zoomIn: options.zoomIn,
|
zoomIn: options.zoomIn,
|
||||||
zoomOut: options.zoomOut,
|
zoomOut: options.zoomOut,
|
||||||
|
editorNoneButton: options.editorNoneButton,
|
||||||
|
editorFreeTextButton: options.editorFreeTextButton,
|
||||||
};
|
};
|
||||||
|
|
||||||
this._wasLocalized = false;
|
this._wasLocalized = false;
|
||||||
@ -133,6 +135,7 @@ class Toolbar {
|
|||||||
this.pageScale = DEFAULT_SCALE;
|
this.pageScale = DEFAULT_SCALE;
|
||||||
this._updateUIState(true);
|
this._updateUIState(true);
|
||||||
this.updateLoadingIndicatorState();
|
this.updateLoadingIndicatorState();
|
||||||
|
this.updateEditorModeButtonsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
_bindListeners(options) {
|
_bindListeners(options) {
|
||||||
@ -267,9 +270,16 @@ class Toolbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLoadingIndicatorState(loading = false) {
|
updateLoadingIndicatorState(loading = false) {
|
||||||
const pageNumberInput = this.items.pageNumber;
|
const { pageNumber } = this.items;
|
||||||
|
|
||||||
pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
|
pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEditorModeButtonsState(disabled = false) {
|
||||||
|
const { editorNoneButton, editorFreeTextButton } = this.items;
|
||||||
|
|
||||||
|
editorNoneButton.disabled = disabled;
|
||||||
|
editorFreeTextButton.disabled = disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
--loading-icon: url(images/loading.svg);
|
--loading-icon: url(images/loading.svg);
|
||||||
--treeitem-expanded-icon: url(images/treeitem-expanded.svg);
|
--treeitem-expanded-icon: url(images/treeitem-expanded.svg);
|
||||||
--treeitem-collapsed-icon: url(images/treeitem-collapsed.svg);
|
--treeitem-collapsed-icon: url(images/treeitem-collapsed.svg);
|
||||||
--toolbarButton-editorFreeText-icon: url(images/toolbarButton-editorFreeText.svg);
|
|
||||||
--toolbarButton-editorNone-icon: url(images/toolbarButton-editorNone.svg);
|
--toolbarButton-editorNone-icon: url(images/toolbarButton-editorNone.svg);
|
||||||
|
--toolbarButton-editorFreeText-icon: url(images/toolbarButton-editorFreeText.svg);
|
||||||
--toolbarButton-menuArrow-icon: url(images/toolbarButton-menuArrow.svg);
|
--toolbarButton-menuArrow-icon: url(images/toolbarButton-menuArrow.svg);
|
||||||
--toolbarButton-sidebarToggle-icon: url(images/toolbarButton-sidebarToggle.svg);
|
--toolbarButton-sidebarToggle-icon: url(images/toolbarButton-sidebarToggle.svg);
|
||||||
--toolbarButton-secondaryToolbarToggle-icon: url(images/toolbarButton-secondaryToolbarToggle.svg);
|
--toolbarButton-secondaryToolbarToggle-icon: url(images/toolbarButton-secondaryToolbarToggle.svg);
|
||||||
|
@ -93,6 +93,7 @@ function getViewerConfiguration() {
|
|||||||
? document.getElementById("openFile")
|
? document.getElementById("openFile")
|
||||||
: null,
|
: null,
|
||||||
print: document.getElementById("print"),
|
print: document.getElementById("print"),
|
||||||
|
editorModeButtons: document.getElementById("editorModeButtons"),
|
||||||
editorNoneButton: document.getElementById("editorNone"),
|
editorNoneButton: document.getElementById("editorNone"),
|
||||||
editorFreeTextButton: document.getElementById("editorFreeText"),
|
editorFreeTextButton: document.getElementById("editorFreeText"),
|
||||||
presentationModeButton: document.getElementById("presentationMode"),
|
presentationModeButton: document.getElementById("presentationMode"),
|
||||||
|
Loading…
Reference in New Issue
Block a user