Skip to content

Commit

Permalink
0.9.1011
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Nov 6, 2024
1 parent 3c206c6 commit 5bdb975
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 125 deletions.
178 changes: 89 additions & 89 deletions main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "make-md",
"name": "MAKE.md",
"version": "0.9.1010",
"version": "0.9.1011",
"minAppVersion": "0.16.0",
"description": "Make.md brings powerful and modern note-taking features to Obsidian. Capture, organize and connect information with more flexibility without any code.",
"author": "MAKE.md",
Expand Down
13 changes: 13 additions & 0 deletions src/adapters/obsidian/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
this.plugin.saveSettings();
})
);

new Setting(spaceAppearances)
.setName("Open Navigator on Right Panel")
.setDesc("Open navigator on right panel instead of left")
.addToggle((toggle) =>
toggle
.setValue(this.plugin.superstate.settings.spacesRightSplit)
.onChange((value) => {
this.plugin.superstate.settings.spacesRightSplit = value;
this.plugin.saveSettings();
})
);

new Setting(spaceAppearances)
.setName(t.settings.spaceRowHeight.name)
.setDesc(t.settings.spaceRowHeight.desc)
Expand Down
4 changes: 3 additions & 1 deletion src/adapters/obsidian/ui/navigator/NavigatorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export class FileTreeView extends ItemView {
async onClose() {
const leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE);
if (leafs.length == 0) {
const leaf = this.app.workspace.getLeftLeaf(false);
const leaf = this.superstate.settings.spacesRightSplit
? this.app.workspace.getRightLeaf(false)
: this.app.workspace.getLeftLeaf(false);
await leaf.setViewState({ type: FILE_TREE_VIEW_TYPE });
}
this.destroy();
Expand Down
7 changes: 3 additions & 4 deletions src/adapters/obsidian/utils/patches.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FlowEditor } from "adapters/obsidian/ui/editors/FlowEditor";
import { FILE_TREE_VIEW_TYPE } from "adapters/obsidian/ui/navigator/NavigatorView";
import MakeMDPlugin from "main";
import { around } from "monkey-around";
import {
Expand All @@ -17,9 +16,9 @@ export const patchFilesPlugin = (plugin: MakeMDPlugin) => {
around(Workspace.prototype, {
getLeavesOfType(old) {
return function (type: unknown) {
if (type == "file-explorer") {
return old.call(this, FILE_TREE_VIEW_TYPE);
}
// if (type == "file-explorer") {
// return old.call(this, FILE_TREE_VIEW_TYPE);
// }
return old.call(this, type);
};
},
Expand Down
1 change: 0 additions & 1 deletion src/adapters/obsidian/utils/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const editTagInFileBody = async (
positions: Pos[],
file: TFile
) => {
console.log("editTagInFileBody", oldTag, newTag, positions);
const offsetOffset = newTag.length - oldTag.length;
if (positions.length == 0) return false;
const original = await plugin.files.readTextFromFile(file.path);
Expand Down
18 changes: 9 additions & 9 deletions src/core/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ class T {
closeFlow: "Close Flow Blocks in Selection",
toggleBold: "Toggle Bold",
toggleItalics: "Toggle Italics",
openSpaces: "Open Spaces",
openSpaces: "Open Navigator",
blink: "Blink",
openFileContext: "Open Explorer",
convertPathToSpace: "Convert to Space",
revealFile: "Reveal File in Spaces",
revealFile: "Reveal File in Navigator",
releaseNotes: "Release Notes",
toggleBacklinks: "Toggle Backlinks",
collapseAllFolders: "Collapse All Folders",
Expand Down Expand Up @@ -176,7 +176,7 @@ class T {
openVaultInFolder: "Open Vault Folder",
obSettings: "Obsidian Settings",
commandPalette: "Command Palette",
backToSpace: "Back to Spaces",
backToSpace: "Back to Navigator",
collapseAllSections: "Collapse All Spaces",
expandAllSections: "Expand All Spaces",
collapseAllFolders: "Collapse All Folders",
Expand Down Expand Up @@ -710,8 +710,8 @@ class T {
desc: "Add inline stickers by typing :",
},
openSpacesOnLaunch: {
name: "Open Spaces as Default Tab",
desc: "Open the Spaces tab when Obsidian launches",
name: "Open Navigator as Default Tab",
desc: "Open the Navigator tab when Obsidian launches",
},
defaultSpaceTemplate: {
name: "Default Space Template",
Expand Down Expand Up @@ -803,7 +803,7 @@ class T {
},
activeFile: {
name: "Reveal Active File",
desc: "Automatically reveal the active file in Spaces",
desc: "Automatically reveal the active file in Navigator",
},


Expand All @@ -821,11 +821,11 @@ class T {
},
spacesAlias: {
name: "Alias",
desc: `Use the alias metadata to show in Spaces`,
desc: `Use the alias metadata to show in Navigator`,
},
spacesFileExplorerDual: {
name: "Compatibility Mode",
desc: "This will improve the compatibility of plugins while using Spaces",
desc: "This will improve the compatibility of plugins while using the Navigator",
},
spacesDeleteOption: {
name: "Delete File Option",
Expand Down Expand Up @@ -887,7 +887,7 @@ class T {

spaceRowHeight: {
name: "Row Height",
desc: "The height for each row in spaces (in pixels), default is 29",
desc: "The height for each row in navigator (in pixels), default is 29",
},

contextPagination: {
Expand Down
38 changes: 23 additions & 15 deletions src/core/react/components/Navigator/SpaceTree/SpaceTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,6 @@ const retrieveData = (
}
});

// if (nextTreeScrollPath.current) {
// const index = tree.findIndex(
// (f) => f.item?.path == nextTreeScrollPath.current
// );
// if (index != -1) {
// listRef.current.scrollToIndex(index);
// nextTreeScrollPath.current = null;
// }
// }
tree.push({
id: "placeholder",
parentId: null,
Expand Down Expand Up @@ -299,7 +290,12 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
x: number;
y: number;
}>({ x: 0, y: 0 });
const listRef = useRef<{ scrollToIndex: (index: number) => void }>(null);
const listRef = useRef<{
scrollToIndex: (
index: number,
options: { align: "start" | "center" | "end" | "auto" }
) => void;
}>(null);

const refreshableSpaces = useMemo(
() =>
Expand All @@ -317,6 +313,7 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
if (superstate.settings.revealActiveFile && activePath)
revealPath(activePath);
}

props.superstate.ui.eventsDispatch.addListener(
"activePathChanged",
changeActivePath
Expand Down Expand Up @@ -365,7 +362,7 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
if (!path || parentSpaces.length == 0) return;

let newOpenFolders = expandedSpaces;

let newScrollToSpace = null;
parentSpaces.forEach((space) => {
const folders = path.split("/");
const pathLevel = space.path
Expand All @@ -388,7 +385,7 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
[space.path]
)
.slice(0, -1);

newScrollToSpace = openPaths[openPaths.length - 1];
newOpenFolders = [
...(newOpenFolders.filter((f) => !openPaths.find((g) => g == f)) ??
[]),
Expand All @@ -397,7 +394,7 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
});

superstate.settings.expandedSpaces = newOpenFolders;
nextTreeScrollPath.current = "/" + path;
nextTreeScrollPath.current = newScrollToSpace;
superstate.saveSettings();
},
[expandedSpaces, activeViewSpaces]
Expand Down Expand Up @@ -446,9 +443,20 @@ export const SpaceTreeComponent = (props: SpaceTreeComponentProps) => {
]);

useEffect(() => {
setFlattenedTree(
retrieveData(superstate, activeViewSpaces, active, expandedSpaces)
const tree = retrieveData(
superstate,
activeViewSpaces,
active,
expandedSpaces
);
setFlattenedTree(tree);
if (nextTreeScrollPath.current) {
const index = tree.findIndex((f) => f.id == nextTreeScrollPath.current);
if (index != -1) {
listRef.current.scrollToIndex(index, { align: "center" });
nextTreeScrollPath.current = null;
}
}
}, [expandedSpaces, activeViewSpaces, active]);
const changeActivePath = (path: string) => {
setActivePath(path);
Expand Down
6 changes: 4 additions & 2 deletions src/core/react/components/PathView/NoteView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export const NoteView = forwardRef((props: NoteViewProps, ref) => {

const properties: Record<string, any> = props.properties;
const pathState = props.superstate.pathsIndex.get(path.basePath);
const pathExists = await props.superstate.spaceManager.pathExists(
path.basePath
);
const filePath =
pathState?.type == "space" && props.forceNote
? props.superstate.spacesIndex.get(props.path)?.space.notePath
: pathState
: pathState || pathExists
? path.fullPath
: null;

Expand All @@ -49,7 +52,6 @@ export const NoteView = forwardRef((props: NoteViewProps, ref) => {
).folderPath
: props.superstate.spaceManager.parentPathForPath(path.basePath);
if (!parent) return;
console.log(parent, props.path, path, props.path, props.source);
const newPath = await props.superstate.spaceManager.createItemAtPath(
parent,
"md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ const SelectMenuSuggestionsComponent = (props: {
: {}
}
dangerouslySetInnerHTML={{
__html: markIt(props.item.name, props.query),
__html:
props.query.length > 0
? markIt(props.item.name, props.query)
: props.item.name,
}}
/>
{props.item.description && (
Expand Down
1 change: 1 addition & 0 deletions src/core/schemas/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const DEFAULT_SETTINGS: MakeMDSettings = {
editorFlow: true,
internalLinkClickFlow: true,
internalLinkSticker: true,
spacesRightSplit: false,
contextEnabled: true,
spaceViewEnabled: true,
saveAllContextToFrontmatter: true,
Expand Down
3 changes: 2 additions & 1 deletion src/core/superstate/cacheParsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ export const parseMetadata = (path: string, settings: MakeMDSettings, spacesCach
if (space.space.notePath == path && space.path != space.space.notePath) {
isSpaceNote = true;
spacePath = space.path;
hidden = true;
if (settings.enableFolderNote)
hidden = true;
}
if (subtype != 'tag' && subtype != 'default') {
if (space.space && space.space.path == parent) {
Expand Down
1 change: 1 addition & 0 deletions src/core/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface MakeMDSettings {
fmKeyColor: string;
fmKeySticker: string;
openSpacesOnLaunch: boolean;
spacesRightSplit: boolean;
indexSVG: boolean;
readableLineWidth: boolean;
syncFormulaToFrontmatter: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ this.markdownAdapter = new ObsidianMarkdownFiletypeAdapter(this);
openFileTreeLeaf = async (showAfterAttach: boolean) => {
const leafs = this.app.workspace.getLeavesOfType(FILE_TREE_VIEW_TYPE);
if (leafs.length == 0) {
const leaf = this.app.workspace.getLeftLeaf(false);
const leaf = this.superstate.settings.spacesRightSplit ? this.app.workspace.getRightLeaf(false) : this.app.workspace.getLeftLeaf(false);
await leaf.setViewState({ type: FILE_TREE_VIEW_TYPE });
if (showAfterAttach && !this.app.workspace.leftSplit.collapsed) this.app.workspace.revealLeaf(leaf);
} else {
Expand Down

0 comments on commit 5bdb975

Please sign in to comment.