Skip to content

Commit

Permalink
Restore "Add to Note" to text selection popup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Aug 22, 2023
1 parent af16c66 commit e805413
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/common/components/reader-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function View(props) {
{state[name + 'ViewSelectionPopup'] && !state.readOnly &&
<SelectionPopup
params={state[name + 'ViewSelectionPopup']}
enableAddToNote={state.enableAddToNote}
onAddToNote={props.onAddToNote}
onAddAnnotation={props.onAddAnnotation}
/>
Expand Down
6 changes: 5 additions & 1 deletion src/common/components/view/selection-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ function SelectionPopup(props) {
props.onAddAnnotation({ ...props.params.annotation, color });
}

function handleAddToNote() {
props.onAddToNote([props.params.annotation]);
}

return (
<ViewPopup
className="selection-popup"
Expand All @@ -28,7 +32,7 @@ function SelectionPopup(props) {
/>))}
</div>
{props.enableAddToNote &&
<div className="wide-button" data-tabstop={true} onClick={props.onAddToNote}>
<div className="wide-button" data-tabstop={true} onClick={handleAddToNote}>
<FormattedMessage id="pdfReader.addToNote"/>
</div>}
</ViewPopup>
Expand Down
3 changes: 2 additions & 1 deletion src/common/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Reader {
onCloseContextMenu={this.closeContextMenu.bind(this)}
onCloseLabelOverlay={this._handleLabelOverlayClose.bind(this)}
onEnterPassword={this.enterPassword.bind(this)}
onAddToNote={this._onAddToNote}
onAddToNote={(annotations) => { this._onAddToNote(annotations); this.setSelectedAnnotations([]); }}
onNavigate={this.navigate.bind(this)}
onUpdateOutline={outline => this._updateState({ outline })}
onRenderThumbnails={(pageIndexes) => this._primaryView._pdfThumbnails.render(pageIndexes)}
Expand Down Expand Up @@ -1016,6 +1016,7 @@ class Reader {
this._lastView.navigateToNextSection();
}

// Note: It's a bit weird, but this function is also used to deselect text in views, if an empty ids array is provided
setSelectedAnnotations(ids, triggeredFromView, triggeringEvent) {
let deleteIDs = [];
for (let annotation of this._state.annotations) {
Expand Down

0 comments on commit e805413

Please sign in to comment.