Skip to content

Commit 79204e2

Browse files
committed
1.3.1
1 parent bb5cb96 commit 79204e2

File tree

23 files changed

+1865
-1578
lines changed

23 files changed

+1865
-1578
lines changed

main.js

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "make-md",
33
"name": "make.md",
4-
"version": "1.3.0",
4+
"version": "1.3.1",
55
"minAppVersion": "0.16.0",
66
"description": "make.md gives you everything you need to organize and personalize your notes.",
77
"author": "make.md",

src/adapters/obsidian/ui/editors/MKitFileViewer.tsx

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import { getAbstractFileAtPath } from "adapters/obsidian/utils/file";
21
import { installSpaceKit } from "adapters/obsidian/ui/kit/kits";
2+
import { getAbstractFileAtPath } from "adapters/obsidian/utils/file";
3+
import { MKitProvider } from "core/react/context/MKitContext";
34
import MakeMDPlugin from "main";
4-
import { FileView, Notice, TFile, ViewStateResult, WorkspaceLeaf } from "obsidian";
5+
import {
6+
FileView,
7+
Notice,
8+
TFile,
9+
ViewStateResult,
10+
WorkspaceLeaf,
11+
} from "obsidian";
512
import React from "react";
613
import { createRoot, Root } from "react-dom/client";
714
import { SpaceKit } from "shared/types/kits";
815
import { safelyParseJSON } from "shared/utils/json";
916
import { MKitFramePreview } from "./MKitFramePreview";
10-
import { MKitProvider } from "core/react/context/MKitContext";
1117

1218
export const MKIT_FILE_VIEWER_TYPE = "mk-mkit-view";
1319
export const ICON = "package";
@@ -19,21 +25,26 @@ interface MKitViewerProps {
1925
onInstall: () => void;
2026
}
2127

22-
const MKitViewerComponent: React.FC<MKitViewerProps> = ({ plugin, spaceKit, filePath, onInstall }) => {
28+
const MKitViewerComponent: React.FC<MKitViewerProps> = ({
29+
plugin,
30+
spaceKit,
31+
filePath,
32+
onInstall,
33+
}) => {
2334
const [installing, setInstalling] = React.useState(false);
2435

2536
// Set CSS variable based on fullWidth property
2637
React.useEffect(() => {
2738
if (spaceKit?.definition?.fullWidth) {
28-
document.documentElement.style.setProperty('--page-width', '100%');
39+
document.documentElement.style.setProperty("--page-width", "100%");
2940
} else {
3041
// Reset to default if not fullWidth
31-
document.documentElement.style.removeProperty('--page-width');
42+
document.documentElement.style.removeProperty("--page-width");
3243
}
3344

3445
// Cleanup on unmount
3546
return () => {
36-
document.documentElement.style.removeProperty('--page-width');
47+
document.documentElement.style.removeProperty("--page-width");
3748
};
3849
}, [spaceKit?.definition?.fullWidth]);
3950

@@ -44,7 +55,7 @@ const MKitViewerComponent: React.FC<MKitViewerProps> = ({ plugin, spaceKit, file
4455
try {
4556
// Get the parent folder of the .mkit file as the install location
4657
const file = getAbstractFileAtPath(plugin.app, filePath) as TFile;
47-
const parentPath = file.parent?.path || '/';
58+
const parentPath = file.parent?.path || "/";
4859

4960
await installSpaceKit(plugin, plugin.superstate, spaceKit, parentPath);
5061
new Notice(`Successfully installed ${spaceKit.name}`);
@@ -70,22 +81,17 @@ const MKitViewerComponent: React.FC<MKitViewerProps> = ({ plugin, spaceKit, file
7081

7182
return (
7283
<div className="mk-mkit-viewer">
73-
<div className="mk-mkit-header">
74-
<button
75-
className="mod-cta"
76-
onClick={handleInstall}
77-
disabled={installing}
78-
>
79-
{installing ? "Installing..." : "Install Space Kit"}
80-
</button>
81-
</div>
82-
8384
<div className="mk-mkit-content">
8485
<MKitProvider spaceKit={spaceKit}>
85-
<MKitFramePreview
86-
superstate={plugin.superstate}
87-
spaceKit={spaceKit}
88-
/>
86+
<MKitFramePreview superstate={plugin.superstate} spaceKit={spaceKit}>
87+
<button
88+
className="mod-cta"
89+
onClick={handleInstall}
90+
disabled={installing}
91+
>
92+
{installing ? "Installing..." : "Install Space Kit"}
93+
</button>
94+
</MKitFramePreview>
8995
</MKitProvider>
9096
</div>
9197
</div>
@@ -126,7 +132,7 @@ export class MKitFileViewer extends FileView {
126132
}
127133
// Clean up CSS variable
128134
if (this.contentEl) {
129-
this.contentEl.style.removeProperty('--page-width');
135+
this.contentEl.style.removeProperty("--page-width");
130136
}
131137
}
132138

@@ -184,7 +190,7 @@ export class MKitFileViewer extends FileView {
184190

185191
// Check if fullWidth is set and apply CSS variable
186192
if (this.spaceKit?.definition?.fullWidth) {
187-
this.contentEl.style.setProperty('--page-width', '100%');
193+
this.contentEl.style.setProperty("--page-width", "100%");
188194
}
189195

190196
// Use the plugin's UI createRoot method if available, otherwise use React's createRoot
@@ -208,15 +214,13 @@ export class MKitFileViewer extends FileView {
208214
/>
209215
);
210216
}
211-
212217
} catch (error) {
213218
console.error("Failed to load MKit file:", error);
214219
this.contentEl.empty();
215220
this.contentEl.createEl("div", {
216221
cls: "mk-mkit-error",
217-
text: `Failed to load MKit file: ${error.message}`
222+
text: `Failed to load MKit file: ${error.message}`,
218223
});
219224
}
220225
}
221-
222-
}
226+
}

src/adapters/obsidian/ui/editors/MKitFramePreview.tsx

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { FrameRootProvider } from "core/react/context/FrameRootContext";
44
import { FramesMDBProvider } from "core/react/context/FramesMDBContext";
55
import { PathProvider } from "core/react/context/PathContext";
66
import { SpaceProvider } from "core/react/context/SpaceContext";
7-
import { useSpaceManager } from "core/react/context/SpaceManagerContext";
87
import { Superstate } from "makemd-core";
9-
import { PathState } from "shared/types/superstate";
10-
import React, { useMemo } from "react";
8+
import React, { PropsWithChildren, useMemo } from "react";
119
import { defaultContextSchemaID } from "shared/schemas/context";
1210
import { SpaceKit } from "shared/types/kits";
1311
import { DBTable, SpaceProperty, SpaceTableSchema } from "shared/types/mdb";
1412
import { FrameTreeProp, MDBFrames } from "shared/types/mframe";
1513
import { SpaceInfo } from "shared/types/spaceInfo";
14+
import { PathState } from "shared/types/superstate";
1615
import { mdbSchemaToFrameSchema } from "shared/utils/makemd/schema";
1716

1817
interface MKitFramePreviewProps {
@@ -21,13 +20,9 @@ interface MKitFramePreviewProps {
2120
frameId?: string;
2221
}
2322

24-
export const MKitFramePreview: React.FC<MKitFramePreviewProps> = ({
25-
superstate,
26-
spaceKit,
27-
frameId,
28-
}) => {
29-
const spaceManager = useSpaceManager();
30-
23+
export const MKitFramePreview: React.FC<
24+
PropsWithChildren<MKitFramePreviewProps>
25+
> = ({ children, superstate, spaceKit, frameId }) => {
3126
// Create pseudo path for preview
3227
const pseudoPath: PathState = useMemo(
3328
() => ({
@@ -172,21 +167,24 @@ export const MKitFramePreview: React.FC<MKitFramePreviewProps> = ({
172167
const bannerUri = useMemo(() => {
173168
// Check various possible property names for banner/cover
174169
const bannerKey = Object.keys(spaceKit.properties || {}).find(
175-
key => key.toLowerCase().includes('banner') ||
176-
key.toLowerCase().includes('cover') ||
177-
key.toLowerCase().includes('image')
170+
(key) =>
171+
key.toLowerCase().includes("banner") ||
172+
key.toLowerCase().includes("cover") ||
173+
key.toLowerCase().includes("image")
178174
);
179-
175+
180176
if (bannerKey && spaceKit.properties[bannerKey]) {
181-
return superstate.spaceManager.uriByString(spaceKit.properties[bannerKey]);
177+
return superstate.spaceManager.uriByString(
178+
spaceKit.properties[bannerKey]
179+
);
182180
}
183-
181+
184182
// Check if there's a banner in the label properties
185183
const labelProperties = spaceKit.context?.label?.rows?.[0];
186184
if (labelProperties?.banner) {
187185
return superstate.spaceManager.uriByString(labelProperties.banner);
188186
}
189-
187+
190188
return null;
191189
}, [spaceKit, superstate]);
192190

@@ -228,52 +226,53 @@ export const MKitFramePreview: React.FC<MKitFramePreviewProps> = ({
228226
className="mk-mkit-banner"
229227
style={{
230228
backgroundImage: `url("${
231-
bannerUri.scheme === 'vault'
229+
bannerUri.scheme === "vault"
232230
? superstate.ui.getUIPath(bannerUri.basePath)
233231
: bannerUri.fullPath
234232
}")`,
235-
backgroundSize: 'cover',
236-
backgroundPosition: 'center',
237-
height: '200px'
233+
backgroundSize: "cover",
234+
backgroundPosition: "center",
235+
height: "200px",
238236
}}
239237
/>
240238
)}
241-
<div className="mk-mkit-header">
242-
<h1 className="mk-mkit-title">{spaceKit.name}</h1>
243-
</div>
244-
<PathProvider
245-
superstate={superstate}
246-
path={pseudoPath.path}
247-
pathState={pseudoPath}
248-
readMode={true}
249-
>
250-
<SpaceProvider superstate={superstate} spaceInfo={spaceInfo}>
251-
<FramesMDBProvider
252-
superstate={superstate}
253-
>
254-
<FrameRootProvider
255-
superstate={superstate}
256-
path={superstate.spaceManager.uriByString(pseudoPath.path)}
257-
cols={[]}
258-
previewMode={true}
259-
frame={mdbFrames.main}
260-
>
261-
<FrameInstanceProvider
262-
id="mkit-preview"
239+
<div className="mk-mkit-body">
240+
<div className="mk-mkit-header">
241+
<h1 className="mk-mkit-title">{spaceKit.name}</h1>
242+
{children}
243+
</div>
244+
<PathProvider
245+
superstate={superstate}
246+
path={pseudoPath.path}
247+
pathState={pseudoPath}
248+
readMode={true}
249+
>
250+
<SpaceProvider superstate={superstate} spaceInfo={spaceInfo}>
251+
<FramesMDBProvider superstate={superstate}>
252+
<FrameRootProvider
263253
superstate={superstate}
264-
props={{}}
265-
contexts={contexts}
266-
editable={false}
254+
path={superstate.spaceManager.uriByString(pseudoPath.path)}
255+
cols={[]}
256+
previewMode={true}
257+
frame={mdbFrames.main}
267258
>
268-
<FrameInstanceView
259+
<FrameInstanceProvider
260+
id="mkit-preview"
269261
superstate={superstate}
270-
source={pseudoPath.path}
271-
/>
272-
</FrameInstanceProvider>
273-
</FrameRootProvider>
274-
</FramesMDBProvider>
275-
</SpaceProvider>
276-
</PathProvider>
262+
props={{}}
263+
contexts={contexts}
264+
editable={false}
265+
>
266+
<FrameInstanceView
267+
superstate={superstate}
268+
source={pseudoPath.path}
269+
/>
270+
</FrameInstanceProvider>
271+
</FrameRootProvider>
272+
</FramesMDBProvider>
273+
</SpaceProvider>
274+
</PathProvider>
275+
</div>
277276
</div>
278277
);
279278
};

src/core/react/components/SpaceView/Contexts/ContextListContainer.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const ContextListContainer = (props: {
3535
}) => {
3636
const flattenedItems = useRef<Record<string, [string, DBRow, Pos]>>({});
3737
const { pathState } = useContext(PathContext);
38-
const spaceManager = useSpaceManager();
38+
const spaceManager = useSpaceManager() || props.superstate.spaceManager;
3939

4040
const {
4141
predicate,
@@ -73,19 +73,26 @@ export const ContextListContainer = (props: {
7373
);
7474
useEffect(() => {
7575
if (!predicate) return;
76-
77-
const listViewUri = initiateString(predicate.listView, "spaces://$kit/#*listView");
78-
const listGroupUri = initiateString(predicate.listGroup, "spaces://$kit/#*listGroup");
79-
const listItemUri = initiateString(predicate.listItem, "spaces://$kit/#*rowItem");
80-
81-
76+
77+
const listViewUri = initiateString(
78+
predicate.listView,
79+
"spaces://$kit/#*listView"
80+
);
81+
const listGroupUri = initiateString(
82+
predicate.listGroup,
83+
"spaces://$kit/#*listGroup"
84+
);
85+
const listItemUri = initiateString(
86+
predicate.listItem,
87+
"spaces://$kit/#*rowItem"
88+
);
89+
8290
const newURIs = {
8391
listView: spaceManager.uriByString(listViewUri, pathState.path),
8492
listGroup: spaceManager.uriByString(listGroupUri, pathState.path),
8593
listItem: spaceManager.uriByString(listItemUri, pathState.path),
8694
};
87-
88-
95+
8996
setURIs((p) => (!_.isEqual(newURIs, p) ? newURIs : p));
9097
}, [predicate, pathState, spaceManager]);
9198
const onKeyDown = (e: React.KeyboardEvent) => {

0 commit comments

Comments
 (0)