diff --git a/chrome/content/zotero/reader.xhtml b/chrome/content/zotero/reader.xhtml index 948a9aeff7..47da34968f 100644 --- a/chrome/content/zotero/reader.xhtml +++ b/chrome/content/zotero/reader.xhtml @@ -348,6 +348,7 @@ primary="true" transparent="transparent" src="resource://zotero/reader/reader.html" + context="textbox-contextmenu" flex="1"/> diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index f67e07e755..8ddddc8ced 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -1098,6 +1098,7 @@ class ReaderTab extends ReaderInstance { this._iframe.setAttribute('type', 'content'); this._iframe.setAttribute('transparent', 'true'); this._iframe.setAttribute('src', 'resource://zotero/reader/reader.html'); + this._iframe.setAttribute('context', 'textbox-contextmenu'); this._tabContainer.appendChild(this._iframe); this._iframe.docShell.windowDraggingAllowed = true; @@ -1108,6 +1109,8 @@ class ReaderTab extends ReaderInstance { this._window.addEventListener('pointerdown', this._handlePointerDown); this._window.addEventListener('pointerup', this._handlePointerUp); + this._window.goBuildEditContextMenu(); + this._iframe.setAttribute('tooltip', 'html-tooltip'); this._open({ location: options.location, secondViewState: options.secondViewState }); @@ -1127,6 +1130,19 @@ class ReaderTab extends ReaderInstance { this._window.removeEventListener('DOMContentLoaded', this._handleLoad); this._iframeWindow = this._iframe.contentWindow; this._iframeWindow.addEventListener('error', event => Zotero.logError(event.error)); + + // Disable text direction switching option because it tries to change direction + // for the whole window and crashes it + this._iframeWindow.addEventListener('contextmenu', () => { + let popup = this._window.goBuildEditContextMenu(); + this._window.goUpdateGlobalEditMenuItems(true); + popup.addEventListener('popupshowing', (e) => { + let menuitemSwitchTextDirection = e.target.querySelector("[command='cmd_switchTextDirection']"); + if (menuitemSwitchTextDirection) { + menuitemSwitchTextDirection.hidden = true; + } + }, { once: true }); + }); } }; @@ -1226,6 +1242,18 @@ class ReaderWindow extends ReaderInstance { if (this._iframe.contentWindow && this._iframe.contentWindow.document === event.target) { this._iframeWindow = this._window.document.getElementById('reader').contentWindow; this._iframeWindow.addEventListener('error', event => Zotero.logError(event.error)); + this._window.goBuildEditContextMenu(); + // Disable text direction switching option because it changes direction for the whole window + this._iframeWindow.addEventListener('contextmenu', () => { + let popup = this._window.goBuildEditContextMenu(); + this._window.goUpdateGlobalEditMenuItems(true); + popup.addEventListener('popupshowing', (e) => { + let menuitemSwitchTextDirection = e.target.querySelector("[command='cmd_switchTextDirection']"); + if (menuitemSwitchTextDirection) { + menuitemSwitchTextDirection.hidden = true; + } + }, { once: true }); + }); } this._switchReaderSubtype(this._type);