parent
a1206e8901
commit
6e49da1452
4 changed files with 47 additions and 6 deletions
|
@ -28,9 +28,9 @@ import cx from 'classnames';
|
||||||
|
|
||||||
const MAX_ALL_NOTES = 7;
|
const MAX_ALL_NOTES = 7;
|
||||||
|
|
||||||
const NoteRow = ({ title, body, date, onClick, parentItemType, parentTitle }) => {
|
const NoteRow = ({ title, body, date, onClick, onContextMenu, parentItemType, parentTitle }) => {
|
||||||
return (
|
return (
|
||||||
<div className={cx('note-row', { 'standalone-note-row': !parentItemType })} onClick={onClick}>
|
<div className={cx('note-row', { 'standalone-note-row': !parentItemType })} onClick={onClick} onContextMenu={onContextMenu}>
|
||||||
<div className="inner">
|
<div className="inner">
|
||||||
{ parentItemType
|
{ parentItemType
|
||||||
? <div className="parent-line">
|
? <div className="parent-line">
|
||||||
|
@ -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 [notes, setNotes] = useState([]);
|
||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
const [hasParent, setHasParent] = useState(true);
|
const [hasParent, setHasParent] = useState(true);
|
||||||
|
@ -71,7 +71,8 @@ const NotesList = forwardRef(({ onClick, onAddChildButtonDown, onAddStandaloneBu
|
||||||
<button onMouseDown={onAddChildButtonDown}>+</button>
|
<button onMouseDown={onAddChildButtonDown}>+</button>
|
||||||
</div>
|
</div>
|
||||||
{!childNotes.length && <div className="empty-row">{Zotero.getString('pane.context.noNotes')}</div>}
|
{!childNotes.length && <div className="empty-row">{Zotero.getString('pane.context.noNotes')}</div>}
|
||||||
{childNotes.map(note => <NoteRow key={note.id} {...note} onClick={() => onClick(note.id)}/>)}
|
{childNotes.map(note => <NoteRow key={note.id} {...note}
|
||||||
|
onClick={() => onClick(note.id)} onContextMenu={(event) => onContextMenu(note.id, event)}/>)}
|
||||||
</section>}
|
</section>}
|
||||||
<section>
|
<section>
|
||||||
<div className="header-row">
|
<div className="header-row">
|
||||||
|
@ -79,7 +80,9 @@ const NotesList = forwardRef(({ onClick, onAddChildButtonDown, onAddStandaloneBu
|
||||||
<button onMouseDown={onAddStandaloneButtonDown}>+</button>
|
<button onMouseDown={onAddStandaloneButtonDown}>+</button>
|
||||||
</div>
|
</div>
|
||||||
{!allNotes.length && <div className="empty-row">{Zotero.getString('pane.context.noNotes')}</div>}
|
{!allNotes.length && <div className="empty-row">{Zotero.getString('pane.context.noNotes')}</div>}
|
||||||
{(expanded ? allNotes : allNotes.slice(0, MAX_ALL_NOTES)).map(note => <NoteRow key={note.id} {...note} onClick={() => onClick(note.id)}/>)}
|
{(expanded ? allNotes : allNotes.slice(0, MAX_ALL_NOTES))
|
||||||
|
.map(note => <NoteRow key={note.id} {...note}
|
||||||
|
onClick={() => onClick(note.id)} onContextMenu={(event) => onContextMenu(note.id, event)}/>)}
|
||||||
{!expanded && allNotes.length > MAX_ALL_NOTES
|
{!expanded && allNotes.length > MAX_ALL_NOTES
|
||||||
&& <div className="more-row" onClick={handleClickMore}>{
|
&& <div className="more-row" onClick={handleClickMore}>{
|
||||||
Zotero.getString('general.numMore', Zotero.Utilities.numberFormat([allNotes.length - MAX_ALL_NOTES], 0))
|
Zotero.getString('general.numMore', Zotero.Utilities.numberFormat([allNotes.length - MAX_ALL_NOTES], 0))
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
***** END LICENSE BLOCK *****
|
***** 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
|
// related with `require` not reusing the context
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
var ReactDOM = require('react-dom');
|
var ReactDOM = require('react-dom');
|
||||||
|
@ -537,6 +537,31 @@ var ZoteroContextPane = new function () {
|
||||||
updateFromCache: () => _updateNotesList(true)
|
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) {
|
function _handleAddChildNotePopupClick(event) {
|
||||||
switch (event.originalTarget.id) {
|
switch (event.originalTarget.id) {
|
||||||
case 'context-pane-add-child-note':
|
case 'context-pane-add-child-note':
|
||||||
|
@ -571,6 +596,11 @@ var ZoteroContextPane = new function () {
|
||||||
onClick={(id) => {
|
onClick={(id) => {
|
||||||
_setPinnedNote(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) => {
|
onAddChildButtonDown={(event) => {
|
||||||
var popup = document.getElementById('context-pane-add-child-note-button-popup');
|
var popup = document.getElementById('context-pane-add-child-note-button-popup');
|
||||||
popup.onclick = _handleAddChildNotePopupClick;
|
popup.onclick = _handleAddChildNotePopupClick;
|
||||||
|
|
|
@ -643,6 +643,13 @@
|
||||||
<menuitem id="context-pane-add-standalone-note" label="&zotero.context.addStandaloneNote;"/>
|
<menuitem id="context-pane-add-standalone-note" label="&zotero.context.addStandaloneNote;"/>
|
||||||
<menuitem id="context-pane-add-standalone-note-from-annotations" label="&zotero.context.addStandaloneNoteFromAnnotations;"/>
|
<menuitem id="context-pane-add-standalone-note-from-annotations" label="&zotero.context.addStandaloneNoteFromAnnotations;"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
|
|
||||||
|
<menupopup id="context-pane-list-popup">
|
||||||
|
<menuitem id="context-pane-list-show-in-library" label="&zotero.items.menu.showInLibrary;"/>
|
||||||
|
<menuitem id="context-pane-list-edit-in-window" label="&zotero.context.editInWindow;"/>
|
||||||
|
<menuseparator/>
|
||||||
|
<menuitem id="context-pane-list-delete" label="&zotero.general.delete;"/>
|
||||||
|
</menupopup>
|
||||||
</popupset>
|
</popupset>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
|
|
|
@ -333,3 +333,4 @@
|
||||||
<!ENTITY zotero.context.addChildNoteFromAnnotations "Add Item Note from Annotations">
|
<!ENTITY zotero.context.addChildNoteFromAnnotations "Add Item Note from Annotations">
|
||||||
<!ENTITY zotero.context.addStandaloneNote "Add Standalone Note">
|
<!ENTITY zotero.context.addStandaloneNote "Add Standalone Note">
|
||||||
<!ENTITY zotero.context.addStandaloneNoteFromAnnotations "Add Standalone Note from Annotations">
|
<!ENTITY zotero.context.addStandaloneNoteFromAnnotations "Add Standalone Note from Annotations">
|
||||||
|
<!ENTITY zotero.context.editInWindow "Edit in a Separate Window">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue