Skip to content

Commit

Permalink
1.0.1 refactor for basics
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Dec 27, 2024
1 parent 4c3924c commit c452a2b
Show file tree
Hide file tree
Showing 356 changed files with 3,815 additions and 2,858 deletions.
498 changes: 252 additions & 246 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.0",
"version": "1.0.1",
"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/dataview/metadata/dataviewReader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TFile } from "obsidian";
import { uniqCaseInsensitive } from "utils/array";
import { uniqCaseInsensitive } from "shared/utils/array";
import { DataViewMarkdownFiletypeAdapter } from "../dataviewMarkdownAdapter";
import { parseDataview } from "./parseDataview";

Expand Down
8 changes: 4 additions & 4 deletions src/adapters/mdb/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { getParentPathFromString } from "utils/path";

import { MDBFileTypeAdapter } from "adapters/mdb/mdbAdapter";
import JSZip from "jszip";
import { DBRows, DBTable, DBTables, SpaceTables } from "shared/types/mdb";
import { uniq } from "shared/utils/array";
import { removeTrailingSlashFromFolder } from "shared/utils/paths";
import { sanitizeSQLStatement } from "shared/utils/sanitizers";
import { Database, QueryExecResult, SqlJsStatic } from "sql.js";
import { DBRows, DBTable, DBTables, SpaceTables } from "types/mdb";
import { uniq } from "utils/array";
import { removeTrailingSlashFromFolder } from "utils/path";
import { sanitizeSQLStatement } from "utils/sanitizers";
import { serializeSQLFieldNames, serializeSQLStatements, serializeSQLValues } from "utils/serializers";

JSZip.support.nodebuffer = false;
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/mdb/localCache/localCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { dbResultsToDBTables, deleteFromDB, getZippedDB, insertIntoDB, replaceDB
import { MDBFileTypeAdapter } from "adapters/mdb/mdbAdapter";
import { debounce } from "lodash";
import { CacheDBSchema } from "schemas/cache";
import { DBRow, DBTables } from "shared/types/mdb";
import { sanitizeSQLStatement } from "shared/utils/sanitizers";
import { Database } from "sql.js";
import { DBRow, DBTables } from "types/mdb";
import { sanitizeSQLStatement } from "utils/sanitizers";
import { LocalCachePersister } from "../../../core/middleware/types/persister";
import { LocalCachePersister } from "../../../shared/types/persister";

/** Simpler wrapper for a file-backed cache for arbitrary metadata. */
export class LocalStorageCache implements LocalCachePersister {
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/mdb/localCache/localCacheMobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { dbResultsToDBTables, getZippedDB, replaceDB, saveZippedDBFile, saveZipp
import { MDBFileTypeAdapter } from "adapters/mdb/mdbAdapter";
import { debounce } from "lodash";
import { CacheDBSchema } from "schemas/cache";
import { DBRow } from "types/mdb";
import { LocalCachePersister } from "../../../core/middleware/types/persister";
import { DBRow } from "shared/types/mdb";
import { LocalCachePersister } from "../../../shared/types/persister";


/** Simpler wrapper for a file-backed cache for arbitrary metadata. */
Expand Down
8 changes: 4 additions & 4 deletions src/adapters/mdb/mdbAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { frameSchemaToTableSchema } from 'core/utils/frames/nodes';
import _ from 'lodash';
import MakeMDPlugin from 'main';
import { AFile, FileTypeAdapter, FilesystemMiddleware } from 'makemd-core';
import { fieldSchema } from 'schemas/mdb';
import { Command } from 'types/commands';
import { DBTable, DBTables, MDB, SpaceProperty, SpaceTable, SpaceTableSchema, SpaceTables } from 'types/mdb';
import { MDBFrame } from 'types/mframe';
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 { loadSQL } from "./db/sqljs";
import { deletePropertyToDBTables, savePropertyToDBTables } from './utils/property';
import { saveSchemaToDBTables } from './utils/schema';
Expand Down
10 changes: 4 additions & 6 deletions src/adapters/mdb/utils/mdb.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@

import {
DBTable,
FilesystemSpaceInfo,
MDB,
SpaceProperty,
SpaceTable,
SpaceTableSchema,
SpaceTables
} from "types/mdb";
} from "shared/types/mdb";
import { FilesystemSpaceInfo } from "shared/types/spaceInfo";

import { vaultSchema } from "adapters/obsidian/filesystem/schemas/vaultSchema";
import {
defaultFieldsForContext
} from "schemas/mdb";
import { defaultFieldsForContext } from "shared/schemas/fields";
import { sanitizeSQLStatement } from "shared/utils/sanitizers";
import { Database, QueryExecResult } from "sql.js";
import { sanitizeSQLStatement } from "utils/sanitizers";
import {
dbResultsToDBTables,
deleteFromDB,
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/mdb/utils/property.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fieldSchema } from "schemas/mdb";
import { DBTables, SpaceProperty } from "types/mdb";
import { sanitizeColumnName } from "utils/sanitizers";
import { fieldSchema } from "shared/schemas/fields";
import { DBTables, SpaceProperty } from "shared/types/mdb";
import { sanitizeColumnName } from "shared/utils/sanitizers";

export const savePropertyToDBTables = (newColumn: SpaceProperty, fields: SpaceProperty[], oldColumn?: SpaceProperty): DBTables => {
const column = {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/mdb/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DBTable, SpaceTableSchema } from "types/mdb";
import { DBTable, SpaceTableSchema } from "shared/types/mdb";

export const saveSchemaToDBTables = (table: SpaceTableSchema, schemas: SpaceTableSchema[]) => {
const newSchema = schemas.find((f) => f.id == table.id)
Expand Down
37 changes: 16 additions & 21 deletions src/adapters/obsidian/SpaceViewContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import classNames from "classnames";
import { SystemSettings } from "core/react/components/System/SystemSettings";
import { SpaceView, Superstate } from "makemd-core";
import { ItemView, ViewStateResult, WorkspaceLeaf } from "obsidian";
import React from "react";
Expand Down Expand Up @@ -145,27 +144,23 @@ export class SpaceViewContainer extends ItemView {
if (this.root) {
this.root.render(
<div className="mk-space-view" data-path={path}>
{path == "spaces://$settings" ? (
<SystemSettings superstate={this.superstate}></SystemSettings>
) : (
<SpaceView
path={path}
superstate={this.superstate}
key={path}
readOnly={false}
<SpaceView
path={path}
superstate={this.superstate}
key={path}
readOnly={false}
>
<div
className={classNames(
"mk-space-scroller markdown-source-view mod-cm6"
)}
>
<div
className={classNames(
"mk-space-scroller markdown-source-view mod-cm6"
)}
>
<SpaceInner
superstate={this.superstate}
header={true}
></SpaceInner>
</div>
</SpaceView>
)}
<SpaceInner
superstate={this.superstate}
header={true}
></SpaceInner>
</div>
</SpaceView>
</div>
);
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/adapters/obsidian/commands/obsidianCommands.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { CLIAdapter, CLIManager } from "core/middleware/commands";
import { parseURI } from "core/utils/uri";
import { CLIManager } from "core/middleware/commands";
import MakeMDPlugin from "main";
import { Command as ObsidianCommand } from "obsidian";
import { CommandWithPath } from "types/commands";
import { CLIAdapter } from "shared/types/actions";
import { CommandWithPath } from "shared/types/commands";
import { parseURI } from "shared/utils/uri";

const obsidianCommandToCommand = (command: ObsidianCommand) : CommandWithPath => {
if (!command) return null;
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/fileSystemPathFixer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { updatePrimaryAlias } from "core/superstate/utils/label";
import MakeMDPlugin from "main";
import { TFile } from "obsidian";
import React from "react";
import { sanitizeFileName } from "utils/sanitizers";
import { sanitizeFileName } from "shared/utils/sanitizers";

export const openPathFixer = (plugin: MakeMDPlugin) => {
const superstate = plugin.superstate;
Expand Down
11 changes: 6 additions & 5 deletions src/adapters/obsidian/filesystem/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import { AFile, FileCache, FileSystemAdapter, FileTypeCache, FilesystemMiddlewar
import { FileSystemAdapter as ObsidianFileSystemAdapter, Platform, TAbstractFile, TFile, TFolder, normalizePath } from "obsidian";

import { LocalStorageCache } from "adapters/mdb/localCache/localCache";
import { LocalCachePersister } from "core/middleware/types/persister";
import { LocalCachePersister } from "shared/types/persister";

import { MobileCachePersister } from "adapters/mdb/localCache/localCacheMobile";
import { DEFAULT_SETTINGS } from "core/schemas/settings";
import { defaultFocusFile } from "core/spaceManager/filesystemAdapter/filesystemAdapter";
import { parsePathState } from "core/utils/superstate/parser";
import { parseURI } from "core/utils/uri";
import { DBRows, DBTables } from "types/mdb";
import { uniqueNameFromString } from "utils/array";
import { getParentPathFromString, pathToString, removeTrailingSlashFromFolder } from "utils/path";
import { DBRows, DBTables } from "shared/types/mdb";
import { uniqueNameFromString } from "shared/utils/array";
import { removeTrailingSlashFromFolder } from "shared/utils/paths";
import { parseURI } from "shared/utils/uri";
import { getParentPathFromString, pathToString } from "utils/path";
import { urlRegex } from "utils/regex";
import { serializeMultiDisplayString } from "utils/serializers";
import { getAllFrontmatterKeys } from "../filetypes/frontmatter/fm";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/filesystem/indexCurrentFileTree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vaultSchema } from "adapters/obsidian/filesystem/schemas/vaultSchema";
import MakeMDPlugin from "main";
import { TFile, TFolder } from "obsidian";
import { DBRows, DBTables } from "types/mdb";
import { DBRows, DBTables } from "shared/types/mdb";
import { getAllAbstractFilesInVault } from "../utils/file";


Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/filesystem/schemas/vaultSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DBTable } from "types/mdb";
import { DBTable } from "shared/types/mdb";


export const vaultSchema: DBTable = {
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/obsidian/filesystem/spaceFileOps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { retrieveAllRecursiveChildren } from "core/spaceManager/filesystemAdapte
import MakeMDPlugin from "main";
import { i18n } from "makemd-core";
import React from "react";
import { FilesystemSpaceInfo } from "types/mdb";
import { windowFromDocument } from "utils/dom";
import { FilesystemSpaceInfo } from "shared/types/spaceInfo";
import { windowFromDocument } from "shared/utils/dom";

export const moveSpaceFiles = async (
plugin: MakeMDPlugin,
Expand Down Expand Up @@ -43,7 +43,7 @@ export const deleteSpaceFiles = async (plugin: MakeMDPlugin, doc: Document) => {
const spaceSubFolder = settings.spaceSubFolder;

const allChildren = retrieveAllRecursiveChildren(
plugin.superstate.vaultDBCache,
plugin.obsidianAdapter.vaultDBCache,
settings,
settings.spacesFolder
);
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/obsidian/filetypes/frontmatter/fm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getAllAbstractFilesInVault } from "adapters/obsidian/utils/file";
import { saveProperties } from "core/superstate/utils/spaces";
import { PathPropertyName } from "core/types/context";
import MakeMDPlugin from "main";
import {
App,
Expand All @@ -9,8 +8,9 @@ import {
TAbstractFile,
TFile
} from "obsidian";
import { DBTable, SpaceTable } from "types/mdb";
import { onlyUniquePropCaseInsensitive, uniq } from "utils/array";
import { PathPropertyName } from "shared/types/context";
import { DBTable, SpaceTable } from "shared/types/mdb";
import { onlyUniquePropCaseInsensitive, uniq } from "shared/utils/array";

import { defaultValueForType, parseMDBStringValue, yamlTypeToMDBType } from "utils/properties";

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/obsidian/filetypes/markdownAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IndexMap } from "core/types/indexMap";
import _ from "lodash";
import MakeMDPlugin from "main";
import { AFile, FileTypeAdapter, FilesystemMiddleware, PathLabel } from "makemd-core";
import { App, CachedMetadata, TFile, TFolder } from "obsidian";
import { uniq } from "utils/array";
import { IndexMap } from "shared/types/indexMap";
import { uniq } from "shared/utils/array";
import { parseMultiDisplayString, parseProperty } from "utils/parsers";
import { getAbstractFileAtPath, tFileToAFile } from "../utils/file";
import { frontMatterForFile } from "./frontmatter/fm";
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/obsidian/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MakeBasicsSettingsTab } from "basics/ui/SettingsPanel";
import t from "core/i18n";
import { App, PluginSettingTab, Setting } from "obsidian";
import { MakeMDSettings } from "../../core/types/settings";
import t from "shared/i18n";
import MakeMDPlugin from "../../main";
import { MakeMDSettings } from "../../shared/types/settings";

type SettingObject = {
name: keyof MakeMDSettings;
Expand Down
1 change: 1 addition & 0 deletions src/adapters/obsidian/types/obsidian.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare module "obsidian" {
}
interface App {
appId: string;
plugins: any;
dragManager: any;
commands: {
listCommands(): Command[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { BannerView } from "core/react/components/MarkdownEditor/BannerView";
import { DataPropertyView } from "core/react/components/SpaceView/Contexts/DataTypeView/DataPropertyView";
import { CellEditMode } from "core/react/components/SpaceView/Contexts/TableView/TableView";
import { PathProvider } from "core/react/context/PathContext";
import { PathState } from "core/types/superstate";
import { Superstate } from "makemd-core";
import React, { useEffect, useMemo, useState } from "react";
import { SpaceTableColumn } from "types/mdb";
import { uniqCaseInsensitive } from "utils/array";
import { SpaceTableColumn } from "shared/types/mdb";
import { PathState } from "shared/types/PathState";
import { uniqCaseInsensitive } from "shared/utils/array";
import { parseProperty } from "utils/parsers";
import { pathNameToString } from "utils/path";
import { detectPropertyType, yamlTypeToMDBType } from "utils/properties";
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 @@ -2,7 +2,7 @@ import { installSpaceKit } from "adapters/obsidian/ui/kit/kits";
import MakeMDPlugin from "main";
import { Superstate } from "makemd-core";
import React, { useState } from "react";
import { windowFromDocument } from "utils/dom";
import { windowFromDocument } from "shared/utils/dom";
import { safelyParseJSON } from "utils/parsers";
import { Dropdown } from "../../../../core/react/components/UI/Dropdown";
import { showSpacesMenu } from "../../../../core/react/components/UI/Menus/properties/selectSpaceMenu";
Expand Down
12 changes: 7 additions & 5 deletions src/adapters/obsidian/ui/kit/kits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
import { getMDBTables } from "adapters/mdb/utils/mdb";
import { regexYaml } from "adapters/text/textCacher";
import { createSpace, newPathInSpace, parseSpaceMetadata, saveProperties } from "core/superstate/utils/spaces";
import { PathPropertyName } from "core/types/context";
import { SpaceDefinition, SpaceType } from "core/types/space";
import MakeMDPlugin from "main";
import { Superstate } from "makemd-core";
import { parseYaml } from "obsidian";
import { defaultFrameSchema } from "schemas/frames";
import { defaultContextSchemaID, fieldSchema } from "schemas/mdb";
import { Note, SpaceKit, TemplateKit } from "types/kits";
import { DBTables, FilesystemSpaceInfo, SpaceTables } from "types/mdb";
import { defaultContextSchemaID } from "shared/schemas/context";
import { fieldSchema } from "shared/schemas/fields";
import { PathPropertyName } from "shared/types/context";
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";

export const installSpaceTemplate = async (plugin: MakeMDPlugin, superstate: Superstate, space: string, template: TemplateKit) => {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/obsidian/ui/showMainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MakeMDPlugin from "main";
import { SelectOption, Superstate, i18n } from "makemd-core";
import { WorkspaceLeaf, WorkspaceMobileDrawer } from "obsidian";
import React from "react";
import { windowFromDocument } from "utils/dom";
import { windowFromDocument } from "shared/utils/dom";
import { FILE_TREE_VIEW_TYPE } from "./navigator/NavigatorView";

export const showMainMenu = (
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/obsidian/ui/sticker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { uiIconSet } from "core/assets/icons";
import MakeMDPlugin from "main";
import { emojiFromString, parseStickerString } from "utils/stickers";
import { uiIconSet } from "shared/assets/icons";
import { emojiFromString, parseStickerString } from "shared/utils/stickers";
import { lucideIcon } from "./icons";


Expand Down
Loading

0 comments on commit c452a2b

Please sign in to comment.