diff --git a/chrome/content/zotero/components/itemPane/notesList.jsx b/chrome/content/zotero/components/itemPane/notesList.jsx index f56389016f..d25c19292a 100644 --- a/chrome/content/zotero/components/itemPane/notesList.jsx +++ b/chrome/content/zotero/components/itemPane/notesList.jsx @@ -28,9 +28,9 @@ import cx from 'classnames'; const MAX_ALL_NOTES = 7; -const NoteRow = ({ title, body, date, onClick, parentItemType, parentTitle }) => { +const NoteRow = ({ title, body, date, onClick, onContextMenu, parentItemType, parentTitle }) => { return ( -
+
{ parentItemType ?
@@ -51,7 +51,7 @@ const NoteRow = ({ title, body, date, onClick, parentItemType, parentTitle }) => ); }; -const NotesList = forwardRef(({ onClick, onAddChildButtonDown, onAddStandaloneButtonDown }, ref) => { +const NotesList = forwardRef(({ onClick, onContextMenu, onAddChildButtonDown, onAddStandaloneButtonDown }, ref) => { const [notes, setNotes] = useState([]); const [expanded, setExpanded] = useState(false); const [hasParent, setHasParent] = useState(true); @@ -71,7 +71,8 @@ const NotesList = forwardRef(({ onClick, onAddChildButtonDown, onAddStandaloneBu
{!childNotes.length &&
{Zotero.getString('pane.context.noNotes')}
} - {childNotes.map(note => onClick(note.id)}/>)} + {childNotes.map(note => onClick(note.id)} onContextMenu={(event) => onContextMenu(note.id, event)}/>)} }
@@ -79,7 +80,9 @@ const NotesList = forwardRef(({ onClick, onAddChildButtonDown, onAddStandaloneBu
{!allNotes.length &&
{Zotero.getString('pane.context.noNotes')}
} - {(expanded ? allNotes : allNotes.slice(0, MAX_ALL_NOTES)).map(note => onClick(note.id)}/>)} + {(expanded ? allNotes : allNotes.slice(0, MAX_ALL_NOTES)) + .map(note => onClick(note.id)} onContextMenu={(event) => onContextMenu(note.id, event)}/>)} {!expanded && allNotes.length > MAX_ALL_NOTES &&
{ Zotero.getString('general.numMore', Zotero.Utilities.numberFormat([allNotes.length - MAX_ALL_NOTES], 0)) diff --git a/chrome/content/zotero/contextPane.js b/chrome/content/zotero/contextPane.js index 073f0b22fb..65a3ce6ed2 100644 --- a/chrome/content/zotero/contextPane.js +++ b/chrome/content/zotero/contextPane.js @@ -23,7 +23,7 @@ ***** END LICENSE BLOCK ***** */ -// TODO: Fix import/require related isues that might be +// TODO: Fix import/require related issues that might be // related with `require` not reusing the context var React = require('react'); var ReactDOM = require('react-dom'); @@ -537,6 +537,31 @@ var ZoteroContextPane = new function () { updateFromCache: () => _updateNotesList(true) }; + function _handleListPopupClick(id, event) { + switch (event.originalTarget.id) { + case 'context-pane-list-show-in-library': + ZoteroPane_Local.selectItem(id); + Zotero_Tabs.select('zotero-pane'); + break; + + case 'context-pane-list-edit-in-window': + ZoteroPane_Local.openNoteWindow(id); + break; + + case 'context-pane-list-delete': + var ps = Components.classes['@mozilla.org/embedcomp/prompt-service;1'] + .getService(Components.interfaces.nsIPromptService); + if (ps.confirm(null, '', Zotero.getString('pane.item.notes.delete.confirm'))) { + Zotero.Items.trashTx(id); + context.cachedNotes = context.cachedNotes.filter(x => x.id != id); + _updateNotesList(true); + } + break; + + default: + } + } + function _handleAddChildNotePopupClick(event) { switch (event.originalTarget.id) { case 'context-pane-add-child-note': @@ -571,6 +596,11 @@ var ZoteroContextPane = new function () { onClick={(id) => { _setPinnedNote(id); }} + onContextMenu={(id, event) => { + var popup = document.getElementById('context-pane-list-popup'); + popup.onclick = (event) => _handleListPopupClick(id, event); + popup.openPopupAtScreen(event.screenX, event.screenY); + }} onAddChildButtonDown={(event) => { var popup = document.getElementById('context-pane-add-child-note-button-popup'); popup.onclick = _handleAddChildNotePopupClick; diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index b5e140694a..75be06a7cb 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -643,6 +643,13 @@ + + + + + + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index 0b98f935e9..c1c9f53aa4 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -333,3 +333,4 @@ +