@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/src/studio.js CHANGED
@@ -543,13 +543,19 @@ if (_openParam) {
543
543
  }
544
544
 
545
545
  // Read and open the file
546
- const fileRelPath = siteCtx.fileRelPath || _openParam;
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
- const parsed = JSON.parse(content);
550
- S = createState(parsed);
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 collection and return its schema. Uses simple directory-prefix
127
- * + extension matching against the collection's `source` glob.
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 findCollectionSchema(documentPath, projectConfig) {
134
- if (!documentPath || !projectConfig?.collections) return null;
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.collections),
136
+ /** @type {Record<string, any>} */ (projectConfig.contentTypes),
137
137
  )) {
138
138
  if (!def.source || !def.schema) continue;
139
139
  const src = def.source.replace(/^\.\//, "");