Merge pull request #15351 from Snuffleupagus/bug-1785854
[api-minor][editor] Indicate, in the title, if the document has been edited (bug 1785854)
This commit is contained in:
commit
c5b9e9aef8
@ -68,12 +68,21 @@ class AnnotationStorage {
|
|||||||
* Remove a value from the storage.
|
* Remove a value from the storage.
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
*/
|
*/
|
||||||
removeKey(key) {
|
remove(key) {
|
||||||
this._storage.delete(key);
|
this._storage.delete(key);
|
||||||
|
|
||||||
if (this._storage.size === 0) {
|
if (this._storage.size === 0) {
|
||||||
this.resetModified();
|
this.resetModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof this.onAnnotationEditor === "function") {
|
||||||
|
for (const value of this._storage.values()) {
|
||||||
|
if (value instanceof AnnotationEditor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.onAnnotationEditor(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,15 +181,6 @@ class AnnotationStorage {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasAnnotationEditors() {
|
|
||||||
for (const value of this._storage.values()) {
|
|
||||||
if (value instanceof AnnotationEditor) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PLEASE NOTE: Only intended for usage within the API itself.
|
* PLEASE NOTE: Only intended for usage within the API itself.
|
||||||
* @ignore
|
* @ignore
|
||||||
|
@ -207,7 +207,7 @@ class AnnotationEditorLayer {
|
|||||||
|
|
||||||
this.#uiManager.removeEditor(editor);
|
this.#uiManager.removeEditor(editor);
|
||||||
this.detach(editor);
|
this.detach(editor);
|
||||||
this.annotationStorage.removeKey(editor.id);
|
this.annotationStorage.remove(editor.id);
|
||||||
editor.div.style.display = "none";
|
editor.div.style.display = "none";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// When the div is removed from DOM the focus can move on the
|
// When the div is removed from DOM the focus can move on the
|
||||||
|
29
web/app.js
29
web/app.js
@ -262,6 +262,8 @@ const PDFViewerApplication = {
|
|||||||
_wheelUnusedTicks: 0,
|
_wheelUnusedTicks: 0,
|
||||||
_idleCallbacks: new Set(),
|
_idleCallbacks: new Set(),
|
||||||
_PDFBug: null,
|
_PDFBug: null,
|
||||||
|
_hasAnnotationEditors: false,
|
||||||
|
_title: document.title,
|
||||||
_printAnnotationStoragePromise: null,
|
_printAnnotationStoragePromise: null,
|
||||||
|
|
||||||
// Called once when the document is loaded.
|
// Called once when the document is loaded.
|
||||||
@ -788,12 +790,14 @@ const PDFViewerApplication = {
|
|||||||
this.setTitle(title);
|
this.setTitle(title);
|
||||||
},
|
},
|
||||||
|
|
||||||
setTitle(title) {
|
setTitle(title = this._title) {
|
||||||
|
this._title = title;
|
||||||
|
|
||||||
if (this.isViewerEmbedded) {
|
if (this.isViewerEmbedded) {
|
||||||
// Embedded PDF viewers should not be changing their parent page's title.
|
// Embedded PDF viewers should not be changing their parent page's title.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.title = title;
|
document.title = `${this._hasAnnotationEditors ? "* " : ""}${title}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
get _docFilename() {
|
get _docFilename() {
|
||||||
@ -880,10 +884,12 @@ const PDFViewerApplication = {
|
|||||||
this._contentLength = null;
|
this._contentLength = null;
|
||||||
this._saveInProgress = false;
|
this._saveInProgress = false;
|
||||||
this._docStats = null;
|
this._docStats = null;
|
||||||
|
this._hasAnnotationEditors = false;
|
||||||
|
|
||||||
this._cancelIdleCallbacks();
|
this._cancelIdleCallbacks();
|
||||||
promises.push(this.pdfScriptingManager.destroyPromise);
|
promises.push(this.pdfScriptingManager.destroyPromise);
|
||||||
|
|
||||||
|
this.setTitle();
|
||||||
this.pdfSidebar.reset();
|
this.pdfSidebar.reset();
|
||||||
this.pdfOutlineViewer.reset();
|
this.pdfOutlineViewer.reset();
|
||||||
this.pdfAttachmentViewer.reset();
|
this.pdfAttachmentViewer.reset();
|
||||||
@ -1045,12 +1051,10 @@ const PDFViewerApplication = {
|
|||||||
this._saveInProgress = false;
|
this._saveInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) {
|
if (this._hasAnnotationEditors) {
|
||||||
this.externalServices.reportTelemetry({
|
this.externalServices.reportTelemetry({
|
||||||
type: "editing",
|
type: "editing",
|
||||||
data: {
|
data: { type: "save" },
|
||||||
type: "save",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1582,7 +1586,7 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
if (pdfTitle) {
|
if (pdfTitle) {
|
||||||
this.setTitle(
|
this.setTitle(
|
||||||
`${pdfTitle} - ${this._contentDispositionFilename || document.title}`
|
`${pdfTitle} - ${this._contentDispositionFilename || this._title}`
|
||||||
);
|
);
|
||||||
} else if (this._contentDispositionFilename) {
|
} else if (this._contentDispositionFilename) {
|
||||||
this.setTitle(this._contentDispositionFilename);
|
this.setTitle(this._contentDispositionFilename);
|
||||||
@ -1744,10 +1748,15 @@ const PDFViewerApplication = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
annotationStorage.onAnnotationEditor = typeStr => {
|
annotationStorage.onAnnotationEditor = typeStr => {
|
||||||
|
this._hasAnnotationEditors = !!typeStr;
|
||||||
|
this.setTitle();
|
||||||
|
|
||||||
|
if (typeStr) {
|
||||||
this.externalServices.reportTelemetry({
|
this.externalServices.reportTelemetry({
|
||||||
type: "editing",
|
type: "editing",
|
||||||
data: { type: typeStr },
|
data: { type: typeStr },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1888,12 +1897,10 @@ const PDFViewerApplication = {
|
|||||||
type: "print",
|
type: "print",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) {
|
if (this._hasAnnotationEditors) {
|
||||||
this.externalServices.reportTelemetry({
|
this.externalServices.reportTelemetry({
|
||||||
type: "editing",
|
type: "editing",
|
||||||
data: {
|
data: { type: "print" },
|
||||||
type: "print",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user