Skip to content

Commit

Permalink
0.9.994
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-cen committed Jul 26, 2024
1 parent b16e4c0 commit 8b311fd
Show file tree
Hide file tree
Showing 13 changed files with 1,145 additions and 1,033 deletions.
1,920 changes: 987 additions & 933 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.993",
"version": "0.9.994",
"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
3 changes: 2 additions & 1 deletion src/core/assets/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,5 +768,6 @@ export const uiIconSet: Record<string, string> = {
'move': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-move"><polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" x2="22" y1="12" y2="12"/><line x1="12" x2="12" y1="2" y2="22"/></svg>`,
'wildcard': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-asterisk"><path d="M12 6v12"/><path d="M17.196 9 6.804 15"/><path d="m6.804 9 10.392 6"/></svg>`,
'replace': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-replace"><path d="M14 4c0-1.1.9-2 2-2"/><path d="M20 2c1.1 0 2 .9 2 2"/><path d="M22 8c0 1.1-.9 2-2 2"/><path d="M16 10c-1.1 0-2-.9-2-2"/><path d="m3 7 3 3 3-3"/><path d="M6 10V5c0-1.7 1.3-3 3-3h1"/><rect width="8" height="8" x="2" y="14" rx="2"/></svg>`,
'alias': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-at-sign"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/></svg>`
'alias': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-at-sign"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/></svg>`,
'import': `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-import"><path d="M12 3v12"/><path d="m8 11 4 4 4-4"/><path d="M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4"/></svg>`
};
7 changes: 4 additions & 3 deletions src/core/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ class T {
propertyValueSpace: "Space",
propertyValueProperty: "Property",
propertyLookup: "Edit Formula",

existingFrontmatter: "Existing Property",
dateFormat: "Date Format",
propertyFileProp: "Property",
multiple: "Multiple",
Expand Down Expand Up @@ -662,6 +662,7 @@ class T {
fileExists: "File Already Exists",
folderExists: "Folder Already Exists",
noPropertyName: "Property Name is Required",
noPropertiesFound: "No Properties Found",
duplicatePropertyName: "Duplicate Property Name",
newSpaceName: "Enter a name for your space",
duplicateSpaceName: "Space name already exists",
Expand Down Expand Up @@ -772,8 +773,8 @@ class T {
desc: "Layout for inline title and sticker in Inline Context",
},
hideFrontmatter: {
name: "Hide Frontmatter Properties",
desc: "Hide the frontmatter properties in inline context",
name: "Hide Context Properties",
desc: "Hide properties you have addeed in context from the Obsidian properties panel",
},
openFileContext: {
name: "Auto Open Explorer",
Expand Down
64 changes: 32 additions & 32 deletions src/core/react/components/Explorer/PropertiesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export const PropertiesView = (props: {
newCols.filter((f) => !props.excludeKeys?.some((g) => g == f.name))
);
setExcludeKeys([
...columns.map((f) => f.name),
...(props.superstate.settings.hideFrontmatter
? columns.map((f) => f.name)
: []),
...(props.excludeKeys ?? []),
]);
setValues(
Expand Down Expand Up @@ -314,7 +316,7 @@ export const PropertiesView = (props: {
selectType
);
};
const propertiessuperstate = props.superstate.settings.hideFrontmatter;

return (
<>
{props.compactMode ? (
Expand Down Expand Up @@ -345,36 +347,34 @@ export const PropertiesView = (props: {
source={pathState.path}
></DataPropertyView>
))
) : !propertiessuperstate || props.force ? (
<>
{cols.map((f, i) => (
<DataPropertyView
key={i}
path={pathState.path}
propertyMenu={(e) => showMenu(e, f)}
superstate={props.superstate}
initialValue={values[f.name]}
row={values}
compactMode={props.compactMode}
column={{ ...f, table: "" }}
columns={[]}
editMode={
!props.editable
? CellEditMode.EditModeView
: CellEditMode.EditModeAlways
}
updateValue={(value) => savePropertyValue(value, f)}
updateFieldValue={(fieldValue, value) =>
savePropertyValue(value, {
...f,
value: fieldValue,
})
}
contextTable={{}}
source={pathState.path}
></DataPropertyView>
))}
</>
) : props.force ? (
cols.map((f, i) => (
<DataPropertyView
key={i}
path={pathState.path}
propertyMenu={(e) => showMenu(e, f)}
superstate={props.superstate}
initialValue={values[f.name]}
row={values}
compactMode={props.compactMode}
column={{ ...f, table: "" }}
columns={[]}
editMode={
!props.editable
? CellEditMode.EditModeView
: CellEditMode.EditModeAlways
}
updateValue={(value) => savePropertyValue(value, f)}
updateFieldValue={(fieldValue, value) =>
savePropertyValue(value, {
...f,
value: fieldValue,
})
}
contextTable={{}}
source={pathState.path}
></DataPropertyView>
))
) : (
<></>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const TreeItem = (props: TreeItemProps) => {
const [pathState, setPathState] = useState<PathState>(
superstate.pathsIndex.get(data.item.path)
);
const pinType = pathState.linkedSpaces?.some((f) => f == data.space)
const pinType = pathState?.linkedSpaces?.some((f) => f == data.space)
? PinType.Linked
: pathState.liveSpaces?.some((f) => f == data.space)
? PinType.Live
Expand Down
26 changes: 0 additions & 26 deletions src/core/react/components/UI/Menus/contexts/PropertyValue.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import i18n from "core/i18n";
import { FormulaEditor } from "core/react/components/SpaceEditor/Actions/FormulaEditor";
import { filePropTypes } from "core/react/components/SpaceView/Contexts/TableView/ColumnHeader";
import { parseFieldValue } from "core/schemas/parseFieldValue";
import { Superstate } from "core/superstate/superstate";
import { allCacheTypesForPaths } from "core/utils/properties/allProperties";
import { spaceNameFromSpacePath } from "core/utils/strings";
import React, { useMemo } from "react";
import {
Expand Down Expand Up @@ -139,31 +137,7 @@ export const PropertyValueComponent = (props: {
})) ?? [];
showOptions(e, null, properties, "field");
};
const selectPathProp = (e: React.MouseEvent) => {
const property = props.fields.find((f) => f.name == parsedValue.field);
const allPaths = props.superstate.spaceManager.allPaths();

const fileProps = property
? property.type == "file" || property.type == "link"
? filePropTypes.map((f) => ({
name: f.name,
value: f.value,
}))
: props.superstate.contextsIndex
.get(
parseFieldValue(property.value, "context", props.superstate).space
)
?.contextTable?.cols.filter((f) => f.hidden != "true")
.map((f) => ({
name: f.name,
value: f.name,
})) ?? []
: [];
const cacheTypes = allCacheTypesForPaths(props.superstate, allPaths).map(
(f) => ({ name: f.name, value: f.name })
);
showOptions(e, null, [...fileProps, ...cacheTypes], "value");
};
const editFormula = (e: React.MouseEvent) => {
const _props = {
superstate: props.superstate,
Expand Down
101 changes: 96 additions & 5 deletions src/core/react/components/UI/Menus/contexts/newSpacePropertyMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import i18n from "core/i18n";

import { Superstate } from "core/superstate/superstate";
import { FMSpaceKeys } from "core/superstate/utils/spaces";
import { FMMetadataKeys } from "core/types/space";
import { allPropertiesForPaths } from "core/utils/properties/allProperties";
import React, { useEffect, useMemo, useRef, useState } from "react";
import { fieldTypeForType, fieldTypes } from "schemas/mdb";
import { Rect } from "types/Pos";
import {
defaultContextSchemaID,
fieldTypeForType,
fieldTypes,
stickerForField,
} from "schemas/mdb";
import { SpaceProperty, SpaceTableColumn } from "types/mdb";
import { Rect } from "types/Pos";
import { windowFromDocument } from "utils/dom";
import { folderPathToString } from "utils/path";
import { menuSeparator } from "../menu/SelectionMenu";
import { PropertyValueComponent } from "./PropertyValue";

export type NewPropertyMenuProps = {
Expand Down Expand Up @@ -155,6 +164,76 @@ const NewPropertyMenuComponent = (
}, 50);
}, []);
const input = useRef(null);
const addExistingProperty = (e: React.MouseEvent) => {
const source = fieldSource == "" ? props.contextPath : fieldSource;
e.stopPropagation();
const existingCols =
props.superstate.contextsIndex.get(source)?.contextTable?.cols ?? [];
const existingProps: SpaceProperty[] = allPropertiesForPaths(
props.superstate,
[...(props.superstate.spacesMap.getInverse(source) ?? [])]
)
.filter(
(f) =>
!existingCols.some((g) => g.name == f.name) &&
![
...FMMetadataKeys(props.superstate.settings),
"tags",
...FMSpaceKeys(props.superstate.settings),
].some((g) => g == f.name)
)
.map((f) => ({
name: f.name,
type: f.type,
value: "",
schemaId: props.schemaId,
}));
if (existingProps.length == 0) {
props.superstate.ui.notify(i18n.notice.noPropertiesFound);
return;
}
props.superstate.ui.openMenu(
(e.target as HTMLElement).getBoundingClientRect(),
{
ui: props.superstate.ui,
multi: false,
editable: false,
searchable: true,
saveOptions: (_: string[], value: any[]) => {
if (value[0] == "all") {
props.superstate.spaceManager
.readTable(source, defaultContextSchemaID)
.then((f) =>
props.superstate.spaceManager.saveTable(source, {
...f,
cols: [...f.cols, ...existingProps],
})
)
.then((f) => props.superstate.reloadContextByPath(source));
props.hide();
return;
}
const result = props.saveField(fieldSource, value[0]);
if (result) props.hide();
},
value: [],
showAll: true,
options: [
{ name: i18n.labels.all, value: "all", icon: "ui//plus" },
menuSeparator,
...existingProps.map((f, i) => ({
id: i + 1,
name: f.name,
value: f,
icon: stickerForField(f),
})),
],
placeholder: i18n.labels.existingFrontmatter,
},
windowFromDocument(e.view.document)
);
};

return (
<div className="mk-menu-container">
<div className="mk-menu-suggestions">
Expand All @@ -168,7 +247,18 @@ const NewPropertyMenuComponent = (
onMouseDown={(e) => e.stopPropagation()}
value={fieldName}
/>
{fieldSource != "$fm" && (
<button
aria-label={i18n.labels.existingFrontmatter}
className="mk-toolbar-button"
onClick={(e) => addExistingProperty(e)}
dangerouslySetInnerHTML={{
__html: props.superstate.ui.getSticker("ui//import"),
}}
></button>
)}
</div>

<div className="mk-menu-separator"></div>
{options.length > 1 && (
<div className="mk-menu-option" onClick={(e) => selectSource(e)}>
Expand All @@ -179,14 +269,15 @@ const NewPropertyMenuComponent = (
{fieldSource == "$fm"
? "None"
: fieldSource == ""
? props.contextPath
: fieldSource}
? props.superstate.spacesIndex.get(props.contextPath)?.name
: props.superstate.spacesIndex.get(fieldSource)?.name}
</span>
</div>
)}

<div className="mk-menu-option" onClick={(e) => selectType(e)}>
<div className="mk-menu-options-inner">
{i18n.labels.propertyValueProperty}
{i18n.labels.propertyType}
</div>
<span>{type.label}</span>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/core/superstate/superstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ public api: API;
})

}
const runContext = math.create(all)
const config :math.ConfigOptions = {
matrix: "Array"
}
const runContext = math.create(all, config)
runContext.import(formulas, { override: true })
this.formulaContext = runContext;
//Initialize
Expand Down
5 changes: 4 additions & 1 deletion src/core/superstate/workers/indexer/indexer.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const all = {
})

}
const runContext = math.create(all)
const config :math.ConfigOptions = {
matrix: "Array"
}
const runContext = math.create(all, config)
runContext.import(formulas, { override: true })

ctx.onmessage = async evt => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/formula/formulas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,16 @@ const map = (args: MathNode[], math: any, scope: Map<string, any>) => {
: args[0];

if (Array.isArray(arr)) {

return arr.map((f, i) => {
scope.set("$current", f);
scope.set("$index", i);
math.evaluate("current = _current(); index = _index()", scope)
const result = args[1].compile().evaluate(scope);

return result;
});
}
return "";
return [];
}
map.rawArgs = true;

Expand Down
10 changes: 8 additions & 2 deletions src/core/utils/formula/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ export const runFormulaNode = (node: FormulaNode, propMap: DBRow): string => {


}
const runContext = math.create(all)
const config :math.ConfigOptions = {
matrix: "Array"
}
const runContext = math.create(all, config)
runContext.import(formulas, { override: true })
if (node.type === "literal") {
return node.value
Expand Down Expand Up @@ -345,7 +348,10 @@ export const runFormula = (paths: Map<string, PathState>, formula: string, prope
})

}
const runContext = math.create(all)
const config :math.ConfigOptions = {
matrix: "Array"
}
const runContext = math.create(all, config)
runContext.import(formulas, { override: true })
let value;
try {
Expand Down
Loading

0 comments on commit 8b311fd

Please sign in to comment.