@jxsuite/studio 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/studio.js +105 -89
- package/dist/studio.js.map +17 -17
- package/package.json +29 -29
- package/src/browse/browse.js +21 -19
- package/src/canvas/canvas-live-render.js +7 -1
- package/src/canvas/canvas-render.js +8 -6
- package/src/files/files.js +2 -0
- package/src/panels/imports-panel.js +2 -2
- package/src/panels/properties-panel.js +3 -3
- package/src/panels/stylebook-panel.js +27 -20
- package/src/settings/{collections-editor.js → content-types-editor.js} +48 -48
- package/src/settings/schema-field-ui.js +1 -1
- package/src/state.js +1 -1
- package/src/studio.js +10 -4
- package/src/utils/studio-utils.js +5 -5
package/src/studio.js
CHANGED
|
@@ -543,13 +543,19 @@ if (_openParam) {
|
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
// Read and open the file
|
|
546
|
-
const
|
|
546
|
+
const _fileParam = new URLSearchParams(location.search).get("file");
|
|
547
|
+
const fileRelPath = _fileParam || siteCtx.fileRelPath || _openParam;
|
|
547
548
|
const content = await platform.readFile(fileRelPath);
|
|
548
549
|
if (content) {
|
|
549
|
-
|
|
550
|
-
|
|
550
|
+
if (fileRelPath.endsWith(".md")) {
|
|
551
|
+
await loadMarkdown(content, null);
|
|
552
|
+
S.documentPath = fileRelPath;
|
|
553
|
+
} else {
|
|
554
|
+
const parsed = JSON.parse(content);
|
|
555
|
+
S = createState(parsed);
|
|
556
|
+
S.documentPath = fileRelPath;
|
|
557
|
+
}
|
|
551
558
|
S.dirty = false;
|
|
552
|
-
S.documentPath = fileRelPath;
|
|
553
559
|
S.ui = { ...S.ui, leftTab: "files" };
|
|
554
560
|
({ doc, session } = fromFlat(S));
|
|
555
561
|
render();
|
|
@@ -123,17 +123,17 @@ export function inferInputType(entry) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* Match a document path to a content
|
|
127
|
-
*
|
|
126
|
+
* Match a document path to a content type and return its schema. Uses simple directory-prefix +
|
|
127
|
+
* extension matching against the content type's `source` glob.
|
|
128
128
|
*
|
|
129
129
|
* @param {string | null} documentPath — project-relative path (e.g. "blog/hello.md")
|
|
130
130
|
* @param {any} projectConfig — parsed project.json
|
|
131
131
|
* @returns {{ name: string; schema: any } | null}
|
|
132
132
|
*/
|
|
133
|
-
export function
|
|
134
|
-
if (!documentPath || !projectConfig?.
|
|
133
|
+
export function findContentTypeSchema(documentPath, projectConfig) {
|
|
134
|
+
if (!documentPath || !projectConfig?.contentTypes) return null;
|
|
135
135
|
for (const [name, def] of Object.entries(
|
|
136
|
-
/** @type {Record<string, any>} */ (projectConfig.
|
|
136
|
+
/** @type {Record<string, any>} */ (projectConfig.contentTypes),
|
|
137
137
|
)) {
|
|
138
138
|
if (!def.source || !def.schema) continue;
|
|
139
139
|
const src = def.source.replace(/^\.\//, "");
|