mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Move the cursorToolOnLoad
preference handling into AppOptions
(PR 9493 follow-up)
Since no other viewer component is currently reading preferences itself, this patch thus unifies the behaviour across the viewer.
This commit is contained in:
parent
6db9c3cb49
commit
c2f1523f06
3 changed files with 16 additions and 7 deletions
|
@ -25,15 +25,16 @@ const CursorTool = {
|
|||
* @typedef {Object} PDFCursorToolsOptions
|
||||
* @property {HTMLDivElement} container - The document container.
|
||||
* @property {EventBus} eventBus - The application event bus.
|
||||
* @property {BasePreferences} preferences - Object for reading/writing
|
||||
* persistent settings.
|
||||
* @property {number} cursorToolOnLoad - (optional) The cursor tool that will be
|
||||
* enabled on load; the constants from {CursorTool} should be used.
|
||||
* The default value is `CursorTool.SELECT`.
|
||||
*/
|
||||
|
||||
class PDFCursorTools {
|
||||
/**
|
||||
* @param {PDFCursorToolsOptions} options
|
||||
*/
|
||||
constructor({ container, eventBus, preferences, }) {
|
||||
constructor({ container, eventBus, cursorToolOnLoad = CursorTool.SELECT, }) {
|
||||
this.container = container;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
|
@ -46,9 +47,9 @@ class PDFCursorTools {
|
|||
|
||||
this._addEventListeners();
|
||||
|
||||
preferences.get('cursorToolOnLoad').then((value) => {
|
||||
this.switchTool(value);
|
||||
}).catch(() => { });
|
||||
Promise.resolve().then(() => {
|
||||
this.switchTool(cursorToolOnLoad);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue