aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/AnchorMenu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf/AnchorMenu.tsx')
-rw-r--r--src/client/views/pdf/AnchorMenu.tsx171
1 files changed, 76 insertions, 95 deletions
diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx
index 5480600b0..07b2afd91 100644
--- a/src/client/views/pdf/AnchorMenu.tsx
+++ b/src/client/views/pdf/AnchorMenu.tsx
@@ -15,6 +15,8 @@ import { GPTPopup, GPTPopupMode } from './GPTPopup/GPTPopup';
import { LightboxView } from '../LightboxView';
import { EditorView } from 'prosemirror-view';
import './AnchorMenu.scss';
+import { ColorPicker, Group, IconButton, Popup, Size, Toggle, ToggleType, Type } from 'browndash-components';
+import { StrCast } from '../../../fields/Types';
@observer
export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
@@ -42,7 +44,6 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
];
@observable private highlightColor: string = 'rgba(245, 230, 95, 0.616)';
- @observable private _showLinkPopup: boolean = false;
@observable public Status: 'marquee' | 'annotation' | '' = '';
@@ -131,7 +132,6 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
() => this._opacity,
opacity => {
if (!opacity) {
- this._showLinkPopup = false;
this.setGPTPopupVis(false);
this.setGPTPopupText('');
}
@@ -141,7 +141,6 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
this._disposer = reaction(
() => SelectionManager.Views().slice(),
selected => {
- this._showLinkPopup = false;
this.setGPTPopupVis(false);
this.setGPTPopupText('');
AnchorMenu.Instance.fadeOut(true);
@@ -253,49 +252,25 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
AnchorMenu.Instance.fadeOut(true);
};
- @action
- toggleLinkPopup = (e: React.MouseEvent) => {
- //ignore the potential null type error because this method cannot be called unless the user selects text and clicks the link button
- //change popup visibility field to visible
- this._showLinkPopup = !this._showLinkPopup;
- };
-
@computed get highlighter() {
- const button = (
- <button className="antimodeMenu-button anchor-color-preview-button" title="" key="highlighter-button" onClick={this.highlightClicked}>
- <div className="anchor-color-preview">
- <FontAwesomeIcon icon="highlighter" size="lg" style={{ transition: 'transform 0.1s', transform: 'rotate(-45deg)' }} />
- <div className="color-preview" style={{ backgroundColor: this.highlightColor }}></div>
- </div>
- </button>
- );
-
- const dropdownContent = (
- <div className="dropdown">
- <p>Change highlighter color:</p>
- <div className="color-wrapper">
- {this._palette.map(color => {
- if (color) {
- return this.highlightColor === color ? (
- <button className="color-button active" key={`active ${color}`} style={{ backgroundColor: color }} onPointerDown={e => this.changeHighlightColor(color, e)}></button>
- ) : (
- <button className="color-button" key={`inactive ${color}`} style={{ backgroundColor: color }} onPointerDown={e => this.changeHighlightColor(color, e)}></button>
- );
- }
- })}
- </div>
- </div>
- );
- return (
- <Tooltip key="highlighter" title={<div className="dash-tooltip">{'Click to Highlight'}</div>}>
- <div className="anchorMenu-highlighter">
- <ButtonDropdown key={'highlighter'} button={button} dropdownContent={dropdownContent} pdf={true} />
- </div>
- </Tooltip>
- );
+ return <Group>
+ <IconButton
+ icon={<FontAwesomeIcon icon="highlighter" style={{ transition: 'transform 0.1s', transform: 'rotate(-45deg)' }} />}
+ tooltip={'Click to Highlight'}
+ onClick={this.highlightClicked}
+ colorPicker={this.highlightColor}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
+ <ColorPicker
+ colorPickerType={'github'}
+ selectedColor={this.highlightColor}
+ setSelectedColor={color => this.changeHighlightColor(color)}
+ size={Size.XSMALL}
+ />
+ </Group>
}
- @action changeHighlightColor = (color: string, e: React.PointerEvent) => {
+ @action changeHighlightColor = (color: string) => {
const col: ColorState = {
hex: color,
hsl: { a: 0, h: 0, s: 0, l: 0, source: '' },
@@ -304,8 +279,6 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
oldHue: 0,
source: '',
};
- e.preventDefault();
- e.stopPropagation();
this.highlightColor = Utils.colorString(col);
};
@@ -339,11 +312,12 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
this.Status === 'marquee' ? (
<>
{this.highlighter}
- <Tooltip key="annotate" title={<div className="dash-tooltip">Drag to Place Annotation</div>}>
- <button className="antimodeMenu-button annotate" ref={this._commentCont} onPointerDown={this.pointerDown} style={{ cursor: 'grab' }}>
- <FontAwesomeIcon icon="comment-alt" size="lg" />
- </button>
- </Tooltip>
+ <IconButton
+ tooltip={'Drag to Place Annotation'}
+ onPointerDown={this.pointerDown}
+ icon={<FontAwesomeIcon icon="comment-alt"/>}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
{/* GPT Summarize icon only shows up when text is highlighted, not on marquee selection*/}
{AnchorMenu.Instance.StartCropDrag === unimplementedFunction && this.canSummarize() && (
<Tooltip key="gpt" title={<div className="dash-tooltip">Summarize with AI</div>}>
@@ -364,59 +338,66 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
mode={this.GPTMode}
/>
{AnchorMenu.Instance.OnAudio === unimplementedFunction ? null : (
- <Tooltip key="annoaudiotate" title={<div className="dash-tooltip">Click to Record Annotation</div>}>
- <button className="antimodeMenu-button annotate" onPointerDown={this.audioDown} style={{ cursor: 'grab' }}>
- <FontAwesomeIcon icon="microphone" size="lg" />
- </button>
- </Tooltip>
+ <IconButton
+ tooltip={'Click to Record Annotation'}
+ onPointerDown={this.audioDown}
+ icon={<FontAwesomeIcon icon="microphone" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
)}
{this.canEdit() && (
- <Tooltip key="gpttextedit" title={<div className="dash-tooltip">AI edit suggestions</div>}>
- <button className="antimodeMenu-button annotate" onPointerDown={this.gptEdit} style={{ cursor: 'grab' }}>
- <FontAwesomeIcon icon="pencil-alt" size="lg" />
- </button>
- </Tooltip>
+ <IconButton
+ tooltip={'AI edit suggestions'}
+ onPointerDown={this.gptEdit}
+ icon={<FontAwesomeIcon icon="pencil-alt" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
)}
- <Tooltip key="link" title={<div className="dash-tooltip">Find document to link to selected text</div>}>
- <button className="antimodeMenu-button link" onPointerDown={this.toggleLinkPopup}>
- <FontAwesomeIcon style={{ position: 'absolute', transform: 'scale(1.5)' }} icon={'search'} size="lg" />
- <FontAwesomeIcon style={{ position: 'absolute', transform: 'scale(0.5)', transformOrigin: 'top left', top: 12, left: 12 }} icon={'link'} size="lg" />
- </button>
- </Tooltip>
- <LinkPopup key="popup" showPopup={this._showLinkPopup} linkCreateAnchor={this.onMakeAnchor} />,
+ <Popup
+ tooltip='Find document to link to selected text'
+ type={Type.PRIM}
+ icon={<FontAwesomeIcon icon={'search'} />}
+ popup={<LinkPopup key="popup" linkCreateAnchor={this.onMakeAnchor} />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
{AnchorMenu.Instance.StartCropDrag === unimplementedFunction ? null : (
- <Tooltip key="crop" title={<div className="dash-tooltip">Click/Drag to create cropped image</div>}>
- <button className="antimodeMenu-button annotate" onPointerDown={this.cropDown} style={{ cursor: 'grab' }}>
- <FontAwesomeIcon icon="image" size="lg" />
- </button>
- </Tooltip>
+ <IconButton
+ tooltip={'Click/Drag to create cropped image'}
+ onPointerDown={this.cropDown}
+ icon={<FontAwesomeIcon icon="image"/>}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />
)}
</>
) : (
<>
- <Tooltip key="trash" title={<div className="dash-tooltip">Remove Link Anchor</div>}>
- <button className="antimodeMenu-button" style={{ display: this.Delete === returnFalse ? 'none' : undefined }} onPointerDown={this.Delete}>
- <FontAwesomeIcon icon="trash-alt" size="lg" />
- </button>
- </Tooltip>
- <Tooltip key="Pin" title={<div className="dash-tooltip">Pin to Presentation</div>}>
- <button className="antimodeMenu-button" style={{ display: this.PinToPres === returnFalse ? 'none' : undefined }} onPointerDown={this.PinToPres}>
- <FontAwesomeIcon icon="map-pin" size="lg" />
- </button>
- </Tooltip>
- <Tooltip key="trail" title={<div className="dash-tooltip">Show Linked Trail</div>}>
- <button className="antimodeMenu-button" style={{ display: this.ShowTargetTrail === returnFalse ? 'none' : undefined }} onPointerDown={this.ShowTargetTrail}>
- <FontAwesomeIcon icon="taxi" size="lg" />
- </button>
- </Tooltip>
- <Tooltip key="toggle" title={<div className="dash-tooltip">make target visibility toggle on click</div>}>
- <button
- className="antimodeMenu-button"
- style={{ display: this.IsTargetToggler === returnFalse ? 'none' : undefined, color: this.IsTargetToggler() ? 'black' : 'white', backgroundColor: this.IsTargetToggler() ? 'white' : 'black' }}
- onPointerDown={this.MakeTargetToggle}>
- <FontAwesomeIcon icon="thumbtack" size="lg" />
- </button>
- </Tooltip>
+ {this.Delete !== returnFalse && <IconButton
+ tooltip={'Remove Link Anchor'}
+ onPointerDown={this.Delete}
+ icon={<FontAwesomeIcon icon="trash-alt" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />}
+ {this.PinToPres !== returnFalse && <IconButton
+ tooltip={'Pin to Presentation'}
+ onPointerDown={this.PinToPres}
+ icon={<FontAwesomeIcon icon="map-pin" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />}
+ {this.ShowTargetTrail !== returnFalse && <IconButton
+ tooltip={'Show Linked Trail'}
+ onPointerDown={this.ShowTargetTrail}
+ icon={<FontAwesomeIcon icon="taxi" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />}
+ {this.IsTargetToggler !== returnFalse && <Toggle
+ tooltip={'Make target visibility toggle on click'}
+ type={Type.PRIM}
+ toggleType={ToggleType.BUTTON}
+ toggleStatus={this.IsTargetToggler()}
+ onClick={this.MakeTargetToggle}
+ icon={<FontAwesomeIcon icon="thumbtack" />}
+ color={StrCast(Doc.UserDoc().userColor)}
+ />}
</>
);