Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Jan 5, 2025
1 parent 02b83a9 commit 1351286
Show file tree
Hide file tree
Showing 99 changed files with 1,205 additions and 963 deletions.
214 changes: 107 additions & 107 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": "1.0.2",
"version": "1.0.3",
"minAppVersion": "0.16.0",
"description": "Make.md gives you everything you need to organize and personalize your notes.",
"author": "MAKE.md",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/mdb/mdbAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { mdbTablesToDBTables, saveDBToPath } from 'adapters/mdb/db/db';
import { deleteMDBTable, getMDB, getMDBTable, getMDBTableProperties, getMDBTableSchemas, getMDBTables } from 'adapters/mdb/utils/mdb';
import { commandToDBTables, mdbSchemaToCommandSchema } from 'core/utils/commands/commands';
import { mdbFrameToDBTables } from "core/utils/frames/frame";
import { frameSchemaToTableSchema } from 'core/utils/frames/nodes';
import _ from 'lodash';
import MakeMDPlugin from 'main';
import { AFile, FileTypeAdapter, FilesystemMiddleware } from 'makemd-core';
import { fieldSchema } from "shared/schemas/fields";
import { Command } from 'shared/types/commands';
import { DBTable, DBTables, MDB, SpaceProperty, SpaceTable, SpaceTableSchema, SpaceTables } from 'shared/types/mdb';
import { MDBFrame } from 'shared/types/mframe';
import { frameSchemaToTableSchema } from "shared/utils/makemd/schema";
import { loadSQL } from "./db/sqljs";
import { deletePropertyToDBTables, savePropertyToDBTables } from './utils/property';
import { saveSchemaToDBTables } from './utils/schema';
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/obsidian/filetypes/jsonAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { AFile, FileTypeAdapter, FilesystemMiddleware } from "makemd-core";

import { omit } from "lodash";
import MakeMDPlugin from "main";
import { parseProperty, safelyParseJSON } from "utils/parsers";
import { safelyParseJSON } from "shared/utils/json";
import { parseProperty } from "utils/parsers";

type CachedMetadataContentTypes = {
property: any;
Expand Down
14 changes: 8 additions & 6 deletions src/adapters/obsidian/filetypes/markdownAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const removeMarkdown = (str: string) => {
return output.replace(/^\s*\n/gm, '');
}

type CleanCachedMetadata = Omit<CachedMetadata, 'tags'> & { tags: string[], resolvedLinks: string[], label: PathLabel, inlinks: string[] }
type CleanCachedMetadata = Omit<CachedMetadata, 'tags'> & { tags: string[], resolvedLinks: string[], label: PathLabel, inlinks: string[], property: any }

export class ObsidianMarkdownFiletypeAdapter implements FileTypeAdapter<CleanCachedMetadata, CachedMetadataContentTypes> {

Expand Down Expand Up @@ -153,25 +153,26 @@ public app: App;
.filter((f) => typeof f === "string")
.map((f) => "#" + f)
);
const contents = await this.plugin.app.vault.cachedRead(getAbstractFileAtPath(this.plugin.app, file.path)as TFile)


const links = fCache.links?.map(f => this.plugin.app.metadataCache.getFirstLinkpathDest(f.link, file.path)?.path).filter(f => f)
this.linksMap.set(file.path, new Set(links));
const updatedCache = {...fCache,
const updatedCache : CleanCachedMetadata = {
resolvedLinks: links ?? [],
inlinks: Array.from(incoming),
tags: rt,
property: fCache.frontmatter,
tasks: fCache.listItems?.filter(f => f.task).map(f => contents.slice(f.position.start.offset, f.position.end.offset)) ?? [],
label: {
name: file.name,
thumbnail: fCache.frontmatter?.[this.plugin.superstate.settings.fmKeyBanner],
sticker: fCache.frontmatter?.[this.plugin.superstate.settings.fmKeySticker],
color: fCache.frontmatter?.[this.plugin.superstate.settings.fmKeyColor],
preview: removeMarkdown(contents.slice(fCache.frontmatterPosition?.end.offset ?? 0, 1000))

}}

if (this.plugin.superstate.settings.notesPreview) {
const contents = await this.plugin.app.vault.cachedRead(getAbstractFileAtPath(this.plugin.app, file.path)as TFile)
updatedCache.label.preview = removeMarkdown(contents.slice(fCache.frontmatterPosition?.end.offset ?? 0, 1000))
}
if (currentCache) {

if (!_.isEqual(currentCache.resolvedLinks, updatedCache.resolvedLinks)) {
Expand All @@ -186,6 +187,7 @@ public app: App;
}
}
this.cache.set(file.path, updatedCache);

this.middleware.updateFileCache(file.path, updatedCache, refresh);
}
private metadataKeys = ['property', 'links', 'embeds', 'tags', 'headings', 'sections', 'listItems', 'frontmatter', 'frontmatterPosition', 'frontmatterLinks', 'blocks'] as Array<keyof CachedMetadata>;
Expand Down
16 changes: 14 additions & 2 deletions src/adapters/obsidian/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
general: ['label', 'tags'],
navigator: ['appearance', 'interaction', 'advanced'],
label: ['appearance'],
notes: ['appearance'],
space: ['appearance', 'folderNote', 'context'],
notes: ['appearance', 'folderNote'],
space: ['appearance' , 'context'],
performance: [],
advanced: []
},
Expand Down Expand Up @@ -130,6 +130,12 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
type: 'boolean',

},
{
name: 'editStickerInSidebar',
category: 'navigator',
subCategory: 'interaction',
type: 'boolean',
},
{
name: 'spacesRightSplit',
category: 'navigator',
Expand Down Expand Up @@ -216,6 +222,12 @@ export class MakeMDPluginSettingsTab extends PluginSettingTab {
subCategory: 'tags',
type: 'boolean',
},
{
name: 'notesPreview',
category: 'performance',
type: 'boolean',
},

{
name: 'spacesPerformance',
category: 'performance',
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/types/obsidian.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EditorView } from "@codemirror/view";
import { FlowEditor, FlowEditorParent } from "adapters/obsidian/ui/editors/FlowEditor";
import { FlowEditor, FlowEditorParent } from "shared/FlowEditor";

declare module "obsidian" {
export enum PopoverState {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/ui/kit/InstallKitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MakeMDPlugin from "main";
import { Superstate } from "makemd-core";
import React, { useState } from "react";
import { windowFromDocument } from "shared/utils/dom";
import { safelyParseJSON } from "utils/parsers";
import { safelyParseJSON } from "shared/utils/json";
import { Dropdown } from "../../../../core/react/components/UI/Dropdown";
import { showSpacesMenu } from "../../../../core/react/components/UI/Menus/properties/selectSpaceMenu";

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/ui/kit/kits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Note, SpaceKit, TemplateKit } from "shared/types/kits";
import { DBTables, SpaceTables } from "shared/types/mdb";
import { SpaceDefinition, SpaceType } from "shared/types/spaceDef";
import { FilesystemSpaceInfo } from "shared/types/spaceInfo";
import { safelyParseJSON } from "utils/parsers";
import { safelyParseJSON } from "shared/utils/json";

export const installSpaceTemplate = async (plugin: MakeMDPlugin, superstate: Superstate, space: string, template: TemplateKit) => {

Expand Down
41 changes: 35 additions & 6 deletions src/adapters/obsidian/ui/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InteractionType, ScreenType } from "shared/types/ui";

import MakeMDPlugin from "main";
import { Sticker, Superstate, UIAdapter, UIManager, i18n } from "makemd-core";
import { Notice, Platform, TFile, getIcon } from "obsidian";
import { Menu, Notice, Platform, TFile, getIcon } from "obsidian";
import React from "react";

import { Container } from "react-dom";
Expand All @@ -16,13 +16,14 @@ import { openPathInElement } from "shared/utils/openPathInElement";
import { getParentPathFromString } from "utils/path";
import { urlRegex } from "utils/regex";

import { BlinkMode } from "core/react/components/Blink/Blink";
import { showLinkMenu } from "core/react/components/UI/Menus/properties/linkMenu";
import { showSpacesMenu } from "core/react/components/UI/Menus/properties/selectSpaceMenu";
import ImageModal from "core/react/components/UI/Modals/ImageModal";
import { BlinkMode } from "shared/types/blink";
import { editableRange } from "shared/utils/codemirror/selectiveEditor";
import { getLineRangeFromRef } from "shared/utils/obsidian";
import { SPACE_VIEW_TYPE } from "../SpaceViewContainer";
import { getAbstractFileAtPath, getLeaf, openPath } from "../utils/file";
import { getAbstractFileAtPath, getLeaf } from "../utils/file";
import { modifyTabSticker } from "../utils/modifyTabSticker";
import { WindowManager } from "./WindowManager";
import { lucideIcons } from "./icons";
Expand Down Expand Up @@ -56,12 +57,23 @@ export class ObsidianUI implements UIAdapter {
};

public quickOpen = (
mode?: number,
mode?: BlinkMode,
offset?: Rect,
win?: Window,
onSelect?: (link: string) => void,
source?: string
) => {
if (mode == BlinkMode.Image) {
this.openPalette(
<ImageModal
superstate={this.manager.superstate}
selectedPath={onSelect}
></ImageModal>,
win,
null
);
return;
}
if (this.manager.superstate.settings.blinkEnabled) {
this.plugin.quickOpen(this.manager.superstate, mode, onSelect, source);
} else {
Expand Down Expand Up @@ -378,14 +390,14 @@ export class ObsidianUI implements UIAdapter {
});
}
} else {
await openPath(leaf, path, this.plugin, true);
await this.plugin.openPath(leaf, path, true);
}
}
);
return;
}
const leaf = getLeaf(this.plugin.app, newLeaf);
openPath(leaf, path, this.plugin);
this.plugin.openPath(leaf, path);
};
public primaryInteractionType = () => {
return Platform.isMobile ? InteractionType.Touch : InteractionType.Mouse;
Expand All @@ -397,4 +409,21 @@ export class ObsidianUI implements UIAdapter {
? ScreenType.Tablet
: ScreenType.Desktop;
};
public hasNativePathMenu = (path: string) => {
return true;
};
public nativePathMenu = (e: React.MouseEvent, path: string) => {
const file = this.plugin.app.vault.getAbstractFileByPath(path);
if (file) {
const fileMenu = new Menu();
this.plugin.app.workspace.trigger(
"file-menu",
fileMenu,
file,
"file-explorer"
);
const rect = e.currentTarget.getBoundingClientRect();
fileMenu.showAtPosition({ x: rect.left, y: rect.bottom });
}
};
}
99 changes: 2 additions & 97 deletions src/adapters/obsidian/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import {
} from "obsidian";

import { SPACE_VIEW_TYPE } from "adapters/obsidian/SpaceViewContainer";
import { defaultSpace, newPathInSpace } from "core/superstate/utils/spaces";
import { isTouchScreen } from "core/utils/ui/screen";
import { TargetLocation } from "shared/types/path";
import { selectElementContents } from "shared/utils/dom";
import { removeTrailingSlashFromFolder } from "shared/utils/paths";
import { sanitizeFileName, sanitizeFolderName } from "shared/utils/sanitizers";
import { folderPathToString, getParentPathFromString } from "utils/path";
import { SPACE_FRAGMENT_VIEW_TYPE } from "../ui/editors/SpaceFragmentViewComponent";
import { folderPathToString } from "utils/path";
import { EVER_VIEW_TYPE } from "../ui/navigator/EverLeafView";


Expand Down Expand Up @@ -169,100 +167,7 @@ export const deleteFiles = (plugin: MakeMDPlugin, files: string[]) => {



export const openPath = async (
leaf: WorkspaceLeaf,
path: string,
plugin: MakeMDPlugin,
flow?: boolean
) => {
const uri = plugin.superstate.spaceManager.uriByString(path);
if (!uri) return;
if (uri.scheme == 'https' || uri.scheme == 'http') {
if (plugin.superstate.spacesIndex.has(path)) {
const viewType = SPACE_VIEW_TYPE;
plugin.app.workspace.setActiveLeaf(leaf, { focus: true });
await leaf.setViewState({
type: viewType,
state: { path: path, flow },
});
return;
} else if (plugin.superstate.pathsIndex.has(path)) {
const viewType = LINK_VIEW_TYPE;
plugin.app.workspace.setActiveLeaf(leaf, { focus: true });
await leaf.setViewState({
type: viewType,
state: { path: path, flow },
});
return;
}
window.open(uri.fullPath, '_blank');
return;
}
if (uri.scheme == 'obsidian') {
await leaf.setViewState({
type: uri.authority,
});
return;
}

if (uri.ref) {
const cache = plugin.superstate.pathsIndex.get(uri.path);

if (cache?.type == "space" || uri.scheme == 'spaces') {
if (flow && uri.ref == 'main') {
await leaf.setViewState({
type: EMBED_SPACE_VIEW_TYPE,
state: { path: uri.fullPath },
});
} else {
await leaf.setViewState({
type: SPACE_FRAGMENT_VIEW_TYPE,
state: { path: uri.fullPath, flow },
});
}
return;
}
}

if (uri.scheme == 'spaces') {
openTagContext(leaf, uri.basePath, plugin.app)
return;
}
plugin.files.getFile(path).then(f => {
if (f)
{
if (f.isFolder) {
openTFolder(leaf, getAbstractFileAtPath(plugin.app, f.path) as TFolder, plugin, flow);
} else if (f) {
openTFile(leaf, getAbstractFileAtPath(plugin.app, f.path) as TFile, plugin.app);
} else {
return;
}
} else {
if (path.contains('/')) {
const folder = removeTrailingSlashFromFolder(getParentPathFromString(path));
const spaceFolder = plugin.superstate.spacesIndex.get(folder);
if (spaceFolder) {
newPathInSpace(
plugin.superstate,
spaceFolder,
fileExtensionForFile(path),
fileNameForFile(path),
);
}
} else {
defaultSpace(plugin.superstate, plugin.superstate.pathsIndex.get(plugin.superstate.ui.activePath)).then(f => {
if (f)
newPathInSpace(
plugin.superstate,
f,
fileExtensionForFile(path),
fileNameForFile(path),
)});
}
}})

};



Expand Down Expand Up @@ -377,7 +282,7 @@ export const openTFile = async (

};

const openTFolder = async (
export const openTFolder = async (
leaf: WorkspaceLeaf,
file: TFolder,
plugin: MakeMDPlugin,
Expand Down
2 changes: 1 addition & 1 deletion src/basics/basics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class MakeBasicsPlugin {
this.app = plugin.app;
if (plugin.app.plugins.getPlugin("make-md")) {
const mkmdEnactor = new MakeMDEnactor(
plugin.app.plugins.getPlugin("make-md").superstate,
plugin.app.plugins.getPlugin("make-md"),
this
);
this.enactor = mkmdEnactor;
Expand Down
2 changes: 1 addition & 1 deletion src/basics/codemirror/flowEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { hoverTooltip } from "basics/tooltip";
import React from "react";
import { flowTypeStateField } from "./flowStateFields";

import { i18n } from "makemd-core";
import i18n from "shared/i18n";

import MakeBasicsPlugin from "basics/basics";
import { FlowEditorHover } from "basics/flow/FlowEditorHover";
Expand Down
2 changes: 1 addition & 1 deletion src/basics/codemirror/placeholder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RangeSetBuilder, StateField } from "@codemirror/state";
import { Decoration, DecorationSet, EditorView } from "@codemirror/view";
import MakeBasicsPlugin from "basics/basics";
import { i18n } from "makemd-core";
import i18n from "shared/i18n";
const placeholderLine = (plugin: MakeBasicsPlugin) => Decoration.line({
attributes: { "data-ph": i18n.labels.placeholder.replace('${1}', plugin.settings.menuTriggerChar) },
class: "mk-placeholder",
Expand Down
2 changes: 1 addition & 1 deletion src/basics/enactor/enactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Enactor {
selectLink(e: React.MouseEvent, onSelect: (path: string) => void): void;
selectSpace(e: React.MouseEvent, onSelect: (path: string) => void): void;
pathExists(path: string): Promise<boolean>;
selectImage(onSelect: (path: string) => void, win: Window): void;
selectImage(e: React.MouseEvent, onSelect: (path: string) => void): void;
isSpace(path: string): boolean;
loadExtensions(firstLoad: boolean): void;
spaceNotePath(path: string): string | null;
Expand Down
Loading

0 comments on commit 1351286

Please sign in to comment.