diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/apis/gpt/GPT.ts | 8 | ||||
-rw-r--r-- | src/client/documents/Documents.ts | 2 | ||||
-rw-r--r-- | src/client/util/CurrentUserUtils.ts | 79 | ||||
-rw-r--r-- | src/client/util/Scripting.ts | 4 | ||||
-rw-r--r-- | src/client/views/FilterPanel.scss | 12 | ||||
-rw-r--r-- | src/client/views/FilterPanel.tsx | 145 | ||||
-rw-r--r-- | src/client/views/PropertiesView.tsx | 2 | ||||
-rw-r--r-- | src/client/views/StyleProvider.tsx | 6 | ||||
-rw-r--r-- | src/client/views/collections/CollectionCardDeckView.tsx | 41 | ||||
-rw-r--r-- | src/client/views/global/globalScripts.ts | 240 | ||||
-rw-r--r-- | src/client/views/nodes/IconTagBox.tsx | 141 | ||||
-rw-r--r-- | src/client/views/pdf/GPTPopup/GPTPopup.tsx | 5 | ||||
-rw-r--r-- | src/typings/index.d.ts | 2 |
13 files changed, 129 insertions, 558 deletions
diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts index 0b1a5160c..2657bf12e 100644 --- a/src/client/apis/gpt/GPT.ts +++ b/src/client/apis/gpt/GPT.ts @@ -49,7 +49,6 @@ const callTypeMap: { [type: string]: GPTCallOpts } = { maxTokens: 2048, temp: 0.25, prompt: "The user is going to give you a list of descriptions. Each one is separated by `======` on either side. Descriptions will vary in length, so make sure to only separate when you see `======`. Sort them by the user's specifications. Make sure each description is only in the list once. Each item should be separated by `======`. Immediately afterward, surrounded by `------` on BOTH SIDES, provide some insight into your reasoning for the way you sorted (and mention nothing about the formatting details given in this description). It is VERY important that you format it exactly as described, ensuring the proper number of `=` and `-` (6 of each) and NO commas" - // prompt: "I'm going to give you a list of descriptions. Each one is separated by `======` on either side. Descriptions will vary in length, so make sure to only separate when you see `======`. Sort them into lists by shared content. Make sure each description is in only one list. Each list should be separated by `======` with the elements within it separated by `~~~~~~`. Immediately afterward, surrounded by `------` on BOTH SIDES, provide some insight into your reasoning for the way you sorted. It is VERY important that you format it exactly as described, ensuring the proper number of `=` `~` and `-` (6 of each) and no commas.Try to create around 4 groups, but a little more or less is ok. Also, I may provide some more insight after this colon:" }, describe: { model: 'gpt-4-vision-preview', maxTokens: 2048, temp: 0, prompt: 'Describe these images in 3-5 words' }, chatcard: { model: 'gpt-4-turbo', maxTokens: 512, temp: 0.5, prompt: 'Answer the following question as a short flashcard response. Do not include a label.' }, @@ -64,7 +63,7 @@ const callTypeMap: { [type: string]: GPTCallOpts } = { model: 'gpt-4-turbo', maxTokens: 1024, temp: 0, - prompt: "BRIEFLY (<75 words) provide a definition for the following term. It will be used as a rubric to evaluate the user's understanding of the topic", + prompt: "BRIEFLY (<25 words) provide a definition for the following term. It will be used as a rubric to evaluate the user's understanding of the topic", }, type: { @@ -106,11 +105,6 @@ const gptAPICall = async (inputTextIn: string, callType: GPTCallType, prompt?: a try { lastCall = inputText; - // const configuration: ClientOptions = { - // apiKey: process.env.OPENAI_KEY, - // dangerouslyAllowBrowser: true, - // }; - const usePrompt = prompt ? prompt + opts.prompt : opts.prompt; const messages: ChatCompletionMessageParam[] = [ { role: 'system', content: usePrompt }, diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 188f07991..83e236cba 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -493,8 +493,6 @@ export class DocumentOptions { // cardSort_visibleSortGroups?: List<number>; // which sorting values are being filtered (shown) cardSort_isDesc?: BOOLt = new BoolInfo('whether the cards are sorted ascending or descending'); // test?: STRt = new StrInfo('testing for filtering') - keywords?: MAPt = new MapInfo('keywords', true); - } export const DocOptions = new DocumentOptions(); diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 702d6e6e5..997d5c5a9 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -669,15 +669,10 @@ pie title Minerals in my tap water } static cardTools(): Button[] { return [ - // { btnList: new List<string>(["Time", "Type", "Color", "Chat GPT", "Custom 1", "Custom 2", "Custom 3" ]), - // title: "Sort Type", toolTip: "Card Sort Type", btnType: ButtonType.DropdownList, ignoreClick: true, width: 100, scripts: { script: '{ return setCardSort(value, _readOnly_); }'}}, - // { title: "Font", toolTip: "Font", width: 100, btnType: ButtonType.DropdownList, toolType:"font", ignoreClick: true, scripts: {script: '{ return setFontAttr(this.toolType, value, _readOnly_);}'}, - // btnList: new List<string>(["Roboto", "Roboto Mono", "Nunito", "Times New Roman", "Arial", "Georgia", "Comic Sans MS", "Tahoma", "Impact", "Crimson Text"]) }, { title: "Time", icon:"hourglass-half", toolTip:"Sort by most recent document creation", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"time", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, { title: "Type", icon:"eye", toolTip:"Sort by document type", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"docType",funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, { title: "Color", icon:"palette", toolTip:"Sort by document color", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"color", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, { title: "Tags", icon:"bolt", toolTip:"Sort by document's tags", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"tag", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "AI Sort", icon:"robot", toolTip:"Have Chat GPT sort your cards for you !", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"chat", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, { title: "Pile", icon:"layer-group", toolTip:"View the cards as a pile in the free form view !", btnType: ButtonType.ClickButton, expertMode: false, toolType:"pile", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, { title: "Chat Popup", icon:"lightbulb", toolTip:"Toggle the chat popup's visibility!", width: 45 ,btnType: ButtonType.ToggleButton, expertMode: false, toolType:"toggle-chat", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} }, @@ -686,62 +681,23 @@ pie title Minerals in my tap water { title: "Ascending", toolTip: "Sort the cards in ascending order", btnType: ButtonType.ToggleButton, icon: "sort-up", toolType:"up", ignoreClick: true, scripts: {onClick: '{ return showFreeform(this.toolType, _readOnly_);}' }}, { title: "Descending", toolTip: "Sort the cards in descending order",btnType: ButtonType.ToggleButton, icon: "sort-down",toolType:"down",ignoreClick: true, scripts: {onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} }, ]}, - - // { title: "Filter", icon:"Filter", toolTip:"Filter cards by tags", width: 150, subMenu: this.cardGroupTools(), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - - - - - - - // // { title: "AIs", icon:"Visibility", toolTip:"Filter AI labels", subMenu: this.cardGroupTools("robot"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("chat", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"heart", toolTip:"Add Like labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"like", funcs: {hidden:`showFreeform ("like", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "1st", icon:"Visibility", toolTip:"Filter likes", width: 150, subMenu: this.cardGroupTools("heart"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("like", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"star", toolTip:"Add Star labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"star", funcs: {hidden:`showFreeform ("star", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "2nd", icon:"Visibility", toolTip:"Filter stars", width: 150, subMenu: this.cardGroupTools("star"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("star", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"cloud", toolTip:"Add Idea labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"idea", funcs: {hidden:`showFreeform ("idea", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "3rd", icon:"Visibility", toolTip:"Filter ideas", width: 150, subMenu: this.cardGroupTools("cloud"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("idea", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, ] } - // static labelTools(): Button[] { - // return [ - // // { title: "Smart", icon:"robot", toolTip:"Have ChatGPT Label and sort your cards for you!", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"chat", funcs: {hidden:`showFreeform ("chat", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "AIs", icon:"AI Sort", toolTip:"Filter AI labels", subMenu: this.cardGroupTools("robot"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("chat", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"heart", toolTip:"Add Like labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"like", funcs: {hidden:`showFreeform ("like", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "1st", icon:"1st", toolTip:"Filter likes", width: 10, subMenu: this.cardGroupTools("heart"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("like", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"star", toolTip:"Add Star labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"star", funcs: {hidden:`showFreeform ("star", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "2nd", icon:"2nd", toolTip:"Filter stars", width: 80, subMenu: this.cardGroupTools("star"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("star", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"cloud", toolTip:"Add Idea labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"idea", funcs: {hidden:`showFreeform ("idea", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "3rd", icon:"3rd", toolTip:"Filter ideas", width: 80, subMenu: this.cardGroupTools("cloud"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("idea", true)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // ] - // } + static tagGroupTools(): Button[] { - if (!Doc.UserDoc().activeDashboard){ - Doc.UserDoc().myFilterHotKeyTitles = new List<string>(['Star', 'Heart', 'Bolt', 'Cloud' ]) - - Doc.UserDoc()['Star'] = 'star' - Doc.UserDoc()['Heart'] = 'heart' - Doc.UserDoc()['Bolt'] = 'bolt' - Doc.UserDoc()['Cloud'] = 'cloud' + if (!Doc.UserDoc().activeDashboard) { + Doc.UserDoc().myFilterHotKeyTitles = new List<string>(['Star', 'Heart', 'Bolt', 'Cloud']); - } - - + ['Star', 'Heart', 'Bolt', 'Cloud'].forEach(key => { + Doc.UserDoc()[key] = key.toLowerCase(); + }); +} // hack: if there's no dashboard, create default filters. otherwise, just make sure that the Options button is preserved return (Doc.UserDoc().activeDashboard ? [] : [ { title: "Star", isSystem: false, icon: "star", toolTip:"Click to toggle the star group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"star", funcs: {}, scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}'}}, { title: "Heart", isSystem: false,icon: "heart", toolTip:"Click to toggle the heart group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"heart", funcs: {}, scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}'}}, { title: "Bolt", isSystem: false,icon: "bolt", toolTip:"Click to toggle the bolt group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"bolt", funcs: {}, scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}'}}, { title: "Cloud", isSystem: false,icon: "cloud", toolTip:"Click to toggle the cloud group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"cloud", funcs: {}, scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}'}}, - - - // { title: "Group 1", icon, toolTip:"Click to toggle group 1's visibility", btnType: ButtonType.ToggleButton, width: 40, expertMode: false, toolType:"1", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Group 2", icon, toolTip:"Click to toggle group 2's visibility", btnType: ButtonType.ToggleButton, width: 40, expertMode: false, toolType:"2", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Group 3", icon, toolTip:"Click to toggle group 3's visibility", btnType: ButtonType.ToggleButton, width: 40, expertMode: false, toolType:"3", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Group 4", icon, toolTip:"Click to toggle group 4's visibility", btnType: ButtonType.ToggleButton, width: 40, expertMode: false, toolType:"4", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "", icon, toolTip:"Click to toggle group 5's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"5", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "", icon, toolTip:"Click to toggle group 6's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"6", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "", icon, toolTip:"Click to toggle group 7's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"7", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, ]).concat([ { title: "Options", isSystem: true,icon: "gear", toolTip:"Click to customize your filter panel", btnType: ButtonType.ClickButton, expertMode: false, toolType:"opts", funcs: {}, scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}'}} ]) @@ -856,19 +812,6 @@ pie title Minerals in my tap water { title: "View", icon: "View", toolTip: "View tools", subMenu: CurrentUserUtils.viewTools(), expertMode: false, toolType:CollectionViewType.Freeform, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Always available { title: "Stack", icon: "View", toolTip: "Stacking tools", subMenu: CurrentUserUtils.stackTools(), expertMode: false, toolType:CollectionViewType.Stacking, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Always available - - // { title: "SortType", btnList: new List<string>(["Time", "Type", "Color", "ChatGPT", "Custom 1", "Custom 2", "Custom 3" ]), - // toolTip: "Card Sort Type", btnType: ButtonType.DropdownList, ignoreClick: true, width: 100, scripts: { script: '{ return showFreeform(value, _readOnly_); }' }, - // // funcs: {hidden: `!SelectedDocType("card", this.expertMode)`} - // }, - // { title: "Visibility", icon:"Visibility", toolTip:"Filter AI labels", subMenu: this.cardGroupTools("robot"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("chat", true)`, width: 100, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"heart", toolTip:"Add Like labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"like", funcs: {hidden:`showFreeform ("like", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Visibility", icon:"Visibility", toolTip:"Filter likes", width: 10, subMenu: this.cardGroupTools("heart"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("like", true)`, width: 100, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"star", toolTip:"Add Star labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"star", funcs: {hidden:`showFreeform ("star", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Visibility", icon:"Visibility", toolTip:"Filter stars", width: 80, subMenu: this.cardGroupTools("star"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("star", true)`, width: 100, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - // // { title: "Custom", icon:"cloud", toolTip:"Add Idea labels", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"idea", funcs: {hidden:`showFreeform ("idea", true)`},scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Visibility", icon:"Visibility", toolTip:"Filter ideas", width: 80, subMenu: this.cardGroupTools("cloud"), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden:`!showFreeform("idea", true)`,width: 100, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, - { title: "Card", icon: "Card", toolTip: "Card View Tools", subMenu: CurrentUserUtils.cardTools(), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Always available // { title: "Create", icon: "Create", toolTip: "Assign card labels", subMenu: CurrentUserUtils.labelTools(), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Always available { title: "Web", icon: "Web", toolTip: "Web functions", subMenu: CurrentUserUtils.webTools(), expertMode: false, toolType:DocumentType.WEB, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Only when Web is selected @@ -877,13 +820,7 @@ pie title Minerals in my tap water { title: "Schema", icon: "Schema",linearBtnWidth:58,toolTip: "Schema functions",subMenu: CurrentUserUtils.schemaTools(),expertMode: false,toolType:CollectionViewType.Schema,funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} }, // Only when Schema is selected { title: "Filter", icon:"=", toolTip:"Filter cards by tags", btnType: ButtonType.MultiToggleButton, width: 150, ignoreClick: true,toolType:DocumentType.COL, subMenu: this.tagGroupTools(), funcs: {hidden: '!SelectedDocType(this.toolType, this.expertMode)'}, - // [ - // { title: "Star", icon: "star", toolTip:"Click to toggle the star group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"star", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Heart", icon: "heart", toolTip:"Click to toggle the heart group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"heart", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Bolt", icon: "bolt", toolTip:"Click to toggle the bolt group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"bolt", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - // { title: "Cloud", icon: "cloud", toolTip:"Click to toggle the cloud group's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"cloud", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}}, - - // ] + }, ]; diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index c63d3d7cb..cb314e3f1 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -1,7 +1,7 @@ // export const ts = (window as any).ts; // import * as typescriptlib from '!!raw-loader!../../../node_modules/typescript/lib/lib.d.ts' // import * as typescriptes5 from '!!raw-loader!../../../node_modules/typescript/lib/lib.es5.d.ts' -import typescriptlib from 'type_decls.d'; +// import typescriptlib from 'type_decls.d'; import * as ts from 'typescript'; import { Doc, FieldType } from '../../fields/Doc'; import { RefField } from '../../fields/RefField'; @@ -248,7 +248,7 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp const funcScript = `(function(${paramString})${reqTypes} { ${body} })`; host.writeFile('file.ts', funcScript); - if (typecheck) host.writeFile('node_modules/typescript/lib/lib.d.ts', typescriptlib); + // if (typecheck) host.writeFile('node_modules/typescript/lib/lib.d.ts', typescriptlib); const program = ts.createProgram(['file.ts'], {}, host); const testResult = program.emit(); const outputText = host.readFile('file.js'); diff --git a/src/client/views/FilterPanel.scss b/src/client/views/FilterPanel.scss index 34c3d2fc1..fbdebde0d 100644 --- a/src/client/views/FilterPanel.scss +++ b/src/client/views/FilterPanel.scss @@ -350,19 +350,7 @@ } -.drawing-box{ - position: absolute; - z-index: 10000; - border-color: black; - border-style: solid; - border-width: medium; - border-radius: 10%; - background-color: #323232; - - - -} // .sliderBox-outerDiv { // width: 30%;// width: calc(100% - 14px); // 14px accounts for handles that are at the max value of the slider that would extend outside the box // height: 40; // height: 100%; diff --git a/src/client/views/FilterPanel.tsx b/src/client/views/FilterPanel.tsx index e15285007..e73d9c2c9 100644 --- a/src/client/views/FilterPanel.tsx +++ b/src/client/views/FilterPanel.tsx @@ -11,7 +11,7 @@ import { List } from '../../fields/List'; import { RichTextField } from '../../fields/RichTextField'; import { SearchUtil } from '../util/SearchUtil'; import { SnappingManager } from '../util/SnappingManager'; -import { undoable } from '../util/UndoManager'; +import { undoable, undoBatch } from '../util/UndoManager'; import { FieldsDropdown } from './FieldsDropdown'; import './FilterPanel.scss'; import { DocumentView } from './nodes/DocumentView'; @@ -20,26 +20,14 @@ import { ObservableReactComponent } from './ObservableReactComponent'; import { Button } from '../util/CurrentUserUtils'; import { ButtonType } from './nodes/FontIconBox/FontIconBox'; import { DocCast } from '../../fields/Types'; -// import { Docs } from '../../documents/Documents'; -import { Docs } from '../documents/Documents'; import { CurrentUserUtils } from '../util/CurrentUserUtils'; -import { DocumentOptions } from '../documents/Documents'; -import { DocUtils } from '../documents/DocUtils'; -import { dropActionType } from '../util/DropActionTypes'; -import { Toggle } from 'browndash-components'; -import { SettingsManager } from '../util/SettingsManager'; import { StrCast } from '../../fields/Types'; -import { ToggleType } from 'browndash-components'; -import { MultiToggle } from 'browndash-components'; -import { Type } from 'browndash-components'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { DocData } from '../../fields/DocSymbols'; -import { DocumentType } from '../documents/DocumentTypes'; import { Tooltip } from '@mui/material'; import { useLocalObservable } from 'mobx-react'; import { useRef } from 'react'; import { useEffect } from 'react'; -import { useState } from 'react'; interface filterProps { @@ -242,12 +230,14 @@ export class FilterPanel extends ObservableReactComponent<filterProps> { return nonNumbers / facetValues.length > 0.1 ? facetValues.sort() : facetValues.sort((n1: string, n2: string) => Number(n1) - Number(n2)); }; - addHotkey(hotKey: string) { + /** + * Allows users to add a filter hotkey to the properties panel. Will also update the multitoggle at the top menu and the + * icontags tht are displayed on the documents themselves + * @param hotKey tite of the new hotkey + */ + addHotkey = (hotKey: string) => { const buttons = DocCast(Doc.UserDoc().myContextMenuBtns); const filter = DocCast(buttons.Filter); - const filter2 = DocCast(filter); - const but2 = Doc.UserDoc().myContextMenuBtns; - const newKey: Button = { title: hotKey, @@ -260,15 +250,11 @@ export class FilterPanel extends ObservableReactComponent<filterProps> { scripts: { onClick: '{ return handleTags(this.toolType, _readOnly_);}' }, }; - // const heyy = [...hi, newKey] - const currHotKeys = StrListCast(Doc.UserDoc().myFilterHotKeyTitles) Doc.UserDoc().myFilterHotKeyTitles = new List<string>(currHotKeys.concat(hotKey)) Doc.UserDoc()[hotKey] = 'bolt' - // Doc.UserDoc()['supppp'] = 'star' - const newBtn = CurrentUserUtils.setupContextMenuBtn(newKey, filter); newBtn.isSystem = newBtn[DocData].isSystem = undefined; @@ -276,32 +262,16 @@ export class FilterPanel extends ObservableReactComponent<filterProps> { const subDocs = DocListCast(filter.data) const opts = subDocs[subDocs.length-1] Doc.AddDocToList(filter, 'data', newBtn, opts, true); - - - - // console.log(filter[DocData].data + 'ok') - // // console.log(filter[DocData][0] + 'help') - // console.log(filter[DocData] + 'good grief') - - // console.log(DocCast(DocCast(filter.data))[0]) - // this.removeHotKey() - - // console.log(DocCast(filter.data) + 'HI') - // console.log(DocListCast(filter.data) + 'WOOOOO') - // console.log(DocCast(filter.data)[0] + 'hm :(') - } - - hotKeyButtons() { + /** + * Renders the newly formed hotkey icon buttons + * @returns the buttons to be rendered + */ + hotKeyButtons = () => { const selected = DocumentView.SelectedDocs().lastElement(); - - // console.log(StrListCast(Doc.UserDoc().myFilterHotKeyTitles) + "hiii") - const hotKeys = StrListCast(Doc.UserDoc().myFilterHotKeyTitles); - - // hotKeys.forEach(l => console.log(l + "render")) // Selecting a button should make it so that the icon on the top filter panel becomes said icon const buttons = hotKeys.map((hotKey, i) => ( @@ -506,6 +476,10 @@ interface HotKeyButtonProps { selected?: Doc } +/** + * Renders the buttons that correspond to each icon tag in the properties view. Allows users to change the icon, + * title, and delete. + */ const HotKeyIconButton: React.FC<HotKeyButtonProps> = observer(({ hotKey, selected}) => { const state = useLocalObservable(() => ({ isActive: false, @@ -534,36 +508,34 @@ const HotKeyIconButton: React.FC<HotKeyButtonProps> = observer(({ hotKey, select const handleClick = () => { state.toggleActive(); - // console.log(state.isActive + "hmmm") }; const hotKeys = StrListCast(Doc.UserDoc().myFilterHotKeyTitles) + const buttons = DocCast(Doc.UserDoc().myContextMenuBtns); + const filter = DocCast(buttons.Filter); + /** + * The doc of the button in the context menu that corresponds to the current hotkey + * @returns + */ const myHotKeyDoc = () => { - const buttons = DocCast(Doc.UserDoc().myContextMenuBtns); - const filter = DocCast(buttons.Filter); const hotKeyDocs = DocListCast(filter.data) return hotKeyDocs.filter(k => StrCast(k.title) === hotKey)[0] } + /** + * Removes a hotkey from list + */ const removeHotKey = () => { - const buttons = DocCast(Doc.UserDoc().myContextMenuBtns); - const filter = DocCast(buttons.Filter); - Doc.RemoveDocFromList(filter, 'data', myHotKeyDoc()); - - - - - // console.log((DocListCast(filter.data)[0].title) + "emmanuel") - - - // console.log(DocCast(filter.data) + 'HI') - // console.log(DocCast(filter.data)[0] + 'hm :(') - } + + /** + * Deselects if the user clicks outside the button + * @param event + */ const handleClickOutside = (event: MouseEvent) => { if (panelRef.current && !panelRef.current.contains(event.target as Node)) { state.deactivate(); @@ -571,23 +543,22 @@ const HotKeyIconButton: React.FC<HotKeyButtonProps> = observer(({ hotKey, select state.stopEditing(); updateFromInput() - - - - // Doc.UserDoc().myFilterHotKeyTitles = new List<string>(hotKeys.map(k => k === hotKey ? state.myHotKey : k)); - // Doc.UserDoc()[state.myHotKey] = StrCast(Doc.UserDoc()[hotKey]) - } } }; - const updateFromInput = () => { - const hi = myHotKeyDoc() + /** + * Updates the list of hotkeys based on the users input. replaces the old title with the new one and then assigns this new + * hotkey with the current icon + */ + const updateFromInput = undoable (() => { + const myDoc = myHotKeyDoc() Doc.UserDoc().myFilterHotKeyTitles = new List<string>(hotKeys.map(k => k === hotKey ? state.myHotKey : k)); Doc.UserDoc()[state.myHotKey] = StrCast(Doc.UserDoc()[hotKey]) - hi.title = state.myHotKey - hi.toolTip = `Click to toggle the ${state.myHotKey}'s group's visibility` - } + Doc.UserDoc()[hotKey] = '' + myDoc.title = state.myHotKey + myDoc.toolTip = `Click to toggle the ${state.myHotKey}'s group's visibility` + }, '') useEffect(() => { @@ -599,31 +570,25 @@ const HotKeyIconButton: React.FC<HotKeyButtonProps> = observer(({ hotKey, select const iconOpts = ['star', 'heart', 'bolt', 'satellite', 'palette', 'robot', 'lightbulb', 'highlighter', 'book', 'chalkboard' ]; + /** + * Panel of icons the user can choose from to represent their tag + */ const iconPanel = iconOpts.map((icon, i) => ( - <button key={i} onClick={(e: React.MouseEvent) => { + <button key={i} onClick={undoable((e: React.MouseEvent) => { e.stopPropagation; Doc.UserDoc()[hotKey] = icon; - const hi = myHotKeyDoc() - hi.icon = icon - - - - }} className='icon-panel-button'> + myHotKeyDoc().icon = icon + }, '')} className='icon-panel-button'> <FontAwesomeIcon icon={icon as any} color = {SnappingManager.userColor}/> </button> )); - function isAttrFiltered(attr: string) { - if (selected && selected._childFilters !== undefined && selected.type === DocumentType.COL) { - return StrListCast(selected._childFilters).some(filter => filter.includes(attr)); - } else { - return false; - } - } - + /** + * Actually renders the buttons + */ return ( - <div className={`filterHotKey-button ${isAttrFiltered(hotKey) ? 'active' : ''}`} + <div className={`filterHotKey-button`} onClick={(e) => { e.stopPropagation(); state.startEditing(); @@ -673,20 +638,12 @@ const HotKeyIconButton: React.FC<HotKeyButtonProps> = observer(({ hotKey, select )} <button className='hotKey-close' onClick={(e: React.MouseEvent) => { e.stopPropagation(); - const hi = StrListCast(Doc.UserDoc().myFilterHotKeyTitles) - // hi.forEach((str) => { - // console.log(str + "before"); - // }); Doc.UserDoc().myFilterHotKeyTitles = new List<string>(hotKeys.filter(k => k !== hotKey)); removeHotKey() - // hi.forEach((str) => { - // console.log(str + "after"); - // }); - }}> <FontAwesomeIcon icon={'x' as any} color={SnappingManager.userColor}/> </button> </div> ); -}) +})
\ No newline at end of file diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index daa8e1720..e940ba6f9 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -54,7 +54,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps private _widthUndo?: UndoManager.Batch; // eslint-disable-next-line no-use-before-define - public static Instance: PropertiesView | undefined; + public static Instance: PropertiesView; constructor(props: PropertiesViewProps) { super(props); makeObservable(this); diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index 12aaf0b39..cda39b474 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -26,6 +26,7 @@ import { FieldViewProps } from './nodes/FieldView'; import { StyleProp } from './StyleProp'; import './StyleProvider.scss'; import { IconTagBox } from './nodes/IconTagBox'; +import { DocData } from '../../fields/DocSymbols'; function toggleLockedPosition(doc: Doc) { UndoManager.RunInBatch(() => Doc.toggleLockedPosition(doc), 'toggleBackground'); @@ -368,6 +369,11 @@ export function DefaultStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps & }; const tags = () => props?.DocumentView?.() && CollectionFreeFormDocumentView.from(props.DocumentView()) ? <TagsView View={props.DocumentView()}/> : null; + const iconTags = () => { + if (doc && doc![DocData].showIconTags) + {return (<IconTagBox doc= {doc}></IconTagBox>)} + } + return ( <> {paint()} diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx index 2390d162c..3d9f28a49 100644 --- a/src/client/views/collections/CollectionCardDeckView.tsx +++ b/src/client/views/collections/CollectionCardDeckView.tsx @@ -23,6 +23,8 @@ import { dropActionType } from '../../util/DropActionTypes'; import { DocCast } from '../../../fields/Types'; import { SelectionManager } from '../../util/SelectionManager'; + + enum cardSortings { Time = 'time', Type = 'type', @@ -32,6 +34,14 @@ enum cardSortings { Tag = 'tag', None = '', } + +/** + * New view type specifically for studying more dynamically. Allows you to reorder docs however you see fit, easily + * sort and filter using presets, and customize your experience with chat gpt. + * + * This file contains code as to how the docs are to be rendered (there place geographically and also in regards to sorting), + * and callback functions for the gpt popup + */ @observer export class CollectionCardView extends CollectionSubView() { private _dropDisposer?: DragManager.DragDropDisposer; @@ -40,10 +50,8 @@ export class CollectionCardView extends CollectionSubView() { private _textToDoc = new Map<string, Doc>(); @observable _forceChildXf = false; - // @observable _isLoading = false; @observable _hoveredNodeIndex = -1; @observable _docRefs = new ObservableMap<Doc, DocumentView>(); - _draggerRef = React.createRef<HTMLDivElement>(); @observable _maxRowCount = 10; @observable _docDraggedIndex: number = -1; @observable _isACardBeingDragged: boolean = false; @@ -99,12 +107,12 @@ export class CollectionCardView extends CollectionSubView() { // Reaction to cardSort changes this._disposers.sort = reaction( - () => this.cardSort, - cardSort => { - if (cardSort === cardSortings.Chat) { + () => GPTPopup.Instance.visible, + isVis => { + if (isVis) { this.openChatPopup(); } else { - GPTPopup.Instance.setVisible(false); + this.Document.cardSort = (this.cardSort === cardSortings.Chat) ? '' : this.Document.cardSort; } } ); @@ -296,7 +304,7 @@ export class CollectionCardView extends CollectionSubView() { * @param de drop event * @returns true if a card has been dropped, falls if not */ - onInternalDrop = (e: Event, de: DragManager.DropEvent) => { + onInternalDrop = undoable((e: Event, de: DragManager.DropEvent) => { if (de.complete.docDragData) { this._isACardBeingDragged = false; this._docDraggedIndex = -1; @@ -304,7 +312,7 @@ export class CollectionCardView extends CollectionSubView() { return true; } return false; - }; + }, '' ); get sortedDocs() { return this.sort(this.childDocsWithoutLinks, this.cardSort, BoolCast(this.Document.cardSort_isDesc), this._docDraggedIndex); @@ -511,8 +519,6 @@ export class CollectionCardView extends CollectionSubView() { image[DocData].description = response.trim(); return response; // Return the response from gptImageLabel } catch (error) { - console.log('bad things have happened'); - console.log(error); } return ''; @@ -523,18 +529,22 @@ export class CollectionCardView extends CollectionSubView() { * usable code * @param gptOutput */ - @action processGptOutput = (gptOutput: string, questionType: string, tag?: string) => { - console.log('HIIII'); - console.log(StrCast(this.Document.cardSort) + 'cardSort'); + @action + + processGptOutput = undoable((gptOutput: string, questionType: string, tag?: string) => { // Split the string into individual list items const listItems = gptOutput.split('======').filter(item => item.trim() !== ''); - if (questionType == '2' || questionType == '4') { + if (questionType === '2' || questionType === '4') { this.childDocs.forEach(d => { d['chatFilter'] = false; }); } + if (questionType ==='6'){ + this.Document.cardSort = 'chat' + } + listItems.forEach((item, index) => { const normalizedItem = item.trim(); @@ -545,7 +555,6 @@ export class CollectionCardView extends CollectionSubView() { switch (questionType) { case '6': doc.chatIndex = index; - console.log(index); break; case '1': const allHotKeys = StrListCast(Doc.UserDoc().myFilterHotKeyTitles); @@ -578,7 +587,7 @@ export class CollectionCardView extends CollectionSubView() { console.warn(`No matching document found for item: ${normalizedItem}`); } }); - }; + }, ''); /** diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts index 8b9f128e0..9e56d313e 100644 --- a/src/client/views/global/globalScripts.ts +++ b/src/client/views/global/globalScripts.ts @@ -198,44 +198,6 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "tag", setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort === "tag" ? doc.cardSort = '' : doc.cardSort = 'tag', }], - // ['heart', { - // checkResult: (doc: Doc) => isAttrFiltered('heart'), - // setDoc: (doc: Doc, dv: DocumentView) => { - // isAttrFiltered('heart') ? Doc.setDocFilter(doc, 'heart', true, 'remove') : Doc.setDocFilter(doc, 'heart', true, 'match'); - - // } - // }], - // ['star', { - // checkResult: (doc: Doc) => isAttrFiltered('star'), - - // setDoc: (doc: Doc, dv: DocumentView) => { - // isAttrFiltered('star') ? Doc.setDocFilter(doc, 'star', true, 'remove') : Doc.setDocFilter(doc, 'star', true, 'match'); - // } - // }], - // ['bolt', { - // checkResult: (doc: Doc) => isAttrFiltered('bolt'), - // setDoc: (doc: Doc, dv: DocumentView) => { - // isAttrFiltered('bolt') ? Doc.setDocFilter(doc, 'bolt', true, 'remove') : Doc.setDocFilter(doc, 'bolt', true, 'match'); - - // } - // }], - // ['cloud', { - // checkResult: (doc: Doc) => isAttrFiltered('cloud'), - // setDoc: (doc: Doc, dv: DocumentView) => { - // isAttrFiltered('cloud') ? Doc.setDocFilter(doc, 'cloud', true, 'remove') : Doc.setDocFilter(doc, 'cloud', true, 'match'); - - // } - // }], - // ['chat', { - // checkResult: (doc: Doc) => { - - // if (StrCast(doc?.cardSort) === "chat"){ - // return true - // }} , - // setDoc: (doc: Doc, dv: DocumentView) => { - // doc.cardSort === "chat" ? doc.cardSort = '' : doc.cardSort = 'chat'; - // }, - // }], ['up', { checkResult: (doc: Doc) => BoolCast(!doc?.cardSort_isDesc), setDoc: (doc: Doc, dv: DocumentView) => { @@ -251,10 +213,17 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' ['toggle-chat', { checkResult: (doc: Doc) => GPTPopup.Instance.visible, setDoc: (doc: Doc, dv: DocumentView) => { - GPTPopup.Instance.setVisible(!GPTPopup.Instance.visible); - GPTPopup.Instance.setMode(GPTPopupMode.SORT); - doc.cardSort === "chat" ? doc.cardSort = '' : doc.cardSort = 'chat'; + if (GPTPopup.Instance.visible){ + doc.cardSort = '' + GPTPopup.Instance.setVisible(false); + + } else { + GPTPopup.Instance.setVisible(true); + GPTPopup.Instance.setMode(GPTPopupMode.CARD); + GPTPopup.Instance.setCardsDoneLoading(true); + } + }, }], @@ -293,9 +262,6 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' if (checkResult) { return map.get(attr)?.checkResult(selected); } - const filters = StrListCast(selected._childFilters).concat(StrListCast(selected?._childFiltersByRanges).filter((filter, i) => !(i % 3))); - - // console.log(filters.some(filter => filter.includes('star'))+ "SUOOOOPPP") const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} }; DocumentView.Selected().map(dv => map.get(attr)?.setDoc(dv.layoutDoc, dv)); @@ -303,7 +269,9 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' return undefined; }); - +/** + * Applies a filter to the selected document (or, if the settins button is pressed, opens the filter panel) + */ ScriptingGlobals.add(function handleTags(value?: any, checkResult?: boolean) { const selected = DocumentView.SelectedDocs().lastElement(); @@ -312,7 +280,7 @@ ScriptingGlobals.add(function handleTags(value?: any, checkResult?: boolean) { } if (checkResult) { - return value=== 'opts' ? PropertiesView.Instance.openFilters : isAttrFiltered(value) + return value=== 'opts' ? PropertiesView.Instance?.openFilters : isAttrFiltered(value) } if (value != 'opts'){ @@ -321,8 +289,7 @@ ScriptingGlobals.add(function handleTags(value?: any, checkResult?: boolean) { else { SnappingManager.PropertiesWidth < 5 && SnappingManager.SetPropertiesWidth(0); SnappingManager.SetPropertiesWidth(MainView.Instance.propertiesWidth() < 15 ? Math.min(MainView.Instance._dashUIWidth - 50, 250) : 0); - - PropertiesView.Instance.CloseAll() + PropertiesView.Instance?.CloseAll() PropertiesView.Instance.openFilters = true } @@ -330,183 +297,6 @@ ScriptingGlobals.add(function handleTags(value?: any, checkResult?: boolean) { return undefined; }, ''); - - -// ScriptingGlobals.add(function cardHasLabel(label: string) { -// const selected = DocumentView.SelectedDocs().lastElement(); -// const labelNum = Number(label) - 1; -// return labelNum < 4 || (selected && DocListCast(selected[Doc.LayoutFieldKey(selected)]).some(doc => doc[StrCast(selected.cardSort_customField)] == labelNum)); -// }, ''); - -// ScriptingGlobals.add(function setCardSort(attr: "Time" | "Type"| "Color"| "ChatGPT"| "Custom 1"| "Custom 2"| "Custom 3", value?: any, checkResult?: boolean) { -// // const editorView = RichTextMenu.Instance?.TextView?.EditorView; -// const selected = DocumentView.SelectedDocs().lastElement(); - -// // prettier-ignore -// const map: Map<"Time" | "Type"| "Color"| "ChatGPT"| "Custom 1"| "Custom 2"| "Custom 3", { checkResult: (doc: Doc) => any; setDoc: (doc: Doc) => void;}> = new Map([ -// ['Time', { - -// checkResult: (doc: Doc) => {StrCast(doc?.cardSort); -// console.log(StrCast(doc?.cardSort + "card sort"))}, -// setDoc: (doc: Doc) => {doc.cardSort = "time" -// console.log("hewwo")} - -// , -// }], -// ['Type', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort), -// setDoc: (doc: Doc) => doc.cardSort = "type", -// }], -// ['Color', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort), -// setDoc: (doc: Doc) => doc.cardSort = "color", -// }], -// // ['links', { -// // checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "links", -// // setDoc: (doc: Doc) => doc.cardSort = "links", -// // }], -// ['Custom 1', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 1", -// setDoc: (doc: Doc) => { -// doc.cardSort = "custom"; -// doc.cardSort_customField = "like"; -// doc.cardSort_visibleSortGroups = new List<number>(); -// } -// }], -// ['Custom 2', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 2", -// setDoc: (doc: Doc) => { -// doc.cardSort = "custom"; -// doc.cardSort_customField = "star"; -// doc.cardSort_visibleSortGroups = new List<number>(); -// } -// }], -// ['Custom 3', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 3", -// setDoc: (doc: Doc) => { -// doc.cardSort = "custom"; -// doc.cardSort_customField = "idea"; -// doc.cardSort_visibleSortGroups = new List<number>(); -// } -// }], -// ['ChatGPT', { -// checkResult: (doc: Doc) => StrCast(doc?.cardSort_customField), -// setDoc: (doc: Doc) => { -// doc.cardSort = "custom"; -// doc.cardSort_customField = "chat"; -// doc.cardSort_visibleSortGroups = new List<number>(); -// }, -// }], -// ]); - -// for (let i = 0; i < 8; i++) { -// map.set((i + 1 + '') as any, { -// checkResult: (doc: Doc) => NumListCast(doc?.cardSort_visibleSortGroups).includes(i), -// setDoc: (doc: Doc) => { -// const list = NumListCast(doc.cardSort_visibleSortGroups); -// doc.cardSort_visibleSortGroups = new List<number>(list.includes(i) ? list.filter(d => d !== i) : [...list, i]); -// }, -// }); -// } - -// if (checkResult) { -// console.log(attr + "attricute") -// console.log(map.get(attr)?.checkResult(selected) + "check result") -// return map.get(attr)?.checkResult(selected); -// } - -// console.log(attr + "attricute lol") - -// // const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} }; -// DocumentView.Selected().map(dv => map.get(attr)?.setDoc(dv.layoutDoc)); -// // setTimeout(() => batch.end(), 100); -// return undefined; - -// // map.get(attr)?.setDoc?.(); -// // return undefined; -// }); - -// ScriptingGlobals.add(function setCardSort(value?: any, checkResult?: boolean) { -// // const editorView = RichTextMenu.Instance?.TextView?.EditorView; -// const selected = DocumentView.SelectedDocs().lastElement(); -// if (checkResult) { -// // console.log(attr + "attricute") -// // console.log(map.get(attr)?.checkResult(selected) + "check result") -// console.log(StrCast(selected?.cardSort) + 'check'); -// const hi = StrCast(selected?.cardSort); -// return StrCast(selected?.cardSortForDropDown) ?? 'Time'; -// } -// function docFields(doc: Doc): void { -// switch (value) { -// case 'Custom 1': -// doc.cardSort_customField = 'like'; -// break; -// case 'Custom 2': -// doc.cardSort_customField = 'star'; -// break; -// case 'Custom 3': -// doc.cardSort_customField = 'idea'; -// break; -// case 'Chat GPT': -// doc.cardSort = 'custom'; -// doc.cardSort_customField = 'chat'; -// break; -// default: -// break; -// } - -// doc.cardSort_visibleSortGroups = new List<number>(); -// } - -// // const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} }; -// DocumentView.Selected().map(dv => { -// dv.Document.cardSortForDropDown = value; - -// if (value != 'Chat GPT') { -// dv.Document.cardSort = value.trim().split(/\s+/)[0].toLowerCase(); -// } -// docFields(dv.Document); -// }); - -// return undefined; - -// // map.get(attr)?.setDoc?.(); -// // return undefined; -// }); - -// ScriptingGlobals.add(function setCardSortAttr(attr: 'time' | 'docType' | 'color', value: any, checkResult?: boolean) { -// // const editorView = RichTextMenu.Instance?.TextView?.EditorView; -// const selected = SelectionManager.Docs.lastElement(); -// // prettier-ignore -// const map: Map<'time' | 'docType' | 'color', { waitForRender?: boolean, checkResult: (doc:Doc) => any; setDoc: (doc:Doc, dv:DocumentView) => void;}> = new Map([ -// ['time', { -// checkResult: (doc:Doc) => StrCast(doc?.cardSort), -// setDoc: (doc:Doc,dv:DocumentView) => doc.cardSort = "time", -// }], -// ['docType', { -// checkResult: (doc:Doc) => StrCast(doc?.cardSort), -// setDoc: (doc:Doc,dv:DocumentView) => doc.cardSort = "type", -// }], -// ['color', { -// checkResult: (doc:Doc) => StrCast(doc?.cardSort), -// setDoc: (doc:Doc,dv:DocumentView) => doc.cardSort = "color", -// }], -// // ['custom', { -// // checkResult: () => RichTextMenu.Instance.textAlign, -// // setDoc: () => value && editorView?.state ? RichTextMenu.Instance.align(editorView, editorView.dispatch, value):(Doc.UserDoc().textAlign = value), -// // }] -// // , -// ]); - -// if (checkResult) { -// return map.get(attr)?.checkResult(selected); -// } - -// console.log('hey') -// SelectionManager.Views.map(dv => map.get(attr)?.setDoc(dv.layoutDoc, dv)); -// console.log('success') -// }); - // eslint-disable-next-line prefer-arrow-callback ScriptingGlobals.add(function setFontAttr(attr: 'font' | 'fontColor' | 'highlight' | 'fontSize' | 'alignment', value: string | number, checkResult?: boolean) { const editorView = RichTextMenu.Instance?.TextView?.EditorView; diff --git a/src/client/views/nodes/IconTagBox.tsx b/src/client/views/nodes/IconTagBox.tsx index 8aa6bff2b..370ce51d1 100644 --- a/src/client/views/nodes/IconTagBox.tsx +++ b/src/client/views/nodes/IconTagBox.tsx @@ -1,13 +1,9 @@ import React from "react"; import { observer } from "mobx-react"; import { computed } from "mobx"; - import { ObservableReactComponent } from "../ObservableReactComponent"; import { NumCast } from "../../../fields/Types"; -import { makeObservable } from "mobx"; import { Doc } from "../../../fields/Doc"; -import { Reaction } from "mobx"; -import { reaction } from "mobx"; import { numberRange } from "../../../Utils"; import { Tooltip } from "@mui/material"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -15,16 +11,9 @@ import { undoable } from "../../util/UndoManager"; import { BoolCast } from "../../../fields/Types"; import { DocCast } from "../../../fields/Types"; import './IconTagBox.scss'; -import { AclAdmin, AclAugment, AclEdit, DocData } from '../../../fields/DocSymbols'; +import {DocData } from '../../../fields/DocSymbols'; import { StrListCast } from "../../../fields/Doc"; import { StrCast } from "../../../fields/Types"; -import { DocListCast } from "../../../fields/Doc"; -import { List } from "../../../fields/List"; -import { action } from "mobx"; -import { DragManager } from "../../util/DragManager"; -import { setupMoveUpEvents } from "../../../ClientUtils"; -import { returnFalse } from "../../../ClientUtils"; -import { emptyFunction } from "../../../Utils"; import { CollectionViewType } from "../../documents/DocumentTypes"; import { SnappingManager } from "../../util/SnappingManager"; import { MainView } from "../MainView"; @@ -33,95 +22,28 @@ import { PropertiesView } from "../PropertiesView"; export interface IconTagProps { doc: Doc; - - } +/** + * Renders the icon tags that rest under the document. The icons rendered are determined by the values of + * each icon in the userdoc. + */ @observer export class IconTagBox extends ObservableReactComponent<IconTagProps> { - private ref: React.RefObject<HTMLDivElement>; - private height: number = 0; - - @computed get currentScale() { - // console.log(NumCast((this._props.doc.embedContainer as Doc)?._freeform_scale, 1)) return NumCast((this._props.doc.embedContainer as Doc)?._freeform_scale, 1); } constructor(props: any) { super(props); - makeObservable(this); - this.ref = React.createRef(); } - // componentDidMount(): void { - // this.height = this.ref.current?.getBoundingClientRect().height ? this.ref.current?.getBoundingClientRect().height : 0; - // this._props.doc._keywordHeight = this.height; - - // reaction( - // () => this.currentScale, - // () => { - // if (this.currentScale < 1) { - // this.height = this.ref.current?.getBoundingClientRect().height ? this.ref.current?.getBoundingClientRect().height : 0; - // this._props.doc._keywordHeight = this.height; - // } - // } - // ); - // } - componentDidUpdate(prevProps: Readonly<IconTagProps>): void { - // this.height = this.ref.current?.getBoundingClientRect().height ? this.ref.current?.getBoundingClientRect().height : 0; this._props.doc[DocData].tagHeight = 36*this.currentScale; } - // createCollection = () => { - // // Get the documents that contain the keyword. - // const selected = DocListCast(this.getKeywordCollectionDocs()!); - // const newEmbeddings = selected.map(doc => Doc.MakeEmbedding(doc)); - - // // Create a new collection and set up configurations. - // const newCollection = ((doc: Doc) => { - // const docData = doc[DocData]; - // docData.data = new List<Doc>(newEmbeddings); - // docData.title = this._props.keyword; - // doc._freeform_panX = doc._freeform_panY = 0; - // return doc; - // })(Doc.MakeCopy(Doc.UserDoc().emptyCollection as Doc, true)); - // newEmbeddings.forEach(embed => (embed.embedContainer = newCollection)); - // newCollection._width = 900; - // newCollection._height = 900; - // newCollection.layout_fitWidth = true; - - // // Add the collection to the keyword document's list of associated smart collections. - // this._props.keywordDoc.collections = new List<Doc>([...DocListCast(this._props.keywordDoc.collections), newCollection]); - // newCollection[DocData].data_labels = new List<string>([this._props.keyword]); - // newCollection[DocData][`${this._props.keyword}`] = true; - // newCollection[DocData].showLabels = true; - // return newCollection; - // }; - - // @action - // handleDragStart = (e: React.PointerEvent) => { - // if (this._props.isEditing) { - // const clone = this.ref.current?.cloneNode(true) as HTMLElement; - // if (!clone) return; - - // setupMoveUpEvents( - // this, - // e, - // () => { - // const dragData = new DragManager.DocumentDragData([this.createCollection()]); - // DragManager.StartDocumentDrag([this.ref.current!], dragData, e.clientX, e.clientY, {}); - // return true; - // }, - // returnFalse, - // emptyFunction - // ); - // e.preventDefault(); - // } - // }; /** * Renders the buttons to customize sorting depending on which group the card belongs to and the amount of total groups @@ -130,25 +52,10 @@ export class IconTagBox extends ObservableReactComponent<IconTagProps> { * @returns */ renderButtons = (doc: Doc): JSX.Element | null => { - // if (cardSort !== cardSortings.Custom) return null; - const amButtons = (StrListCast(Doc.UserDoc().myFilterHotKeyTitles).length) + 1 const keys = StrListCast(Doc.UserDoc().myFilterHotKeyTitles) - - - // const amButtons = Math.max( - // 4, - // this.childDocs?.reduce((set, d) => { - // if (this.cardSort_customField) { - // set.add(NumCast(d[this.cardSort_customField])); - // } - // return set; - // }, new Set<number>()).size ?? 0 - // ); - - // const activeButtonIndex = CollectionCardView.getButtonGroup(this.cardSort_customField, doc); - + const totalWidth = (amButtons -1) * 35 + (amButtons -1) * 2 * 5 + 6; const iconMap = (buttonID: number) => { @@ -179,16 +86,14 @@ export class IconTagBox extends ObservableReactComponent<IconTagProps> { </button> </Tooltip> ))} - - {/* <Tooltip title={<div className="dash-tooltip">Click to customize these icons</div>}> - <button type="button" onClick={() => this.openHotKeyMenu() }> - <FontAwesomeIcon icon='gear' style={{ color: '#17438a', height: '30px', width: '30px'}} /> - </button> - </Tooltip> */} </div> ); }; + /** + * Opens the filter panel in the properties menu + */ + openHotKeyMenu = () => { SnappingManager.PropertiesWidth < 5 && SnappingManager.SetPropertiesWidth(0); SnappingManager.SetPropertiesWidth(MainView.Instance.propertiesWidth() < 15 ? Math.min(MainView.Instance._dashUIWidth - 50, 250) : 0); @@ -204,31 +109,19 @@ export class IconTagBox extends ObservableReactComponent<IconTagProps> { * @param doc */ toggleButton = undoable((doc: Doc, icon: string) => { - - - - // this.cardSort_customField && (doc[this.cardSort_customField] = buttonID); - - // doc.cardSort_activeIcons = new List<string>() - - - // const list = StrListCast(doc.cardSort_activeIcons); - // doc.cardSort_activeIcons = new List<string>(list.includes(icon) ? list.filter(d => d !== icon) : [...list, icon]); - BoolCast(doc[icon]) ? doc[icon] = false : doc[icon] = true - - - // StrListCast(doc.cardSort_activeIcons).push(iconMap[buttonID]) }, 'toggle card tag'); + /** + * Determines whether or not the given icon is active depending on the doc's data + * @param doc + * @param icon + * @returns + */ getButtonIcon = (doc: Doc, icon: any): JSX.Element => { - - // const isActive = StrListCast(doc.cardSort_activeIcons).includes(icon) const isActive = doc[icon] - - // console.log(StrListCast(doc.cardSort_activeIcons)) const color = isActive ? '#4476f7' : '#323232'; return <FontAwesomeIcon icon={icon} style={{ color , height: '30px', width: '30px'}} />; @@ -244,8 +137,6 @@ export class IconTagBox extends ObservableReactComponent<IconTagProps> { } - - } diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx index 002e82332..53bedbb65 100644 --- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx +++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx @@ -279,7 +279,7 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { } /** - * Generates a response to the user's questoin depending on the type of their question + * Generates a response to the user's question depending on the type of their question */ generateCard = async () => { console.log(this.chatSortPrompt + "USER PROMPT") @@ -798,7 +798,8 @@ export class GPTPopup extends ObservableReactComponent<GPTPopupProps> { color={StrCast(SettingsManager.userVariantColor)} tooltip="close" icon={<CgClose size="16px" />} - onClick={() => this.setVisible(false)} + onClick={() => { + this.setVisible(false)}} /> </> diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index bee79a38d..fea88cdcb 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -12,7 +12,7 @@ declare module 'fit-curve'; declare module 'iink-js'; declare module 'pdfjs-dist/web/pdf_viewer'; declare module 'react-jsx-parser'; -declare module 'type_decls.d'; +// declare module 'type_decls.d'; declare module '@react-pdf/renderer' { import * as React from 'react'; |