@rimelight/cms 0.0.4 → 0.0.5

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.
Files changed (51) hide show
  1. package/dist/index.d.mts +17 -17
  2. package/dist/index.mjs +47 -47
  3. package/dist/schema/index.d.mts +13 -13
  4. package/dist/schema/sqlite.d.mts +12 -12
  5. package/package.json +9 -4
  6. package/src/admin/api/media-file.ts +1 -1
  7. package/src/admin/pages/assets.astro +11 -11
  8. package/src/admin/pages/pages-edit.astro +3 -3
  9. package/src/admin/pages/pages-index.astro +2 -2
  10. package/src/admin/pages/pages-preview.astro +3 -3
  11. package/src/admin/pages/pages-review.astro +2 -2
  12. package/src/admin/pages/templates-edit.astro +1 -1
  13. package/src/admin/pages/templates-index.astro +1 -1
  14. package/src/astro/BlockRenderer.astro +1 -1
  15. package/src/astro/blocks/CalloutBlock.astro +1 -1
  16. package/src/astro/blocks/OrderedListBlock.astro +2 -2
  17. package/src/astro/blocks/ParagraphBlock.astro +1 -1
  18. package/src/astro/blocks/TabsBlock.astro +5 -5
  19. package/src/astro/blocks/UnorderedListBlock.astro +2 -2
  20. package/src/auth/editor-guards.ts +1 -1
  21. package/src/cache/purge.ts +2 -2
  22. package/src/client/components/RimelightBlock.tsx +1 -1
  23. package/src/client/components/RimelightBlockPicker.tsx +1 -1
  24. package/src/client/components/RimelightPreview.tsx +27 -27
  25. package/src/client/components/RimelightPropertiesPanel.tsx +4 -4
  26. package/src/client/components/RimelightTemplateEditor.tsx +9 -5
  27. package/src/client/components/editors/CalloutEditor.tsx +10 -10
  28. package/src/client/components/editors/CardEditor.tsx +5 -5
  29. package/src/client/components/editors/CardsEditor.tsx +2 -2
  30. package/src/client/components/editors/CodeEditor.tsx +5 -5
  31. package/src/client/components/editors/DialogueEditor.tsx +6 -6
  32. package/src/client/components/editors/FileTreeEditor.tsx +1 -1
  33. package/src/client/components/editors/ImageEditor.tsx +9 -9
  34. package/src/client/components/editors/ParagraphEditor.tsx +1 -1
  35. package/src/client/components/editors/SceneEditor.tsx +9 -9
  36. package/src/client/components/editors/ScriptEditor.tsx +8 -8
  37. package/src/client/components/editors/SectionEditor.tsx +3 -3
  38. package/src/client/components/editors/StepItemEditor.tsx +6 -5
  39. package/src/client/components/editors/StepsEditor.tsx +1 -1
  40. package/src/client/components/editors/TabItemEditor.tsx +3 -3
  41. package/src/client/components/editors/TableEditor.tsx +4 -4
  42. package/src/client/components/editors/TabsEditor.tsx +1 -1
  43. package/src/client/state/editor-store.ts +23 -23
  44. package/src/client/utils/sortable.ts +13 -12
  45. package/src/client/utils/tree-sanitizer.ts +1 -1
  46. package/src/core/excerpt.ts +16 -16
  47. package/src/core/page-definitions.ts +2 -2
  48. package/src/docs/agent.ts +1 -1
  49. package/src/docs/routing.ts +2 -2
  50. package/src/loader/live.ts +1 -1
  51. package/src/markdown/serializer.ts +26 -26
@@ -22,7 +22,7 @@ function extractTextFromProperty(prop: unknown, locale: string = "en"): string {
22
22
  }
23
23
  const record = prop as Record<string, unknown>
24
24
  if (typeof record[locale] === "string") return record[locale] as string
25
- if (typeof record.en === "string") return record.en as string
25
+ if (typeof record["en"] === "string") return record["en"] as string
26
26
  const firstVal = Object.values(record)[0]
27
27
  if (typeof firstVal === "string") return firstVal
28
28
  }
@@ -47,35 +47,35 @@ export function extractTextFromBlocks(
47
47
 
48
48
  switch (block.type) {
49
49
  case "ParagraphBlock": {
50
- const text = extractTextFromProperty(props.text, locale)
50
+ const text = extractTextFromProperty(props["text"], locale)
51
51
  if (text) chunks.push(text)
52
52
  break
53
53
  }
54
54
  case "SectionBlock": {
55
- if (props.title) chunks.push(String(props.title))
56
- if (props.description) chunks.push(String(props.description))
57
- if (Array.isArray(props.children)) {
58
- const childText = extractTextFromBlocks(props.children, locale)
55
+ if (props["title"]) chunks.push(String(props["title"]))
56
+ if (props["description"]) chunks.push(String(props["description"]))
57
+ if (Array.isArray(props["children"])) {
58
+ const childText = extractTextFromBlocks(props["children"], locale)
59
59
  if (childText) chunks.push(childText)
60
60
  }
61
61
  break
62
62
  }
63
63
  case "CardBlock": {
64
- if (props.title) chunks.push(String(props.title))
65
- if (props.description) chunks.push(String(props.description))
64
+ if (props["title"]) chunks.push(String(props["title"]))
65
+ if (props["description"]) chunks.push(String(props["description"]))
66
66
  break
67
67
  }
68
68
  case "DialogueBlock": {
69
- if (props.character && props.line) {
70
- chunks.push(`${props.character}: ${props.line}`)
71
- } else if (props.line) {
72
- chunks.push(String(props.line))
69
+ if (props["character"] && props["line"]) {
70
+ chunks.push(`${props["character"]}: ${props["line"]}`)
71
+ } else if (props["line"]) {
72
+ chunks.push(String(props["line"]))
73
73
  }
74
74
  break
75
75
  }
76
76
  case "StepItemBlock": {
77
- if (props.title) chunks.push(String(props.title))
78
- if (props.description) chunks.push(String(props.description))
77
+ if (props["title"]) chunks.push(String(props["title"]))
78
+ if (props["description"]) chunks.push(String(props["description"]))
79
79
  break
80
80
  }
81
81
  default:
@@ -133,8 +133,8 @@ export function createPageExcerpt(
133
133
 
134
134
  if (contentObj && typeof contentObj === "object") {
135
135
  const props = (contentObj as { properties?: Record<string, unknown> }).properties
136
- if (props && props.description) {
137
- const descText = extractTextFromProperty(props.description, locale)
136
+ if (props && props["description"]) {
137
+ const descText = extractTextFromProperty(props["description"], locale)
138
138
  if (descText) return truncateExcerpt(descText, maxLength)
139
139
  }
140
140
 
@@ -464,7 +464,7 @@ export const PAGE_MAP: Record<string, PageDefinition> = {
464
464
  }
465
465
 
466
466
  export function getPageDefinition(type: string): PageDefinition {
467
- if (!type) return PAGE_MAP.Default!
467
+ if (!type) return PAGE_MAP["Default"]!
468
468
 
469
469
  // Exact match
470
470
  if (PAGE_MAP[type]) return PAGE_MAP[type]
@@ -498,5 +498,5 @@ export function getPageDefinition(type: string): PageDefinition {
498
498
  if (key.toLowerCase() === normalized) return def
499
499
  }
500
500
 
501
- return PAGE_MAP.Default!
501
+ return PAGE_MAP["Default"]!
502
502
  }
package/src/docs/agent.ts CHANGED
@@ -13,7 +13,7 @@ function resolveLocalized(val: unknown, locale: string = "en"): string {
13
13
  if (typeof val === "string") return val
14
14
  if (typeof val === "object" && val !== null) {
15
15
  const rec = val as Record<string, string>
16
- return rec[locale] || rec.en || Object.values(rec)[0] || ""
16
+ return rec[locale] || rec["en"] || Object.values(rec)[0] || ""
17
17
  }
18
18
  return typeof val === "number" ? String(val) : ""
19
19
  }
@@ -22,8 +22,8 @@ export function getDocsVersions(entries: (DocEntry | string)[], locale?: string)
22
22
  continue
23
23
  }
24
24
 
25
- if (entry.properties?.version && String(entry.properties.version).startsWith("v")) {
26
- versions.add(String(entry.properties.version))
25
+ if (entry.properties?.["version"] && String(entry.properties["version"]).startsWith("v")) {
26
+ versions.add(String(entry.properties["version"]))
27
27
  continue
28
28
  }
29
29
 
@@ -56,7 +56,7 @@ function resolveLocalized(val: unknown, locale: string = "en"): string {
56
56
  if (typeof val === "string") return val
57
57
  if (typeof val === "object" && val !== null) {
58
58
  const rec = val as Record<string, string>
59
- return rec[locale] || rec.en || Object.values(rec)[0] || ""
59
+ return rec[locale] || rec["en"] || Object.values(rec)[0] || ""
60
60
  }
61
61
  return typeof val === "number" ? String(val) : ""
62
62
  }
@@ -46,18 +46,18 @@ export function blocksToMarkdown(
46
46
 
47
47
  for (const block of blocks) {
48
48
  if (!block) continue
49
- const children = block.children || block.props?.children || []
49
+ const children = block.children || block.props?.["children"] || []
50
50
 
51
51
  switch (block.type) {
52
52
  case "SectionBlock": {
53
- const level = (block.props?.level as HeadingLevel) || (baseLevel as HeadingLevel)
53
+ const level = (block.props?.["level"] as HeadingLevel) || (baseLevel as HeadingLevel)
54
54
  const hashes = "#".repeat(Math.min(6, Math.max(1, level)))
55
- const title = block.props?.title || ""
55
+ const title = block.props?.["title"] || ""
56
56
  if (title) {
57
57
  lines.push(`${hashes} ${title}`)
58
58
  }
59
- if (block.props?.description) {
60
- lines.push(`_${block.props.description}_`)
59
+ if (block.props?.["description"]) {
60
+ lines.push(`_${block.props["description"]}_`)
61
61
  }
62
62
  if (children.length > 0) {
63
63
  lines.push(blocksToMarkdown(children, { sectionLevel: Math.min(6, level + 1) }))
@@ -66,13 +66,13 @@ export function blocksToMarkdown(
66
66
  }
67
67
 
68
68
  case "ParagraphBlock": {
69
- const text = inlinesToMarkdown(block.props?.text)
69
+ const text = inlinesToMarkdown(block.props?.["text"])
70
70
  if (text) lines.push(text)
71
71
  break
72
72
  }
73
73
 
74
74
  case "CalloutBlock": {
75
- const variant = (block.props?.variant || "info").toUpperCase()
75
+ const variant = (block.props?.["variant"] || "info").toUpperCase()
76
76
  const childMd = blocksToMarkdown(children, options)
77
77
  const calloutHeader = `> [!${variant}]`
78
78
  if (childMd) {
@@ -88,16 +88,16 @@ export function blocksToMarkdown(
88
88
  }
89
89
 
90
90
  case "CodeBlock": {
91
- const lang = block.props?.language || ""
92
- const code = block.props?.code || ""
93
- const caption = block.props?.caption ? `\n_${block.props.caption}_` : ""
91
+ const lang = block.props?.["language"] || ""
92
+ const code = block.props?.["code"] || ""
93
+ const caption = block.props?.["caption"] ? `\n_${block.props["caption"]}_` : ""
94
94
  lines.push(`\`\`\`${lang}\n${code}\n\`\`\`${caption}`)
95
95
  break
96
96
  }
97
97
 
98
98
  case "TableBlock": {
99
- const columns = block.props?.columns || []
100
- const rows = block.props?.rows || []
99
+ const columns = block.props?.["columns"] || []
100
+ const rows = block.props?.["rows"] || []
101
101
  if (columns.length > 0) {
102
102
  const headerRow = `| ${columns.map((c: any) => c.header || c.key).join(" | ")} |`
103
103
  const alignRow = `| ${columns
@@ -111,16 +111,16 @@ export function blocksToMarkdown(
111
111
  (r: any) => `| ${columns.map((c: any) => r[c.key] || "").join(" | ")} |`
112
112
  )
113
113
  const tableMd = [headerRow, alignRow, ...bodyRows].join("\n")
114
- const caption = block.props?.caption ? `\n_${block.props.caption}_` : ""
114
+ const caption = block.props?.["caption"] ? `\n_${block.props["caption"]}_` : ""
115
115
  lines.push(`${tableMd}${caption}`)
116
116
  }
117
117
  break
118
118
  }
119
119
 
120
120
  case "ImageBlock": {
121
- const alt = block.props?.alt || ""
122
- const src = block.props?.src || ""
123
- const caption = block.props?.caption ? `\n_${block.props.caption}_` : ""
121
+ const alt = block.props?.["alt"] || ""
122
+ const src = block.props?.["src"] || ""
123
+ const caption = block.props?.["caption"] ? `\n_${block.props["caption"]}_` : ""
124
124
  lines.push(`![${alt}](${src})${caption}`)
125
125
  break
126
126
  }
@@ -135,7 +135,7 @@ export function blocksToMarkdown(
135
135
  }
136
136
 
137
137
  case "TabItemBlock": {
138
- const label = block.props?.label || "Tab"
138
+ const label = block.props?.["label"] || "Tab"
139
139
  lines.push(`#### ${label}\n\n${blocksToMarkdown(children, options)}`)
140
140
  break
141
141
  }
@@ -156,8 +156,8 @@ export function blocksToMarkdown(
156
156
  }
157
157
 
158
158
  case "StepItemBlock": {
159
- const title = block.props?.title || "Step"
160
- const desc = block.props?.description ? ` - ${block.props.description}` : ""
159
+ const title = block.props?.["title"] || "Step"
160
+ const desc = block.props?.["description"] ? ` - ${block.props["description"]}` : ""
161
161
  lines.push(`- **${title}**${desc}`)
162
162
  if (children.length > 0) {
163
163
  lines.push(blocksToMarkdown(children, options))
@@ -176,9 +176,9 @@ export function blocksToMarkdown(
176
176
  }
177
177
 
178
178
  case "CardBlock": {
179
- const title = block.props?.title || ""
180
- const href = block.props?.href || "#"
181
- const desc = block.props?.description ? `: ${block.props.description}` : ""
179
+ const title = block.props?.["title"] || ""
180
+ const href = block.props?.["href"] || "#"
181
+ const desc = block.props?.["description"] ? `: ${block.props["description"]}` : ""
182
182
  lines.push(`- [${title}](${href})${desc}`)
183
183
  break
184
184
  }
@@ -196,19 +196,19 @@ export function blocksToMarkdown(
196
196
  }
197
197
  return treeLines
198
198
  }
199
- const treeNodes = block.props?.tree || []
199
+ const treeNodes = block.props?.["tree"] || []
200
200
  lines.push(`\`\`\`text\n${renderTree(treeNodes).join("\n")}\n\`\`\``)
201
201
  break
202
202
  }
203
203
 
204
204
  case "DialogueBlock": {
205
- lines.push(`**${block.props?.character}:** "${block.props?.line || ""}"`)
205
+ lines.push(`**${block.props?.["character"]}:** "${block.props?.["line"] || ""}"`)
206
206
  break
207
207
  }
208
208
 
209
209
  default: {
210
- if (block.props?.text) {
211
- lines.push(inlinesToMarkdown(block.props.text))
210
+ if (block.props?.["text"]) {
211
+ lines.push(inlinesToMarkdown(block.props["text"]))
212
212
  }
213
213
  break
214
214
  }