Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrychenzw committed Jul 13, 2024
1 parent 83e6de1 commit fce1dfa
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 119 deletions.
31 changes: 25 additions & 6 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FileView, Notice, Plugin, TFile } from "obsidian";
import { FileView, Notice, Plugin, TFile, moment} from "obsidian";
import { t } from "src/lang/helper";
import { ZKNavigationSettngTab } from "src/settings/settings";
import { ZKGraphView, ZK_GRAPH_TYPE } from "src/view/graphView";
Expand Down Expand Up @@ -68,7 +68,6 @@ interface ZKNavigationSettings {
MainNoteButton: boolean;
MainNoteButtonText: string;
SelectMainNote: string;
RefreshIndexViewFlag: boolean;
settingIcon:boolean;
MainNoteSuggestMode: string;
ListTree: boolean;
Expand All @@ -77,6 +76,11 @@ interface ZKNavigationSettings {
HistoryMaxCount: number;
HistoryListShow: boolean;
ListTreeShow: boolean;
exportCanvas: boolean;
cardWidth: number;
cardHeight: number;
canvasFilePath: string;
siblingsOrder: string;
}

//Default value for setting field
Expand Down Expand Up @@ -112,15 +116,14 @@ const DEFAULT_SETTINGS: ZKNavigationSettings = {
DirectionOfFamilyGraph: "LR",
DirectionOfInlinksGraph: "TB",
DirectionOfOutlinksGraph: "TB",
BranchToolbra: true,
BranchToolbra: false,
RandomIndex: true,
RandomMainNote: true,
TableView: true,
IndexButton: true,
MainNoteButton: true,
MainNoteButtonText: t("Main notes"),
SelectMainNote: '',
RefreshIndexViewFlag: false,
settingIcon: true,
MainNoteSuggestMode: 'fuzzySuggest',
ListTree: true,
Expand All @@ -129,12 +132,20 @@ const DEFAULT_SETTINGS: ZKNavigationSettings = {
HistoryMaxCount: 20,
HistoryListShow: false,
ListTreeShow: false,
exportCanvas: true,
cardWidth: 400,
cardHeight: 240,
canvasFilePath: "",
siblingsOrder: "number",
}

export default class ZKNavigationPlugin extends Plugin {

settings: ZKNavigationSettings;
FileforLocaLgraph: string = "";
indexViewOffsetWidth: number = 0;
indexViewOffsetHeight: number = 0;
RefreshIndexViewFlag: boolean = false;

async loadSettings() {
this.settings = Object.assign(
Expand Down Expand Up @@ -180,8 +191,8 @@ export default class ZKNavigationPlugin extends Plugin {
this.settings.zoomPanScaleArr = [];
this.settings.BranchTab = 0;
this.settings.FoldNodeArr = [];
this.RefreshIndexViewFlag = true;
await this.openIndexView();
this.app.workspace.trigger("zk-navigation:refresh-index-graph");
}
}

Expand All @@ -191,8 +202,8 @@ export default class ZKNavigationPlugin extends Plugin {
this.settings.zoomPanScaleArr = [];
this.settings.BranchTab = 0;
this.settings.FoldNodeArr = [];
this.RefreshIndexViewFlag = true;
await this.openIndexView();
this.app.workspace.trigger("zk-navigation:refresh-index-graph");
}

} else {
Expand Down Expand Up @@ -283,6 +294,7 @@ export default class ZKNavigationPlugin extends Plugin {
this.settings.zoomPanScaleArr = [];
this.settings.BranchTab = 0;
this.settings.FoldNodeArr = [];
this.RefreshIndexViewFlag = true;
await this.openIndexView();
}
}
Expand All @@ -293,6 +305,7 @@ export default class ZKNavigationPlugin extends Plugin {
this.settings.zoomPanScaleArr = [];
this.settings.BranchTab = 0;
this.settings.FoldNodeArr = [];
this.RefreshIndexViewFlag = true;
await this.openIndexView();
}

Expand All @@ -318,9 +331,15 @@ export default class ZKNavigationPlugin extends Plugin {
active:true,
});
}

this.app.workspace.revealLeaf(
this.app.workspace.getLeavesOfType(ZK_INDEX_TYPE)[0]

);

if(this.RefreshIndexViewFlag === true){
this.app.workspace.trigger("zk-navigation:refresh-index-graph");
}
}

async openGraphView() {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "zettelkasten-navigation",
"name": "zettelkasten navigation",
"version": "0.0.51",
"version": "0.0.52",
"minAppVersion": "1.5.7",
"description": "Visualize a Luhmann-style zettelkasten.",
"author": "terrychenzw",
Expand Down
15 changes: 14 additions & 1 deletion src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
"Indexes folder location": "⚠Index files folder location",
"zk-index-graph-view": "zk-index-graph-view",
"Name of index button": "Name of index button",
"Suggest mode of index modal": "Suggestion mode of index modal",
"Suggest mode of index modal": "Suggest mode of index modal",
"Suggest mode of main note modal": "Suggest mode of main note modal",
"Keyword Order": "Keyword Order",
"Fuzzy Suggest": "Fuzzy Suggest",
Expand Down Expand Up @@ -60,6 +60,16 @@ export default {
"History List": "recent retrieval",
"And set the list length": "Set the max length",
"list tree": "outline view",
"set default width and height for cards": "set default width and height for cards",
"card width": "card width",
"card height": "card height",
"set the fixed path for exported canvas file": "⚠set a fixed canvas file",
"if empty, it will create a new canvas file every time": "if not set, it will create a new canvas file every time",
"Example: folder/filename.canvas": "Example: folder/filename.canvas",
"siblings order":"siblings order",
"siblings order description": "【number first】: 1->2...->a->b;【letter first】: a->b...->1->2",
'number first':'number first',
'letter first': 'letter first',

// indexView.ts
"Display from : ": "Display from : ",
Expand All @@ -82,6 +92,9 @@ export default {
"table view": "table view",
"Current note: ": "Current note: ",
"settings": "open settings",
"export to canvas": "export to canvas",
"select a main note": "select a main note",
"select an index": "select an index",

// localView.ts
"close relative": "close relative",
Expand Down
14 changes: 14 additions & 0 deletions src/lang/locale/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ export default {
"History List": "检索记录",
"And set the list length": "设置最大打开记录条数",
"list tree": "大纲视图",
"set default width and height for cards": "设置卡片宽度与高度",
"card width": "卡片宽度",
"card height": "卡片高度",
"set the fixed path for exported canvas file":"⚠设置一个固定的白板文件",
"if empty, it will create a new canvas file every time": "如果不设置,每次都会产生一个新的白板文件",
"Example: folder/filename.canvas": "比如: 文件夹/文件名.canvas",
"siblings order": "手足节点(同级)排序",
"siblings order description": "【数字优先】: 1->2...->a->b;【字母优先】: a->b...->1->2;",
'number first': "数字优先",
'letter first': "字母优先",


// indexView.ts
"Display from : ": "起点:",
Expand All @@ -81,6 +92,9 @@ export default {
"table view": "表格视图",
"Current note: ": "当前笔记: ",
"settings": "打开设置",
"export to canvas": "导出到白板",
"select a main note": "选择一个主笔记",
"select an index": "选择一个关键词",

// localView.ts
"close relative": "邻近",
Expand Down
3 changes: 2 additions & 1 deletion src/modal/indexModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class indexModal extends SuggestModal<ZKIndex> {
this.onSubmit = onSubmit;
this.plugin = plugin;
this.MainNotes = MainNotes;

this.setPlaceholder(t("select an index"));
}

// Returns all available suggestions.
Expand Down Expand Up @@ -106,6 +106,7 @@ export class indexFuzzyModal extends FuzzySuggestModal<ZKIndex> {
this.onSubmit = onSubmit;
this.plugin = plugin;
this.MainNotes = MainNotes;
this.setPlaceholder(t("select an index"));
}

getItems(): ZKIndex[] {
Expand Down
5 changes: 5 additions & 0 deletions src/modal/mainNoteModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ZKNavigationPlugin from "main";
import { App, FuzzySuggestModal, SuggestModal, renderMatches } from "obsidian";
import { t } from "src/lang/helper";
import { ZKNode } from "src/view/indexView";

export class mainNoteModal extends SuggestModal<ZKNode>{
Expand All @@ -14,6 +15,7 @@ export class mainNoteModal extends SuggestModal<ZKNode>{
this.onSubmit = onSubmit;
this.plugin = plugin;
this.MainNotes = MainNotes;
this.setPlaceholder(t("select a main note"));
}

getSuggestions(query: string):ZKNode[] {
Expand All @@ -32,6 +34,7 @@ export class mainNoteModal extends SuggestModal<ZKNode>{
this.selectZKNode = node;
this.onSubmit(this.selectZKNode);
}

}

export class mainNoteFuzzyModal extends FuzzySuggestModal<ZKNode> {
Expand All @@ -46,11 +49,13 @@ export class mainNoteFuzzyModal extends FuzzySuggestModal<ZKNode> {
this.onSubmit = onSubmit;
this.plugin = plugin;
this.MainNotes = MainNotes;
this.setPlaceholder(t("select a main note"));
}

getItems(): ZKNode[] {

return this.MainNotes;

}

getItemText(node: ZKNode): string {
Expand Down
Loading

0 comments on commit fce1dfa

Please sign in to comment.