Enable PDF reader by default and enable for groups

"Zotero" is now the first and default option in the "Open PDFs using"
drop-down in the General pane of the preferences.
This commit is contained in:
Dan Stillman 2022-01-29 02:13:13 -05:00
parent f8d7eb8ed7
commit 5a0cd78f06
22 changed files with 84 additions and 263 deletions

View file

@ -363,16 +363,7 @@
} }
var type = Zotero.Libraries.get(this.item.libraryID).libraryType; var type = Zotero.Libraries.get(this.item.libraryID).libraryType;
var switherDeck = this._id('attachment-note-editor-switcher'); var noteEditor = this._id('attachment-note-editor');
// Note editor
if (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild) {
var noteEditor = this._id('attachment-note-editor-old');
switherDeck.selectedIndex = 0;
}
else {
var noteEditor = this._id('attachment-note-editor');
switherDeck.selectedIndex = 1;
}
if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) { if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) {
noteEditor.linksOnTop = true; noteEditor.linksOnTop = true;
@ -637,10 +628,7 @@
</grid> </grid>
</vbox> </vbox>
<deck id="attachment-note-editor-switcher" flex="1"> <zoteronoteeditor id="attachment-note-editor" notitle="1" flex="1"/>
<oldzoteronoteeditor id="attachment-note-editor-old" notitle="1" flex="1"/>
<zoteronoteeditor id="attachment-note-editor" notitle="1" flex="1"/>
</deck>
<button id="select-button" hidden="true"/> <button id="select-button" hidden="true"/>
</vbox> </vbox>

View file

@ -340,8 +340,7 @@
case 'note': case 'note':
var type = Zotero.Libraries.get(this.libraryID).libraryType; var type = Zotero.Libraries.get(this.libraryID).libraryType;
var useOld = type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild; elementName = 'zoteronoteeditor';
elementName = useOld ? 'oldzoteronoteeditor' : 'zoteronoteeditor';
break; break;
case 'annotation': case 'annotation':

View file

@ -256,58 +256,22 @@ var ZoteroItemPane = new function() {
tree.focus(); tree.focus();
} }
} }
this.switchEditorEngine = function (useOld) {
var switherDeck = document.getElementById('zotero-note-editor-switcher');
switherDeck.selectedIndex = useOld ? 0 : 1;
};
this.onNoteSelected = function (item, editable) { this.onNoteSelected = function (item, editable) {
_selectedNoteID = item.id; _selectedNoteID = item.id;
var type = Zotero.Libraries.get(item.libraryID).libraryType; var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild) { var noteEditor = document.getElementById('zotero-note-editor');
// If an external note window is open for this item, don't show the editor noteEditor.mode = editable ? 'edit' : 'view';
if (ZoteroPane.findNoteWindow(item.id)) { noteEditor.viewMode = 'library';
this.showNoteWindowMessage(); noteEditor.parent = null;
return; noteEditor.item = item;
}
var noteEditor = document.getElementById('zotero-note-editor-old');
// If loading new or different note, disable undo while we repopulate the text field
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
// undo content from another note into the current one.
var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
noteEditor.mode = editable ? 'edit' : 'view';
noteEditor.parent = null;
noteEditor.item = item;
if (clearUndo) {
noteEditor.clearUndo();
}
}
else {
var noteEditor = document.getElementById('zotero-note-editor');
noteEditor.mode = editable ? 'edit' : 'view';
noteEditor.viewMode = 'library';
noteEditor.parent = null;
noteEditor.item = item;
}
document.getElementById('zotero-view-note-button').hidden = !editable || (type == 'user' || Zotero.enablePDFBuildForGroups) && Zotero.isPDFBuild;
document.getElementById('zotero-item-pane-content').selectedIndex = 2; document.getElementById('zotero-item-pane-content').selectedIndex = 2;
}; };
this.showNoteWindowMessage = function () {
ZoteroPane.setItemPaneMessage(Zotero.getString('pane.item.notes.editingInWindow'));
};
/** /**
* Select the parent item and open the note editor * Select the parent item and open the note editor
*/ */
@ -315,19 +279,6 @@ var ZoteroItemPane = new function() {
var selectedNote = Zotero.Items.get(_selectedNoteID); var selectedNote = Zotero.Items.get(_selectedNoteID);
var type = Zotero.Libraries.get(selectedNote.libraryID).libraryType; var type = Zotero.Libraries.get(selectedNote.libraryID).libraryType;
if (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild) {
// We don't want to show the note in two places, since it causes unnecessary UI updates
// and can result in weird bugs where note content gets lost.
//
// If this is a child note, select the parent
if (selectedNote.parentID) {
await ZoteroPane.selectItem(selectedNote.parentID);
}
// Otherwise, hide note and replace with a message that we're editing externally
else {
this.showNoteWindowMessage();
}
}
ZoteroPane.openNoteWindow(selectedNote.id); ZoteroPane.openNoteWindow(selectedNote.id);
}; };

View file

@ -117,16 +117,8 @@
'onerror' handler crashes the app on a save error to prevent typing in notes 'onerror' handler crashes the app on a save error to prevent typing in notes
while they're not being saved while they're not being saved
--> -->
<deck id="zotero-note-editor-switcher" flex="1"> <zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"
<oldzoteronoteeditor id="zotero-note-editor-old" flex="1" notitle="1" previousfocus="zotero-items-tree"/>
previousfocus="zotero-items-tree"
onerror="ZoteroPane.displayErrorMessage(); this.mode = 'view'"/>
<zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"
previousfocus="zotero-items-tree"/>
</deck>
<button id="zotero-view-note-button"
label="&zotero.notes.separate;"
oncommand="ZoteroItemPane.openNoteWindow()"/>
</groupbox> </groupbox>
<!-- Attachment item --> <!-- Attachment item -->

View file

@ -27,11 +27,6 @@ var noteEditor;
var notifierUnregisterID; var notifierUnregisterID;
var type; var type;
function switchEditorEngine(useOld) {
var switherDeck = document.getElementById('zotero-note-editor-switcher');
switherDeck.selectedIndex = useOld ? 0 : 1;
}
async function onLoad() { async function onLoad() {
if (window.arguments) { if (window.arguments) {
var io = window.arguments[0]; var io = window.arguments[0];
@ -58,13 +53,7 @@ async function onLoad() {
} }
} }
type = Zotero.Libraries.get(libraryID).libraryType; type = Zotero.Libraries.get(libraryID).libraryType;
switchEditorEngine(type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild); noteEditor = document.getElementById('zotero-note-editor');
if (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild) {
noteEditor = document.getElementById('zotero-note-editor-old');
}
else {
noteEditor = document.getElementById('zotero-note-editor');
}
noteEditor.mode = 'edit'; noteEditor.mode = 'edit';
noteEditor.viewMode = 'window'; noteEditor.viewMode = 'window';
@ -107,14 +96,7 @@ function onError() {
function onUnload() { function onUnload() {
Zotero.Notifier.unregisterObserver(notifierUnregisterID); Zotero.Notifier.unregisterObserver(notifierUnregisterID);
if (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild) { noteEditor.saveSync();
if (noteEditor.item) {
window.opener.ZoteroPane.onNoteWindowClosed(noteEditor.item.id, noteEditor.value);
}
}
else {
noteEditor.saveSync();
}
} }
var NotifyCallback = { var NotifyCallback = {

View file

@ -22,8 +22,5 @@
</keyset> </keyset>
<command id="cmd_close" oncommand="window.close();"/> <command id="cmd_close" oncommand="window.close();"/>
<deck id="zotero-note-editor-switcher" flex="1"> <zoteronoteeditor id="zotero-note-editor" flex="1" onerror="return;onError()"/>
<oldzoteronoteeditor id="zotero-note-editor-old" flex="1" onerror="onError()"/>
<zoteronoteeditor id="zotero-note-editor" flex="1" onerror="return;onError()"/>
</deck>
</window> </window>

View file

@ -43,7 +43,6 @@ Zotero_Preferences.General = {
this.updateAutoRenameFilesUI(); this.updateAutoRenameFilesUI();
this._updateFileHandlerUI(); this._updateFileHandlerUI();
this._updateZotero6BetaCheckbox();
}, },
updateAutoRenameFilesUI: function () { updateAutoRenameFilesUI: function () {
@ -60,7 +59,7 @@ Zotero_Preferences.General = {
var currentPath = Zotero.Prefs.get(pref); var currentPath = Zotero.Prefs.get(pref);
var fp = new FilePicker(); var fp = new FilePicker();
if (currentPath) { if (currentPath && currentPath != 'system') {
fp.displayDirectory = OS.Path.dirname(currentPath); fp.displayDirectory = OS.Path.dirname(currentPath);
} }
fp.init( fp.init(
@ -78,12 +77,7 @@ Zotero_Preferences.General = {
setFileHandler: function (type, handler) { setFileHandler: function (type, handler) {
var pref = this._getFileHandlerPref(type); var pref = this._getFileHandlerPref(type);
if (handler) { Zotero.Prefs.set(pref, handler);
Zotero.Prefs.set(pref, handler);
}
else {
Zotero.Prefs.clear(pref);
}
this._updateFileHandlerUI(); this._updateFileHandlerUI();
}, },
@ -92,16 +86,13 @@ Zotero_Preferences.General = {
var menulist = document.getElementById('fileHandler-pdf'); var menulist = document.getElementById('fileHandler-pdf');
var customMenuItem = document.getElementById('fileHandler-custom'); var customMenuItem = document.getElementById('fileHandler-custom');
// TEMP: Use separate checkbox for now // System default
/*if (handler == 'zotero') { if (handler == 'system') {
let menuitem = document.getElementById('fileHandler-internal');
menulist.selectedIndex = 0;
customMenuItem.hidden = true; customMenuItem.hidden = true;
return; menulist.selectedIndex = 1;
}*/ }
// Custom handler // Custom handler
if (handler) { else if (handler) {
let icon; let icon;
try { try {
let fph = Services.io.getProtocolHandler("file") let fph = Services.io.getProtocolHandler("file")
@ -126,13 +117,14 @@ Zotero_Preferences.General = {
customMenuItem.className = ''; customMenuItem.className = '';
} }
customMenuItem.hidden = false; customMenuItem.hidden = false;
menulist.selectedIndex = 1;
}
// System default
else {
customMenuItem.hidden = true;
menulist.selectedIndex = 2; menulist.selectedIndex = 2;
} }
// Zotero
else {
let menuitem = document.getElementById('fileHandler-internal');
menulist.selectedIndex = 0;
customMenuItem.hidden = true;
}
}, },
_getFileHandlerPref: function (type) { _getFileHandlerPref: function (type) {
@ -140,38 +132,5 @@ Zotero_Preferences.General = {
throw new Error(`Unknown file type ${type}`); throw new Error(`Unknown file type ${type}`);
} }
return 'fileHandler.pdf'; return 'fileHandler.pdf';
},
handleZotero6BetaChange: function (event) {
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_CANCEL;
var index = ps.confirmEx(
window,
Zotero.getString('general.restartRequired'),
Zotero.getString('general.restartRequiredForChange', Zotero.appName),
buttonFlags,
Zotero.getString('general.restartApp', Zotero.appName),
null, null, null, {}
);
if (index == 0) {
Zotero.Prefs.set('beta.zotero6', !event.target.checked);
Zotero.Utilities.Internal.quitZotero(true);
return;
}
// Set to opposite so the click changes it back to what it was before
event.target.checked = !event.target.checked;
},
_updateZotero6BetaCheckbox: function () {
var checkbox = document.getElementById('zotero6-checkbox');
if (Zotero.Prefs.get('beta.zotero6')) {
checkbox.setAttribute('checked', true);
}
else {
checkbox.removeAttribute('checked');
}
} }
} }

View file

@ -67,23 +67,15 @@
<menulist id="fileHandler-pdf" class="fileHandler-menu"> <menulist id="fileHandler-pdf" class="fileHandler-menu">
<menupopup> <menupopup>
<menuitem id="fileHandler-internal" <menuitem id="fileHandler-internal"
oncommand="Zotero_Preferences.General.setFileHandler('pdf', 'zotero')" oncommand="Zotero_Preferences.General.setFileHandler('pdf', '')"/>
hidden="true"/>
<menuitem id="fileHandler-custom"/>
<menuitem label="&zotero.preferences.fileHandler.systemDefault;" <menuitem label="&zotero.preferences.fileHandler.systemDefault;"
oncommand="Zotero_Preferences.General.setFileHandler('pdf', false)"/> oncommand="Zotero_Preferences.General.setFileHandler('pdf', 'system')"/>
<menuitem id="fileHandler-custom"/>
<menuitem label="&zotero.preferences.custom;" <menuitem label="&zotero.preferences.custom;"
oncommand="Zotero_Preferences.General.chooseFileHandler('pdf')"/> oncommand="Zotero_Preferences.General.chooseFileHandler('pdf')"/>
</menupopup> </menupopup>
</menulist> </menulist>
</hbox> </hbox>
<checkbox
id="zotero6-checkbox"
label="Enable the Zotero PDF reader and new note editor (preview, My Library only)"
style="margin-top: 5px"
onclick="Zotero_Preferences.General.handleZotero6BetaChange(event)"/>
<label class="zotero-text-link" value="Learn more about the preview"
style="margin-left: 23px; margin-top: 1px" href="https://www.zotero.org/support/pdf_reader_preview"/>
</groupbox> </groupbox>
<groupbox id="zotero-prefpane-miscellaneous-groupbox"> <groupbox id="zotero-prefpane-miscellaneous-groupbox">

View file

@ -87,13 +87,6 @@ const ZoteroStandalone = new function() {
ZoteroStandalone.DebugOutput.init(); ZoteroStandalone.DebugOutput.init();
// TEMP: Remove tab bar if not PDF build
if (Zotero.isMac && !Zotero.isPDFBuild) {
document.documentElement.removeAttribute('drawintitlebar');
document.documentElement.removeAttribute('tabsintitlebar');
document.documentElement.removeAttribute('chromemargin');
}
Zotero.hideZoteroPaneOverlays(); Zotero.hideZoteroPaneOverlays();
ZoteroPane.init(); ZoteroPane.init();
ZoteroPane.makeVisible(); ZoteroPane.makeVisible();

View file

@ -1702,7 +1702,7 @@ Zotero.Server.Connector.Ping.prototype = {
let response = { let response = {
prefs: { prefs: {
automaticSnapshots: Zotero.Prefs.get('automaticSnapshots'), automaticSnapshots: Zotero.Prefs.get('automaticSnapshots'),
googleDocsAddNoteEnabled: Zotero.isPDFBuild googleDocsAddNoteEnabled: true
} }
}; };
if (Zotero.QuickCopy.hasSiteSettings()) { if (Zotero.QuickCopy.hasSiteSettings()) {

View file

@ -1273,19 +1273,6 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
env.sqlValues.push({ int: itemTypeID }); env.sqlValues.push({ int: itemTypeID });
} }
// TEMP: Don't allow annotations or embedded images in group libraries
// TODO: Enable test in annotations.js after removing
if (libraryType == 'group' && !Zotero.enablePDFBuildForGroups) {
if (this._changed.primaryData && this._changed.primaryData.itemTypeID
&& Zotero.ItemTypes.getName(itemTypeID) == 'annotation') {
throw new Error("Annotations can currently be created only in user libraries");
}
if (this._changed.attachmentData
&& this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_EMBEDDED_IMAGE) {
throw new Error("Embedded-image attachments can currently be created only in user libraries");
}
}
if (isNew || (this._changed.primaryData && this._changed.primaryData.dateAdded)) { if (isNew || (this._changed.primaryData && this._changed.primaryData.dateAdded)) {
env.sqlColumns.push('dateAdded'); env.sqlColumns.push('dateAdded');
env.sqlValues.push(this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime); env.sqlValues.push(this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime);

View file

@ -666,13 +666,6 @@ Zotero.Integration.Interface.prototype.addEditCitation = async function (docFiel
* @return {Promise} * @return {Promise}
*/ */
Zotero.Integration.Interface.prototype.addNote = async function () { Zotero.Integration.Interface.prototype.addNote = async function () {
if (!Zotero.isPDFBuild) {
let ps = Services.prompt;
let errorMessage = "To add notes to your document, you must enable the beta PDF reader "
+ "and note editor in the Zotero preferences.";
let index = ps.alert(null, Zotero.getString('general.error'), errorMessage);
throw new Zotero.Exception.UserCancelled('Cannot add notes with note editor disabled');
}
await this._session.init(false, false); await this._session.init(false, false);
if ((!await this._doc.canInsertField(this._session.data.prefs['fieldType']))) { if ((!await this._doc.canInsertField(this._session.data.prefs['fieldType']))) {

View file

@ -27,6 +27,8 @@
Zotero.OpenPDF = { Zotero.OpenPDF = {
openToPage: async function (pathOrItem, page, annotationKey) { openToPage: async function (pathOrItem, page, annotationKey) {
var handler = Zotero.Prefs.get("fileHandler.pdf");
var path; var path;
if (pathOrItem == 'string') { if (pathOrItem == 'string') {
Zotero.logError("Zotero.OpenPDF.openToPage() now takes a Zotero.Item rather than a path " Zotero.logError("Zotero.OpenPDF.openToPage() now takes a Zotero.Item rather than a path "
@ -36,8 +38,8 @@ Zotero.OpenPDF = {
else { else {
let item = pathOrItem; let item = pathOrItem;
let library = Zotero.Libraries.get(item.libraryID); let library = Zotero.Libraries.get(item.libraryID);
// TEMP // Zotero PDF reader
if (Zotero.isPDFBuild && (library.libraryType == 'user' || Zotero.enablePDFBuildForGroups)) { if (!handler) {
let location = { let location = {
annotationKey, annotationKey,
pageIndex: page && page - 1 pageIndex: page && page - 1
@ -53,10 +55,9 @@ Zotero.OpenPDF = {
} }
} }
var handler = Zotero.Prefs.get("fileHandler.pdf");
var opened = false; var opened = false;
if (handler) { if (handler != 'system') {
Zotero.debug(`Custom handler is ${handler}`); Zotero.debug(`Custom handler is ${handler}`);
} }
@ -72,7 +73,7 @@ Zotero.OpenPDF = {
opened = true; opened = true;
} }
else if (Zotero.isWin) { else if (Zotero.isWin) {
if (!handler) { if (handler == 'system') {
handler = this._getPDFHandlerWindows(); handler = this._getPDFHandlerWindows();
if (handler) { if (handler) {
Zotero.debug(`Default handler is ${handler}`); Zotero.debug(`Default handler is ${handler}`);
@ -92,7 +93,7 @@ Zotero.OpenPDF = {
} }
} }
else if (Zotero.isLinux) { else if (Zotero.isLinux) {
if (!handler) { if (handler == 'system') {
handler = await this._getPDFHandlerLinux(); handler = await this._getPDFHandlerLinux();
if (handler) { if (handler) {
Zotero.debug(`Resolved handler is ${handler}`); Zotero.debug(`Resolved handler is ${handler}`);

View file

@ -49,7 +49,7 @@ Zotero.Prefs = new function(){
if (!fromVersion) { if (!fromVersion) {
fromVersion = 0; fromVersion = 0;
} }
var toVersion = 3; var toVersion = 4;
if (fromVersion < toVersion) { if (fromVersion < toVersion) {
for (var i = fromVersion + 1; i <= toVersion; i++) { for (var i = fromVersion + 1; i <= toVersion; i++) {
switch (i) { switch (i) {
@ -78,10 +78,9 @@ Zotero.Prefs = new function(){
this.clear('note.fontSize'); this.clear('note.fontSize');
break; break;
// TEMP: Uncomment and set toVersion above to 3 when adding to prefs drop-down case 4:
//case 3: this.clear('fileHandler.pdf');
// this.clear('fileHandler.pdf'); break;
// break;
} }
} }
this.set('prefVersion', toVersion); this.set('prefVersion', toVersion);

View file

@ -260,9 +260,6 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
return; return;
} }
Zotero.isPDFBuild = Zotero.Prefs.get('beta.zotero6');
Zotero.enablePDFBuildForGroups = false;
try { try {
yield Zotero.DataDirectory.init(); yield Zotero.DataDirectory.init();
if (this.restarting) { if (this.restarting) {

View file

@ -69,13 +69,6 @@ var ZoteroPane = new function()
this.init = function () { this.init = function () {
Zotero.debug("Initializing Zotero pane"); Zotero.debug("Initializing Zotero pane");
if (!Zotero.isPDFBuild) {
let win = document.getElementById('main-window')
win.setAttribute('legacytoolbar', 'true');
document.getElementById('titlebar').hidden = true;
document.getElementById('tab-bar-container').hidden = true;
}
// Set key down handler // Set key down handler
document.addEventListener('keydown', ZoteroPane_Local.handleKeyDown, true); document.addEventListener('keydown', ZoteroPane_Local.handleKeyDown, true);
document.addEventListener('blur', ZoteroPane.handleBlur); document.addEventListener('blur', ZoteroPane.handleBlur);
@ -1224,12 +1217,9 @@ var ZoteroPane = new function()
} }
// Rename tab // Rename tab
if (Zotero.isPDFBuild) { Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName());
Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName());
}
let type = Zotero.Libraries.get(collectionTreeRow.ref.libraryID).libraryType; let type = Zotero.Libraries.get(collectionTreeRow.ref.libraryID).libraryType;
ZoteroItemPane.switchEditorEngine(type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild);
// Clear quick search and tag selector when switching views // Clear quick search and tag selector when switching views
document.getElementById('zotero-tb-search').value = ""; document.getElementById('zotero-tb-search').value = "";
@ -3334,7 +3324,7 @@ var ZoteroPane = new function()
this.openNoteWindow = function (itemID, col, parentKey) { this.openNoteWindow = function (itemID, col, parentKey) {
var item = Zotero.Items.get(itemID); var item = Zotero.Items.get(itemID);
var type = Zotero.Libraries.get(item.libraryID).libraryType; var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.canEdit() && (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild)) { if (!this.canEdit()) {
this.displayCannotEditLibraryMessage(); this.displayCannotEditLibraryMessage();
return; return;
} }
@ -3371,25 +3361,12 @@ var ZoteroPane = new function()
} }
} }
}; };
this.onNoteWindowClosed = async function (itemID, noteText) {
var item = Zotero.Items.get(itemID);
item.setNote(noteText);
await item.saveTx();
// If note is still selected, show the editor again when the note window closes
var selectedItems = this.getSelectedItems(true);
if (selectedItems.length == 1 && itemID == selectedItems[0]) {
ZoteroItemPane.onNoteSelected(item, this.collectionsView.editable);
}
};
this.openBackupNoteWindow = function (itemID) { this.openBackupNoteWindow = function (itemID) {
var item = Zotero.Items.get(itemID); var item = Zotero.Items.get(itemID);
var type = Zotero.Libraries.get(item.libraryID).libraryType; var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.canEdit() && (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild)) { if (!this.canEdit()) {
this.displayCannotEditLibraryMessage(); this.displayCannotEditLibraryMessage();
return; return;
} }
@ -3866,10 +3843,10 @@ var ZoteroPane = new function()
} }
else if (item.isNote()) { else if (item.isNote()) {
var type = Zotero.Libraries.get(item.libraryID).libraryType; var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.collectionsView.editable && (type == 'group' && !Zotero.enablePDFBuildForGroups || !Zotero.isPDFBuild)) { if (!this.collectionsView.editable) {
continue; continue;
} }
document.getElementById('zotero-view-note-button').doCommand(); ZoteroItemPane.openNoteWindow();
} }
else if (item.isAttachment()) { else if (item.isAttachment()) {
yield this.viewAttachment(item.id, event); yield this.viewAttachment(item.id, event);
@ -3899,12 +3876,12 @@ var ZoteroPane = new function()
await item.saveTx(); await item.saveTx();
} }
} }
// Custom PDF handler
if (contentType === 'application/pdf') { if (contentType === 'application/pdf') {
let item = await Zotero.Items.getAsync(itemID); let item = await Zotero.Items.getAsync(itemID);
let library = Zotero.Libraries.get(item.libraryID); let library = Zotero.Libraries.get(item.libraryID);
// TEMP let pdfHandler = Zotero.Prefs.get("fileHandler.pdf");
if (Zotero.isPDFBuild && (library.libraryType == 'user' || Zotero.enablePDFBuildForGroups)) { // Zotero PDF reader
if (!pdfHandler) {
await Zotero.Reader.open( await Zotero.Reader.open(
itemID, itemID,
extraData && extraData.location, extraData && extraData.location,
@ -3912,15 +3889,18 @@ var ZoteroPane = new function()
); );
return; return;
} }
let pdfHandler = Zotero.Prefs.get("fileHandler.pdf"); // Custom PDF handler
if (pdfHandler) { if (pdfHandler != 'system') {
if (await OS.File.exists(pdfHandler)) { try {
Zotero.launchFileWithApplication(path, pdfHandler); if (await OS.File.exists(pdfHandler)) {
return; Zotero.launchFileWithApplication(path, pdfHandler);
return;
}
} }
else { catch (e) {
Zotero.logError(`${pdfHandler} not found -- launching file normally`); Zotero.logError(e);
} }
Zotero.logError(`${pdfHandler} not found -- launching file normally`);
} }
} }
Zotero.launchFile(path); Zotero.launchFile(path);

View file

@ -50,7 +50,6 @@
<!ENTITY zotero.tabs.attachments.label "Attachments"> <!ENTITY zotero.tabs.attachments.label "Attachments">
<!ENTITY zotero.tabs.tags.label "Tags"> <!ENTITY zotero.tabs.tags.label "Tags">
<!ENTITY zotero.tabs.related.label "Related"> <!ENTITY zotero.tabs.related.label "Related">
<!ENTITY zotero.notes.separate "Edit in a separate window">
<!ENTITY zotero.toolbar.duplicate.label "Show Duplicates"> <!ENTITY zotero.toolbar.duplicate.label "Show Duplicates">
<!ENTITY zotero.collections.showUnfiledItems "Show Unfiled Items"> <!ENTITY zotero.collections.showUnfiledItems "Show Unfiled Items">

View file

@ -394,7 +394,6 @@ pane.item.notes.allNotes = All Notes
pane.item.notes.untitled = Untitled Note pane.item.notes.untitled = Untitled Note
pane.item.notes.delete.confirm = Are you sure you want to delete this note? pane.item.notes.delete.confirm = Are you sure you want to delete this note?
pane.item.notes.count = %1$S note;%1$S notes pane.item.notes.count = %1$S note;%1$S notes
pane.item.notes.editingInWindow = Editing in separate window
pane.item.notes.ignoreMissingImage = Some note images are missing and cannot be copied. pane.item.notes.ignoreMissingImage = Some note images are missing and cannot be copied.
pane.item.attachments.rename.title = New title: pane.item.attachments.rename.title = New title:
pane.item.attachments.rename.renameAssociatedFile = Rename associated file pane.item.attachments.rename.renameAssociatedFile = Rename associated file

View file

@ -178,7 +178,6 @@ pref("extensions.zotero.pane.persist", "");
// Custom file handlers // Custom file handlers
pref("extensions.zotero.fileHandler.pdf", ""); pref("extensions.zotero.fileHandler.pdf", "");
pref("extensions.zotero.beta.zotero6", false);
// File/URL opening executable if launch() fails // File/URL opening executable if launch() fails
pref("extensions.zotero.fallbackLauncher.unix", "/usr/bin/xdg-open"); pref("extensions.zotero.fallbackLauncher.unix", "/usr/bin/xdg-open");

View file

@ -935,6 +935,10 @@ async function importPDFAttachment(parentItem, options = {}) {
async function createAnnotation(type, parentItem, options = {}) { async function createAnnotation(type, parentItem, options = {}) {
var annotation = new Zotero.Item('annotation'); var annotation = new Zotero.Item('annotation');
annotation.libraryID = parentItem.libraryID;
if (options.version != undefined) {
annotation.version = options.version;
}
annotation.parentID = parentItem.id; annotation.parentID = parentItem.id;
annotation.annotationType = type; annotation.annotationType = type;
if (type == 'highlight') { if (type == 'highlight') {
@ -958,13 +962,21 @@ async function createAnnotation(type, parentItem, options = {}) {
[314.4, 412.8, 556.2, 609.6] [314.4, 412.8, 556.2, 609.6]
] ]
}); });
if (options.createdByUserID) {
annotation.createdByUserID = options.createdByUserID;
}
if (options.isExternal) { if (options.isExternal) {
annotation.annotationIsExternal = options.isExternal; annotation.annotationIsExternal = options.isExternal;
} }
if (options.tags) { if (options.tags) {
annotation.setTags(options.tags); annotation.setTags(options.tags);
} }
await annotation.saveTx(); if (options.synced !== undefined) {
annotation.synced = options.synced;
}
await annotation.saveTx({
skipEditCheck: true
});
return annotation; return annotation;
} }

View file

@ -159,7 +159,6 @@ user_pref("dom.max_chrome_script_run_time", 0);
// It would be better to leave this on and handle it in Sinon's FakeXMLHttpRequest // It would be better to leave this on and handle it in Sinon's FakeXMLHttpRequest
user_pref("extensions.zotero.sync.server.compressData", false); user_pref("extensions.zotero.sync.server.compressData", false);
user_pref("extensions.zotero.automaticScraperUpdates", false); user_pref("extensions.zotero.automaticScraperUpdates", false);
user_pref("extensions.zotero.beta.zotero6", true);
user_pref("extensions.zotero.debug.log", $DEBUG); user_pref("extensions.zotero.debug.log", $DEBUG);
user_pref("extensions.zotero.debug.level", $DEBUG_LEVEL); user_pref("extensions.zotero.debug.level", $DEBUG_LEVEL);
user_pref("extensions.zotero.debug.time", $DEBUG); user_pref("extensions.zotero.debug.time", $DEBUG);

View file

@ -126,14 +126,13 @@ describe("Zotero.Annotations", function() {
exampleNote.libraryID = item.libraryID; exampleNote.libraryID = item.libraryID;
exampleImage.libraryID = item.libraryID; exampleImage.libraryID = item.libraryID;
// Disabled while group annotations are disabled group = await getGroup();
/*group = await getGroup();
exampleGroupHighlight.libraryID = group.libraryID; exampleGroupHighlight.libraryID = group.libraryID;
groupItem = await createDataObject('item', { libraryID: group.libraryID }); groupItem = await createDataObject('item', { libraryID: group.libraryID });
groupAttachment = await importFileAttachment( groupAttachment = await importFileAttachment(
'test.pdf', 'test.pdf',
{ libraryID: group.libraryID, parentID: groupItem.id } { libraryID: group.libraryID, parentID: groupItem.id }
);*/ );
}); });
describe("#toJSON()", function () { describe("#toJSON()", function () {
@ -236,11 +235,11 @@ describe("Zotero.Annotations", function() {
await annotation.eraseTx(); await annotation.eraseTx();
}); });
it.skip("should generate an object for a highlight by another user in a group library", async function () { it("should generate an object for a highlight by another user in a group library", async function () {
await Zotero.Users.setName(12345, 'Kate Smith'); await Zotero.Users.setName(12345, 'First Last');
var annotation = new Zotero.Item('annotation'); var annotation = new Zotero.Item('annotation');
annotation.libraryID = group.libraryID; annotation.libraryID = groupAttachment.libraryID;
annotation.key = exampleGroupHighlight.key; annotation.key = exampleGroupHighlight.key;
await annotation.loadPrimaryData(); await annotation.loadPrimaryData();
annotation.createdByUserID = 12345; annotation.createdByUserID = 12345;
@ -250,13 +249,17 @@ describe("Zotero.Annotations", function() {
let itemProp = 'annotation' + prop[0].toUpperCase() + prop.substr(1); let itemProp = 'annotation' + prop[0].toUpperCase() + prop.substr(1);
annotation[itemProp] = exampleGroupHighlightAlt[prop]; annotation[itemProp] = exampleGroupHighlightAlt[prop];
} }
await annotation.saveTx(); await annotation.saveTx({
skipEditCheck: true
});
var json = await Zotero.Annotations.toJSON(annotation); var json = await Zotero.Annotations.toJSON(annotation);
assert.isFalse(json.isAuthor); assert.isFalse(json.isAuthor);
assert.equal(json.authorName, 'Kate Smith'); assert.equal(json.authorName, 'First Last');
await annotation.eraseTx(); await annotation.eraseTx({
skipEditCheck: true
});
}); });
}); });