aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/AnchorMenu.scss14
-rw-r--r--src/client/views/pdf/GPTPopup/GPTPopup.scss10
-rw-r--r--src/client/views/pdf/GPTPopup/GPTPopup.tsx30
-rw-r--r--src/client/views/pdf/PDFViewer.scss13
-rw-r--r--src/client/views/pdf/PDFViewer.tsx6
5 files changed, 34 insertions, 39 deletions
diff --git a/src/client/views/pdf/AnchorMenu.scss b/src/client/views/pdf/AnchorMenu.scss
index 6990bdcf1..98eeaf80e 100644
--- a/src/client/views/pdf/AnchorMenu.scss
+++ b/src/client/views/pdf/AnchorMenu.scss
@@ -6,19 +6,19 @@
}
.anchorMenu-highlighter {
padding-right: 5px;
- .antimodeMenu-button {
- padding: 0;
- padding: 0;
+ .antimodeMenu-button {
+ padding: 0px;
+ padding: 0px;
padding-right: 0px;
padding-left: 0px;
width: 5px;
}
}
-.anchor-color-preview-button {
- width: 25px !important;
+.anchor-color-preview-button {
+ width: 25px !important;
.anchor-color-preview {
display: flex;
- flex-direction: column;
+ flex-direction: column;
padding-right: 3px;
width: unset !important;
.color-preview {
@@ -51,4 +51,4 @@
border: 2px solid white;
}
}
-} \ No newline at end of file
+}
diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.scss b/src/client/views/pdf/GPTPopup/GPTPopup.scss
index f6fa45221..85c1f6759 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.scss
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.scss
@@ -20,8 +20,8 @@ $headingHeight: 32px;
left: 75px;
width: 100%;
height: 100%;
- top: 0;
- left: 0;
+ top: 0px;
+ left: 0px;
border-top: solid gray 20px;
border-radius: 16px;
z-index: 999;
@@ -58,7 +58,7 @@ $headingHeight: 32px;
font-size: 12px;
font-weight: 400;
letter-spacing: 1px;
- margin: 0;
+ margin: 0px;
padding-right: 5px;
}
@@ -214,8 +214,8 @@ $headingHeight: 32px;
.img-container::after {
content: '';
position: absolute;
- top: 0;
- left: 0;
+ top: 0px;
+ left: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
index 568e48edf..9c37428ee 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
@@ -11,7 +11,7 @@ import { ClientUtils } from '../../../../ClientUtils';
import { Doc } from '../../../../fields/Doc';
import { NumCast, StrCast } from '../../../../fields/Types';
import { Networking } from '../../../Network';
-import { DescriptionSeperator, DocSeperator, GPTCallType, GPTDocCommand, gptAPICall, gptImageCall } from '../../../apis/gpt/GPT';
+import { DataSeperator, DescriptionSeperator, DocSeperator, GPTCallType, GPTDocCommand, gptAPICall, gptImageCall } from '../../../apis/gpt/GPT';
import { DocUtils } from '../../../documents/DocUtils';
import { Docs } from '../../../documents/Documents';
import { SettingsManager } from '../../../util/SettingsManager';
@@ -90,7 +90,7 @@ export class GPTPopup extends ObservableReactComponent<object> {
if (hasChildDocs) {
this._textToDocMap.clear();
this.setCollectionContext(selDoc.Document);
- this.onGptResponse = (sortResult: string, questionType: GPTDocCommand, args?: string) => this.processGptResponse(selDoc, this._textToDocMap, sortResult, questionType, args);
+ this.onGptResponse = (sortResult: string, questionType: GPTDocCommand) => this.processGptResponse(selDoc, this._textToDocMap, sortResult, questionType);
this.onQuizRandom = () => this.randomlyChooseDoc(selDoc.Document, hasChildDocs());
this._documentDescriptions = Promise.all(hasChildDocs().map(doc =>
Doc.getDescription(doc).then(text => this._textToDocMap.set(text.replace(/\n/g, ' ').trim(), doc) && `${DescriptionSeperator}${text}${DescriptionSeperator}`)
@@ -134,7 +134,7 @@ export class GPTPopup extends ObservableReactComponent<object> {
* @param questionType
* @param tag
*/
- processGptResponse = (docView: DocumentView, textToDocMap: Map<string, Doc>, gptOutput: string, questionType: GPTDocCommand, args?: string) =>
+ processGptResponse = (docView: DocumentView, textToDocMap: Map<string, Doc>, gptOutput: string, questionType: GPTDocCommand) =>
undoable(() => {
switch (questionType) { // reset collection based on question typefc
case GPTDocCommand.Sort:
@@ -145,20 +145,17 @@ export class GPTPopup extends ObservableReactComponent<object> {
break;
} // prettier-ignore
- gptOutput.split('======').filter(item => item.trim() !== '') // Split output into individual document contents
- .map(docContentRaw => textToDocMap.get(docContentRaw.replace(/\n/g, ' ').trim())) // the find the corresponding Doc using textToDoc map
- .filter(doc => doc).map(doc => doc!) // filter out undefined values
- .forEach((doc, index) => {
+ gptOutput.split(DescriptionSeperator).filter(item => item.trim() !== '') // Split output into individual document contents
+ .map(docContentRaw => docContentRaw.replace(/\n/g, ' ').trim())
+ .map(docContentRaw => ({doc: textToDocMap.get(docContentRaw.split(DataSeperator)[0]), data: docContentRaw.split(DataSeperator)[1] })) // the find the corresponding Doc using textToDoc map
+ .filter(({doc}) => doc).map(({doc, data}) => ({doc:doc!, data})) // filter out undefined values
+ .forEach(({doc, data}, index) => {
switch (questionType) {
case GPTDocCommand.Sort:
doc[ChatSortField] = index;
break;
case GPTDocCommand.AssignTags:
- if (args) {
- const hashTag = args.startsWith('#') ? args : '#' + args[0].toLowerCase() + args.slice(1);
- const filterTag = Doc.MyFilterHotKeys.map(key => StrCast(key.toolType)).find(key => key.includes(args)) ?? hashTag;
- TagItem.addTagToDoc(doc, filterTag);
- }
+ data && TagItem.addTagToDoc(doc, data.startsWith('#') ? data : '#'+data[0].toLowerCase()+data.slice(1) );
break;
case GPTDocCommand.Filter:
TagItem.addTagToDoc(doc, GPTPopup.ChatTag);
@@ -238,10 +235,10 @@ export class GPTPopup extends ObservableReactComponent<object> {
* @param userPrompt the user's input that chat will respond to
*/
generateUserPromptResponse = (userPrompt: string) =>
- gptAPICall(userPrompt, GPTCallType.COMMANDTYPE, undefined, true).then((commandType, args = commandType.split(' ').slice(1).join(' ')) =>
+ gptAPICall(userPrompt, GPTCallType.COMMANDTYPE, undefined, true).then(commandType =>
(async () => {
switch (this.NumberToCommandType(commandType)) {
- case GPTDocCommand.AssignTags:
+ case GPTDocCommand.AssignTags:return this._documentDescriptions?.then(descs => gptAPICall(userPrompt, GPTCallType.TAGDOCS, descs)) ?? "";
case GPTDocCommand.Filter: return this._documentDescriptions?.then(descs => gptAPICall(userPrompt, GPTCallType.SUBSETDOCS, descs)) ?? "";
case GPTDocCommand.Sort: return this._documentDescriptions?.then(descs => gptAPICall(userPrompt, GPTCallType.SORTDOCS, descs)) ?? "";
default: return Doc.getDescription(DocumentView.SelectedDocs().lastElement()).then(desc => gptAPICall(userPrompt, GPTCallType.DOCINFO, desc));
@@ -249,7 +246,7 @@ export class GPTPopup extends ObservableReactComponent<object> {
})().then(
action(res => {
// Trigger the callback with the result
- this.onGptResponse?.(res || 'Something went wrong :(', this.NumberToCommandType(commandType), args);
+ this.onGptResponse?.(res || 'Something went wrong :(', this.NumberToCommandType(commandType));
this._conversationArray.push(
this.NumberToCommandType(commandType) === GPTDocCommand.GetInfo ? res:
// Extract explanation surrounded by the DocSeperator string (defined in GPT.ts) at the top or both at the top and bottom
@@ -515,6 +512,7 @@ export class GPTPopup extends ObservableReactComponent<object> {
</div>
);
+ setDictationRef = (r: DictationButton | null) => (this._askDictation = r);
promptBox = (heading: string, value: string, onChange: (e: string) => string, placeholder: string) => (
<>
<div className="gptPopup-sortBox">
@@ -541,7 +539,7 @@ export class GPTPopup extends ObservableReactComponent<object> {
background={SettingsManager.userVariantColor}
onClick={() => this.callGpt(this._mode)}
/>
- <DictationButton ref={r => (this._askDictation = r)} setInput={onChange} />
+ <DictationButton ref={this.setDictationRef} setInput={onChange} />
</div>
</>
);
diff --git a/src/client/views/pdf/PDFViewer.scss b/src/client/views/pdf/PDFViewer.scss
index 1aab2b853..dafa908a2 100644
--- a/src/client/views/pdf/PDFViewer.scss
+++ b/src/client/views/pdf/PDFViewer.scss
@@ -3,8 +3,8 @@
width: 100%;
position: absolute;
display: inline-block;
- top: 0;
- left: 0;
+ top: 0px;
+ left: 0px;
}
:root {
@@ -16,8 +16,8 @@
position: absolute;
width: 100%;
height: 100%;
- top: 0;
- left: 0;
+ top: 0px;
+ left: 0px;
position: absolute;
overflow-y: auto;
overflow-x: hidden;
@@ -99,7 +99,7 @@
.pdfViewerDash-annotationLayer {
position: absolute;
transform-origin: left top;
- top: 0;
+ top: 0px;
width: 100%;
pointer-events: none;
mix-blend-mode: multiply; // bcz: makes text fuzzy!
@@ -118,6 +118,9 @@
.pdfViewerDash-interactive {
pointer-events: all;
+ &::-webkit-scrollbar {
+ width: 40px;
+ }
}
.loading-spinner {
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index a88d8b282..616e2119f 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -901,12 +901,6 @@ export class PDFViewer extends ObservableReactComponent<IViewerProps> {
@action
onPointerDown = (e: React.PointerEvent): void => {
- // const hit = document.elementFromPoint(e.clientX, e.clientY);
- // bcz: Change. drag selecting requires that preventDefault is NOT called. This used to happen in DocumentView,
- // but that's changed, so this shouldn't be needed.
- // if (hit && hit.localName === "span" && this.annotationsActive(true)) { // drag selecting text stops propagation
- // e.button === 0 && e.stopPropagation();
- // }
// if alt+left click, drag and annotate
this._downX = e.clientX;
this._downY = e.clientY;