Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Make-md/makemd
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Apr 13, 2023
2 parents d9280b0 + 59776c0 commit 2e6605e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
.env
.DS_Store
undefined
.vscode
12 changes: 11 additions & 1 deletion src/components/ContextView/FolderContextViewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ export const FolderContextViewComponent = (
const folder = props.folder?.path;
const path = folderContextFromFolder(props.plugin, folder);
const ref = useRef<HTMLDivElement>(null);
const [flowOpen, setFlowOpen] = useState(false);


const folderNotePath = props.plugin.settings.folderNoteInsideFolder
? `${props.folder.path}/${props.folder.name}.md`
: props.folder && props.folder.parent.path == "/"
? `${props.folder.name}.md`
: `${props.folder.parent.path}/${props.folder.name}.md`;

const folderNote = getAbstractFileAtPath(app, folderNotePath);

const [flowOpen, setFlowOpen] = useState(
props.plugin.settings.enableFolderNote &&
props.plugin.settings.folderNoteOpenDefault &&
folderNote
);

const loadFile = async () => {
const folderNote = getAbstractFileAtPath(app, folderNotePath);
if (folderNote) {
Expand Down
4 changes: 4 additions & 0 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ class T {
name:"Enable Folder Note",
desc:"Access the folder note in the folder page and hide the folder note from spaces"
},
folderNoteOpenDefault: {
name: 'Open Folder Note by Default',
desc: 'When accessing a folder, open the folder note by default.',
},
activeFile: {
name: "Reveal Active File",
desc: "Automatically reveal the active file in Spaces"
Expand Down
90 changes: 52 additions & 38 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface MakeMDPluginSettings {
deleteFileOption: DeleteFileOption;
autoOpenFileContext: boolean;
expandedFolders: Record<string, string[]>;
folderNoteOpenDefault: boolean;
expandedSpaces: string[];
saveAllContextToFrontmatter: boolean;
folderRank: StringTree;
Expand Down Expand Up @@ -61,7 +62,7 @@ export const DEFAULT_SETTINGS: MakeMDPluginSettings = {
editorFlow: true,
internalLinkClickFlow: true,
saveAllContextToFrontmatter: false,
editorFlowStyle: "seamless",
editorFlowStyle: 'seamless',
autoOpenFileContext: false,
spacesCompactMode: false,
spacesEnabled: true,
Expand All @@ -71,29 +72,30 @@ export const DEFAULT_SETTINGS: MakeMDPluginSettings = {
spacesStickers: true,
spacesDisablePatch: false,
folderNoteInsideFolder: true,
folderNoteOpenDefault: false,
sidebarTabs: true,
showRibbon: true,
deleteFileOption: "trash",
deleteFileOption: 'trash',
expandedFolders: {},
expandedSpaces: ["/"],
expandedSpaces: ['/'],
folderRank: {
node: "root",
node: 'root',
children: [],
isFolder: true,
},
openFolders: [],
fileIcons: [],
spaces: [],
pinnedSpaces: [],
menuTriggerChar: "/",
emojiTriggerChar: ":",
folderContextFile: "context",
tagContextFolder: "Context",
hiddenFiles: ["Context"],
hiddenExtensions: ["mdb"],
vaultSort: ["rank", true],
newFileLocation: "root",
newFileFolderPath: "",
menuTriggerChar: '/',
emojiTriggerChar: ':',
folderContextFile: 'context',
tagContextFolder: 'Context',
hiddenFiles: ['Context'],
hiddenExtensions: ['mdb'],
vaultSort: ['rank', true],
newFileLocation: 'root',
newFileFolderPath: '',
};

export class MakeMDPluginSettingsTab extends PluginSettingTab {
Expand All @@ -113,15 +115,15 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
let { containerEl } = this;
containerEl.empty();

containerEl.createEl("h2", { text: t.settings.sectionAppearance });
containerEl.createEl('h2', { text: t.settings.sectionAppearance });
new Setting(containerEl)
.setName(t.settings.sidebarTabs.name)
.setDesc(t.settings.sidebarTabs.desc)
.addToggle((toggle) =>
toggle.setValue(this.plugin.settings.sidebarTabs).onChange((value) => {
this.plugin.settings.sidebarTabs = value;
this.plugin.saveSettings();
document.body.classList.toggle("mk-hide-tabs", !value);
document.body.classList.toggle('mk-hide-tabs', !value);
})
);
new Setting(containerEl)
Expand All @@ -131,7 +133,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
toggle.setValue(this.plugin.settings.showRibbon).onChange((value) => {
this.plugin.settings.showRibbon = value;
this.plugin.saveSettings();
document.body.classList.toggle("mk-hide-ribbon", !value);
document.body.classList.toggle('mk-hide-ribbon', !value);
})
);

Expand All @@ -149,7 +151,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
})
);

containerEl.createEl("h2", { text: t.settings.sectionSidebar });
containerEl.createEl('h2', { text: t.settings.sectionSidebar });
new Setting(containerEl)
.setName(t.settings.spaces.name)
.setDesc(t.settings.spaces.desc)
Expand Down Expand Up @@ -191,6 +193,18 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName(t.settings.folderNoteOpenDefault.name)
.setDesc(t.settings.folderNoteOpenDefault.desc)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.folderNoteOpenDefault)
.onChange((value) => {
this.plugin.settings.folderNoteOpenDefault = value;
this.plugin.saveSettings();
})
);
new Setting(containerEl)
.setName(t.settings.activeFile.name)
.setDesc(t.settings.activeFile.desc)
Expand All @@ -202,7 +216,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
this.plugin.saveSettings();
})
);
containerEl.createEl("h2", { text: "Context" });
containerEl.createEl('h2', { text: 'Context' });

new Setting(containerEl)
.setName(t.settings.openFileContext.name)
Expand All @@ -228,7 +242,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
})
);

containerEl.createEl("h2", { text: t.settings.sectionFlow });
containerEl.createEl('h2', { text: t.settings.sectionFlow });
new Setting(containerEl)
.setName(t.settings.internalLinkFlowEditor.name)
.setDesc(t.settings.internalLinkFlowEditor.desc)
Expand All @@ -255,26 +269,26 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
.setName(t.settings.editorFlowStyle.name)
.setDesc(t.settings.editorFlowStyle.desc)
.addDropdown((dropdown: DropdownComponent) => {
dropdown.addOption("classic", t.settings.editorFlowStyle.classic);
dropdown.addOption("seamless", t.settings.editorFlowStyle.seamless);
dropdown.addOption("minimal", t.settings.editorFlowStyle.minimal);
dropdown.addOption('classic', t.settings.editorFlowStyle.classic);
dropdown.addOption('seamless', t.settings.editorFlowStyle.seamless);
dropdown.addOption('minimal', t.settings.editorFlowStyle.minimal);
dropdown
.setValue(this.plugin.settings.editorFlowStyle)
.onChange(async (value) => {
this.plugin.settings.editorFlowStyle = value;
document.body.classList.toggle("mk-flow-classic", false);
document.body.classList.toggle("mk-flow-seamless", false);
document.body.classList.toggle("mk-flow-minimal", false);
if (value == "seamless")
document.body.classList.toggle("mk-flow-seamless", true);
if (value == "classic")
document.body.classList.toggle("mk-flow-classic", true);
if (value == "minimal")
document.body.classList.toggle("mk-flow-minimal", true);
document.body.classList.toggle('mk-flow-classic', false);
document.body.classList.toggle('mk-flow-seamless', false);
document.body.classList.toggle('mk-flow-minimal', false);
if (value == 'seamless')
document.body.classList.toggle('mk-flow-seamless', true);
if (value == 'classic')
document.body.classList.toggle('mk-flow-classic', true);
if (value == 'minimal')
document.body.classList.toggle('mk-flow-minimal', true);
});
});

containerEl.createEl("h2", { text: t.settings.sectionEditor });
containerEl.createEl('h2', { text: t.settings.sectionEditor });

new Setting(containerEl)
.setName(t.settings.makeChar.name)
Expand All @@ -291,7 +305,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
let char = value[0];

if (value.trim().length === 2) {
char = value.replace(this.plugin.settings.menuTriggerChar, "");
char = value.replace(this.plugin.settings.menuTriggerChar, '');
}

text.setValue(char);
Expand Down Expand Up @@ -339,7 +353,7 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
})
);

containerEl.createEl("h2", { text: t.settings.sectionAdvanced });
containerEl.createEl('h2', { text: t.settings.sectionAdvanced });

new Setting(containerEl)
.setName(t.settings.spacesFileExplorerDual.name)
Expand Down Expand Up @@ -380,13 +394,13 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
.setDesc(t.settings.spacesDeleteOption.desc)
.addDropdown((dropdown) => {
dropdown.addOption(
"permanent",
'permanent',
t.settings.spacesDeleteOptions.permanant
);
dropdown.addOption("trash", t.settings.spacesDeleteOptions.trash);
dropdown.addOption('trash', t.settings.spacesDeleteOptions.trash);
dropdown.addOption(
"system-trash",
t.settings.spacesDeleteOptions["system-trash"]
'system-trash',
t.settings.spacesDeleteOptions['system-trash']
);
dropdown.setValue(this.plugin.settings.deleteFileOption);
dropdown.onChange((option: DeleteFileOption) => {
Expand Down

0 comments on commit 2e6605e

Please sign in to comment.