@yugoo-design/dsh-design-studio-dsh 0.1.0-beta.4 → 0.1.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.
@@ -7996,12 +7996,30 @@ var StudioPanelDraftController = class {
7996
7996
  */
7997
7997
  /** Split one leading YAML frontmatter block from the document body. */
7998
7998
  function splitFrontmatter(source) {
7999
- const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/u.exec(source);
8000
- if (match === null) return { body: source };
7999
+ const opening = /^\uFEFF?---[ \t]*\r?\n/u.exec(source);
8000
+ if (opening === null) return { body: source };
8001
+ const remaining = source.slice(opening[0].length);
8002
+ const closing = /^---[ \t]*(?:\r?\n|$)/mu.exec(remaining);
8003
+ if (closing === null) return { body: source };
8001
8004
  return {
8002
- frontmatter: match[1],
8003
- body: source.slice(match[0].length)
8004
- };
8005
+ frontmatter: remaining.slice(0, closing.index).replace(/\r?\n$/u, ""),
8006
+ body: remaining.slice(closing.index + closing[0].length)
8007
+ };
8008
+ }
8009
+ /** Shared full-file reading view; source/editing modes retain their original bytes. */
8010
+ function renderStudioDocument(source, options) {
8011
+ const { frontmatter, body } = splitFrontmatter(source);
8012
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [frontmatter === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
8013
+ className: "ygd-studio-file-metadata",
8014
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: options.locale === "zh" ? "文件元信息 · 展开查看" : "File metadata · expand to view" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
8015
+ className: "ygd-studio-frontmatter",
8016
+ "aria-label": "frontmatter",
8017
+ children: frontmatter
8018
+ })]
8019
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
8020
+ "aria-label": options.ariaLabel,
8021
+ children: renderStudioMarkdown(body)
8022
+ })] });
8005
8023
  }
8006
8024
  /** Parse `**bold**` and `` `code` `` segments into React nodes; everything else is plain text. */
8007
8025
  function inlineNodes(text, keyPrefix) {
@@ -9007,7 +9025,10 @@ function KitFiles({ client, name, version, mindset, description, locale, renderM
9007
9025
  children: busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingIndicator, { label: zh ? "正在读取文件" : "Loading file" }) : error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
9008
9026
  role: "alert",
9009
9027
  children: error
9010
- }) : read && /\.md$/i.test(path) ? renderStudioMarkdown(content) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
9028
+ }) : read && /\.md$/i.test(path) ? renderStudioDocument(content, {
9029
+ locale,
9030
+ ariaLabel: "Kit document"
9031
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
9011
9032
  "aria-label": "Kit file source",
9012
9033
  style: {
9013
9034
  padding: 16,
@@ -11104,7 +11125,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, renderPrevie
11104
11125
  }) : !loaded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
11105
11126
  role: "status",
11106
11127
  children: error ? zh ? "无法读取此文件。" : "Could not load this file." : path ? zh ? "读取中…" : "Loading…" : zh ? "没有可读取的文件。" : "No readable files."
11107
- }) : reading && /\.md$/i.test(path) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: renderStudioMarkdown(content) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
11128
+ }) : reading && /\.md$/i.test(path) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: renderStudioDocument(content, { locale }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
11108
11129
  "aria-label": path || "Source file",
11109
11130
  spellCheck: false,
11110
11131
  value: content,
@@ -12660,20 +12681,10 @@ function StudioWorkspace({ client, controller: supplied, authoring, kitAuthoring
12660
12681
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: draft ? locale === "zh" ? "工作副本 · 未发布" : "Working copy · unpublished" : locale === "zh" ? "已安装内容" : "Installed content" })
12661
12682
  ]
12662
12683
  });
12663
- const markdownDoc = (source, ariaLabel) => {
12664
- const { frontmatter, body } = splitFrontmatter(source);
12665
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [frontmatter === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
12666
- className: "ygd-studio-file-metadata",
12667
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: locale === "zh" ? "文件元信息 · 展开查看" : "File metadata · expand to view" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
12668
- className: "ygd-studio-frontmatter",
12669
- "aria-label": "frontmatter",
12670
- children: frontmatter
12671
- })]
12672
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
12673
- "aria-label": ariaLabel,
12674
- children: renderStudioMarkdown(body)
12675
- })] });
12676
- };
12684
+ const markdownDoc = (source, ariaLabel) => renderStudioDocument(source, {
12685
+ locale,
12686
+ ariaLabel
12687
+ });
12677
12688
  /** Bundle descriptions are authored as Markdown lists; cards render the same safe subset. */
12678
12689
  const cardDescription = (description) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
12679
12690
  className: "ygd-studio-card-description",