aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/CurrentUserUtils.ts46
-rw-r--r--src/client/views/global/globalScripts.ts182
-rw-r--r--src/client/views/nodes/FontIconBox/FontIconBox.tsx2
3 files changed, 184 insertions, 46 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index f2ef9b943..438867eeb 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -660,40 +660,40 @@ pie title Minerals in my tap water
}
static cardTools(): Button[] {
return [
- { btnList: new List<string>(["Time", "Type", "Color", "ChatGPT", "Custom 1", "Custom 2", "Custom 3" ]),
- title: "Sort Type", toolTip: "Card Sort Type", btnType: ButtonType.DropdownList, ignoreClick: true, width: 150, scripts: { script: '{ return showFreeform(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>(["Time", "Type", "Color", "Chat GPT", "Custom 1", "Custom 2", "Custom 3" ]),
+ title: "Sort Type", toolTip: "Card Sort Type", btnType: ButtonType.DropdownList, ignoreClick: true, width: 150, 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: "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: "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:"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: "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:"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: "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:"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)`} },
+ { 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 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 cardGroupTools(icon: string): Button[] {
return [
- { title: "", icon, toolTip:"Click to toggle group 1's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"1", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
- { title: "", icon, toolTip:"Click to toggle group 2's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"2", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
- { title: "", icon, toolTip:"Click to toggle group 3's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"3", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
- { title: "", icon, toolTip:"Click to toggle group 4's visibility", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"4", funcs: {hidden:`!cardHasLabel(this.toolType)`}, scripts: { onClick: '{ return showFreeform(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_);}'}},
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index 107e21e08..0a6f78e2e 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -135,10 +135,10 @@ ScriptingGlobals.add(function toggleOverlay(checkResult?: boolean) {
});
// eslint-disable-next-line prefer-arrow-callback
-ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce', checkResult?: boolean, persist?: boolean, ) {
+ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines' | 'clusters' | 'viewAll' | 'fitOnce', checkResult?: boolean, persist?: boolean) {
const selected = DocumentView.SelectedDocs().lastElement();
// prettier-ignore
- const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | "Time" | "Type"| "Color"| "ChatGPT"| "Custom 1"| "Custom 2"| "Custom 3" ,
+ const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'links' | 'like' | 'star' | 'idea' | 'chat' | '1' | '2' | '3' | '4',
{
waitForRender?: boolean;
checkResult: (doc: Doc) => any;
@@ -173,49 +173,48 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
checkResult: (doc: Doc) => BoolCast(Doc.UserDoc().defaultToFlashcards, false),
setDoc: (doc: Doc, dv: DocumentView) => Doc.UserDoc().defaultToFlashcards = !Doc.UserDoc().defaultToFlashcards,
}],
- ['Time', {
- checkResult: (doc: Doc) => {StrCast(doc?.cardSort);
- console.log(StrCast(doc?.cardSort + "card sort"))},
+ ['time', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "time",
setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "time",
}],
- ['Type', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort),
+ ['docType', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "type",
setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "type",
}],
- ['Color', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort),
+ ['color', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "color",
setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "color",
}],
- // ['links', {
- // checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "links",
- // setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "links",
- // }],
- ['Custom 1', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 1",
+ ['links', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "links",
+ setDoc: (doc: Doc, dv: DocumentView) => doc.cardSort = "links",
+ }],
+ ['like', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "like",
setDoc: (doc: Doc, dv: DocumentView) => {
doc.cardSort = "custom";
doc.cardSort_customField = "like";
doc.cardSort_visibleSortGroups = new List<number>();
}
}],
- ['Custom 2', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 2",
+ ['star', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "star",
setDoc: (doc: Doc, dv: DocumentView) => {
doc.cardSort = "custom";
doc.cardSort_customField = "star";
doc.cardSort_visibleSortGroups = new List<number>();
}
}],
- ['Custom 3', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort) + " 3",
+ ['idea', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "idea",
setDoc: (doc: Doc, dv: DocumentView) => {
doc.cardSort = "custom";
doc.cardSort_customField = "idea";
doc.cardSort_visibleSortGroups = new List<number>();
}
}],
- ['ChatGPT', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort_customField),
+ ['chat', {
+ checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "custom" && StrCast(doc?.cardSort_customField) === "chat",
setDoc: (doc: Doc, dv: DocumentView) => {
doc.cardSort = "custom";
doc.cardSort_customField = "chat";
@@ -234,7 +233,7 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
}
if (checkResult) {
- console.log("HIIIIII")
+ // console.log("HIIIIII")
return map.get(attr)?.checkResult(selected);
}
const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} };
@@ -249,6 +248,144 @@ ScriptingGlobals.add(function cardHasLabel(label: string) {
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")
+ return StrCast(selected?.cardSort);
+ }
+
+ function docFields(doc: Doc): void {
+ switch(value){
+ case 'Custom 1':
+ doc.cardSort_customField = "like";
+ doc.cardSort_visibleSortGroups = new List<number>();
+ break;
+ case 'Custom 2':
+ doc.cardSort_customField = "star";
+ doc.cardSort_visibleSortGroups = new List<number>();
+ break;
+ case 'Custom 3':
+ doc.cardSort_customField = "idea";
+ doc.cardSort_visibleSortGroups = new List<number>();
+ break;
+ case 'Chat GPT':
+ doc.cardSort = "custom";
+ doc.cardSort_customField = "chat";
+ doc.cardSort_visibleSortGroups = new List<number>();
+ break;
+ default:
+ break;
+ }
+ }
+
+ // const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} };
+ DocumentView.Selected().map(dv => {
+ 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();
@@ -315,6 +452,7 @@ ScriptingGlobals.add(function setFontAttr(attr: 'font' | 'fontColor' | 'highligh
]);
if (checkResult) {
+ // console.log(map.get(attr)?.checkResult() + "font check result")
return map.get(attr)?.checkResult();
}
map.get(attr)?.setDoc?.();
diff --git a/src/client/views/nodes/FontIconBox/FontIconBox.tsx b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
index ffb668b03..8317d62a6 100644
--- a/src/client/views/nodes/FontIconBox/FontIconBox.tsx
+++ b/src/client/views/nodes/FontIconBox/FontIconBox.tsx
@@ -192,7 +192,7 @@ export class FontIconBox extends ViewBoxBaseComponent<ButtonProps>() {
} else {
text = script?.script.run({ this: this.Document, value: '', _readOnly_: true }).result;
// text = StrCast((RichTextMenu.Instance?.TextView?.EditorView ? RichTextMenu.Instance : Doc.UserDoc()).fontFamily);
- getStyle = (val: string) => ({ fontFamily: val });
+ // getStyle = (val: string) => ({ fontFamily: val });
}
// Get items to place into the list