@rimelight/cms 0.0.4 → 0.0.6
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/index.d.mts +118 -118
- package/dist/index.mjs +47 -47
- package/dist/integration.d.mts +3 -4
- package/dist/schema/index.d.mts +32 -33
- package/dist/schema/sqlite.d.mts +31 -32
- package/dist/storage/index.d.mts +12 -13
- package/package.json +13 -8
- package/src/admin/api/media-file.ts +1 -1
- package/src/admin/pages/assets.astro +11 -11
- package/src/admin/pages/pages-edit.astro +3 -3
- package/src/admin/pages/pages-index.astro +2 -2
- package/src/admin/pages/pages-preview.astro +3 -3
- package/src/admin/pages/pages-review.astro +2 -2
- package/src/admin/pages/templates-edit.astro +1 -1
- package/src/admin/pages/templates-index.astro +1 -1
- package/src/astro/BlockRenderer.astro +1 -1
- package/src/astro/blocks/CalloutBlock.astro +1 -1
- package/src/astro/blocks/OrderedListBlock.astro +2 -2
- package/src/astro/blocks/ParagraphBlock.astro +1 -1
- package/src/astro/blocks/TabsBlock.astro +5 -5
- package/src/astro/blocks/UnorderedListBlock.astro +2 -2
- package/src/auth/editor-guards.ts +1 -1
- package/src/cache/purge.ts +2 -2
- package/src/client/components/RimelightBlock.tsx +1 -1
- package/src/client/components/RimelightBlockPicker.tsx +1 -1
- package/src/client/components/RimelightPreview.tsx +27 -27
- package/src/client/components/RimelightPropertiesPanel.tsx +4 -4
- package/src/client/components/RimelightTemplateEditor.tsx +9 -5
- package/src/client/components/editors/CalloutEditor.tsx +10 -10
- package/src/client/components/editors/CardEditor.tsx +5 -5
- package/src/client/components/editors/CardsEditor.tsx +2 -2
- package/src/client/components/editors/CodeEditor.tsx +5 -5
- package/src/client/components/editors/DialogueEditor.tsx +6 -6
- package/src/client/components/editors/FileTreeEditor.tsx +1 -1
- package/src/client/components/editors/ImageEditor.tsx +9 -9
- package/src/client/components/editors/ParagraphEditor.tsx +1 -1
- package/src/client/components/editors/SceneEditor.tsx +9 -9
- package/src/client/components/editors/ScriptEditor.tsx +8 -8
- package/src/client/components/editors/SectionEditor.tsx +3 -3
- package/src/client/components/editors/StepItemEditor.tsx +6 -5
- package/src/client/components/editors/StepsEditor.tsx +1 -1
- package/src/client/components/editors/TabItemEditor.tsx +3 -3
- package/src/client/components/editors/TableEditor.tsx +4 -4
- package/src/client/components/editors/TabsEditor.tsx +1 -1
- package/src/client/state/editor-store.ts +23 -23
- package/src/client/utils/sortable.ts +13 -12
- package/src/client/utils/tree-sanitizer.ts +1 -1
- package/src/core/excerpt.ts +16 -16
- package/src/core/page-definitions.ts +2 -2
- package/src/docs/agent.ts +1 -1
- package/src/docs/routing.ts +2 -2
- package/src/loader/live.ts +1 -1
- package/src/markdown/serializer.ts +26 -26
|
@@ -20,7 +20,7 @@ function findBlockInfo(
|
|
|
20
20
|
}
|
|
21
21
|
const isSec = b.type === "SectionBlock"
|
|
22
22
|
const nextDepth = isSec ? currentDepth + 1 : currentDepth
|
|
23
|
-
const children = b.children || b.props?.children
|
|
23
|
+
const children = b.children || b.props?.["children"]
|
|
24
24
|
if (Array.isArray(children)) {
|
|
25
25
|
const found = findBlockInfo(children, targetId, nextDepth)
|
|
26
26
|
if (found) {
|
|
@@ -37,7 +37,7 @@ function findBlockInfo(
|
|
|
37
37
|
function getMaxSubtreeSectionHeight(b: BaseBlock | null): number {
|
|
38
38
|
if (!b) return 0
|
|
39
39
|
const isSec = b.type === "SectionBlock"
|
|
40
|
-
const children = b.children || b.props?.children
|
|
40
|
+
const children = b.children || b.props?.["children"]
|
|
41
41
|
let maxChildHeight = 0
|
|
42
42
|
if (Array.isArray(children)) {
|
|
43
43
|
for (const c of children) {
|
|
@@ -106,13 +106,13 @@ export function createEditorState(
|
|
|
106
106
|
if (!item) continue
|
|
107
107
|
if (item.id === id) {
|
|
108
108
|
item.props = { ...item.props, ...newProps }
|
|
109
|
-
if (newProps
|
|
110
|
-
item.children = newProps
|
|
111
|
-
item.props
|
|
109
|
+
if (newProps["children"] !== undefined) {
|
|
110
|
+
item.children = newProps["children"]
|
|
111
|
+
item.props["children"] = newProps["children"]
|
|
112
112
|
}
|
|
113
113
|
return true
|
|
114
114
|
}
|
|
115
|
-
const childrenList = item.children || item.props?.children
|
|
115
|
+
const childrenList = item.children || item.props?.["children"]
|
|
116
116
|
if (childrenList && findAndUpdate(childrenList)) {
|
|
117
117
|
return true
|
|
118
118
|
}
|
|
@@ -148,8 +148,8 @@ export function createEditorState(
|
|
|
148
148
|
if (b.children) {
|
|
149
149
|
b.children = removeFromList(b.children)
|
|
150
150
|
}
|
|
151
|
-
if (b.props?.children) {
|
|
152
|
-
b.props
|
|
151
|
+
if (b.props?.["children"]) {
|
|
152
|
+
b.props["children"] = removeFromList(b.props["children"])
|
|
153
153
|
}
|
|
154
154
|
return true
|
|
155
155
|
})
|
|
@@ -172,10 +172,10 @@ export function createEditorState(
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
for (const item of list) {
|
|
175
|
-
const children = item.children || item.props?.children
|
|
175
|
+
const children = item.children || item.props?.["children"]
|
|
176
176
|
if (children && findAndMove(children)) {
|
|
177
177
|
item.children = children
|
|
178
|
-
item.props
|
|
178
|
+
item.props["children"] = children
|
|
179
179
|
return true
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -200,10 +200,10 @@ export function createEditorState(
|
|
|
200
200
|
return true
|
|
201
201
|
}
|
|
202
202
|
for (const item of list) {
|
|
203
|
-
const children = item.children || item.props?.children
|
|
203
|
+
const children = item.children || item.props?.["children"]
|
|
204
204
|
if (children && findAndDup(children)) {
|
|
205
205
|
item.children = children
|
|
206
|
-
item.props
|
|
206
|
+
item.props["children"] = children
|
|
207
207
|
return true
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -259,23 +259,23 @@ export function createEditorState(
|
|
|
259
259
|
if (parentId) {
|
|
260
260
|
for (const item of list) {
|
|
261
261
|
if (item.id === parentId) {
|
|
262
|
-
const children = item.children || item.props?.children || []
|
|
262
|
+
const children = item.children || item.props?.["children"] || []
|
|
263
263
|
if (position === "after") {
|
|
264
264
|
children.push(newBlock)
|
|
265
265
|
} else {
|
|
266
266
|
children.unshift(newBlock)
|
|
267
267
|
}
|
|
268
268
|
item.children = children
|
|
269
|
-
item.props
|
|
269
|
+
item.props["children"] = children
|
|
270
270
|
return true
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
for (const item of list) {
|
|
275
|
-
const children = item.children || item.props?.children
|
|
275
|
+
const children = item.children || item.props?.["children"]
|
|
276
276
|
if (children && insertIntoList(children)) {
|
|
277
277
|
item.children = children
|
|
278
|
-
item.props
|
|
278
|
+
item.props["children"] = children
|
|
279
279
|
return true
|
|
280
280
|
}
|
|
281
281
|
}
|
|
@@ -319,10 +319,10 @@ export function createEditorState(
|
|
|
319
319
|
}
|
|
320
320
|
if (b.children) {
|
|
321
321
|
b.children = remove(b.children)
|
|
322
|
-
if (b.props) b.props
|
|
323
|
-
} else if (b.props?.children) {
|
|
324
|
-
b.props
|
|
325
|
-
b.children = b.props
|
|
322
|
+
if (b.props) b.props["children"] = b.children
|
|
323
|
+
} else if (b.props?.["children"]) {
|
|
324
|
+
b.props["children"] = remove(b.props["children"])
|
|
325
|
+
b.children = b.props["children"]
|
|
326
326
|
}
|
|
327
327
|
return true
|
|
328
328
|
})
|
|
@@ -361,14 +361,14 @@ export function createEditorState(
|
|
|
361
361
|
const insertIntoTarget = (list: BaseBlock[]): boolean => {
|
|
362
362
|
for (const item of list) {
|
|
363
363
|
if (item.id === targetParentId) {
|
|
364
|
-
const children = item.children || item.props?.children || []
|
|
364
|
+
const children = item.children || item.props?.["children"] || []
|
|
365
365
|
const idx = Math.min(Math.max(0, newIndex), children.length)
|
|
366
366
|
children.splice(idx, 0, extractedBlock!)
|
|
367
367
|
item.children = children
|
|
368
|
-
item.props
|
|
368
|
+
item.props["children"] = children
|
|
369
369
|
return true
|
|
370
370
|
}
|
|
371
|
-
const sub = item.children || item.props?.children
|
|
371
|
+
const sub = item.children || item.props?.["children"]
|
|
372
372
|
if (sub && insertIntoTarget(sub)) return true
|
|
373
373
|
}
|
|
374
374
|
return false
|
|
@@ -2,8 +2,8 @@ import Sortable from "sortablejs"
|
|
|
2
2
|
|
|
3
3
|
const sortableProto: Record<string, any> | undefined = Sortable?.prototype
|
|
4
4
|
|
|
5
|
-
if (typeof window !== "undefined" && sortableProto && !sortableProto
|
|
6
|
-
sortableProto
|
|
5
|
+
if (typeof window !== "undefined" && sortableProto && !sortableProto["patchedParentNodeGuard"]) {
|
|
6
|
+
sortableProto["patchedParentNodeGuard"] = true
|
|
7
7
|
const originalOnDragOver = sortableProto["_onDragOver"]
|
|
8
8
|
if (typeof originalOnDragOver === "function") {
|
|
9
9
|
sortableProto["_onDragOver"] = function (evt: Event) {
|
|
@@ -109,10 +109,11 @@ export function initBlockSortable(container: HTMLElement, options: SortableOptio
|
|
|
109
109
|
onAdd: (evt) => {
|
|
110
110
|
runCleanup(evt.item)
|
|
111
111
|
const itemEl = evt.item
|
|
112
|
-
const blockId = itemEl.dataset
|
|
112
|
+
const blockId = itemEl.dataset["id"] || itemEl.getAttribute("data-id")
|
|
113
113
|
if (blockId && evt.newIndex !== undefined && options.onAdd) {
|
|
114
114
|
const target = evt.from.closest("[data-block-id]")
|
|
115
|
-
const containerBlockId =
|
|
115
|
+
const containerBlockId =
|
|
116
|
+
target instanceof HTMLElement ? target.dataset["blockId"] : undefined
|
|
116
117
|
// Remove the physically-moved DOM node before calling the callback.
|
|
117
118
|
// The reactive framework (SolidJS) will re-render the authoritative element
|
|
118
119
|
// from state, so leaving the SortableJS-placed node causes a visual duplicate.
|
|
@@ -123,7 +124,7 @@ export function initBlockSortable(container: HTMLElement, options: SortableOptio
|
|
|
123
124
|
onRemove: (evt) => {
|
|
124
125
|
runCleanup(evt.item)
|
|
125
126
|
const itemEl = evt.item
|
|
126
|
-
const blockId = itemEl.dataset
|
|
127
|
+
const blockId = itemEl.dataset["id"] || itemEl.getAttribute("data-id")
|
|
127
128
|
if (blockId && evt.oldIndex !== undefined && options.onRemove) {
|
|
128
129
|
options.onRemove(blockId, evt.oldIndex)
|
|
129
130
|
}
|
|
@@ -167,8 +168,8 @@ export function cleanAllSortableClasses(specificItem?: HTMLElement | Element) {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
const customWin: Record<string, any> | null = typeof window !== "undefined" ? window : null
|
|
170
|
-
if (customWin && !customWin
|
|
171
|
-
customWin
|
|
171
|
+
if (customWin && !customWin["cmsSortableGlobalListenersAttached"]) {
|
|
172
|
+
customWin["cmsSortableGlobalListenersAttached"] = true
|
|
172
173
|
const globalClean = () => {
|
|
173
174
|
const doClean = () => cleanAllSortableClasses()
|
|
174
175
|
doClean()
|
|
@@ -176,9 +177,9 @@ if (customWin && !customWin.cmsSortableGlobalListenersAttached) {
|
|
|
176
177
|
setTimeout(doClean, 150)
|
|
177
178
|
setTimeout(doClean, 300)
|
|
178
179
|
}
|
|
179
|
-
customWin
|
|
180
|
-
customWin
|
|
181
|
-
customWin
|
|
182
|
-
customWin
|
|
183
|
-
customWin
|
|
180
|
+
customWin["addEventListener"]("mouseup", globalClean, { capture: true })
|
|
181
|
+
customWin["addEventListener"]("pointerup", globalClean, { capture: true })
|
|
182
|
+
customWin["addEventListener"]("touchend", globalClean, { capture: true })
|
|
183
|
+
customWin["addEventListener"]("dragend", globalClean, { capture: true })
|
|
184
|
+
customWin["addEventListener"]("drop", globalClean, { capture: true })
|
|
184
185
|
}
|
|
@@ -2,7 +2,7 @@ import type { BaseBlock } from "../../core/types/blocks"
|
|
|
2
2
|
|
|
3
3
|
export function getBlockChildren(b: BaseBlock): BaseBlock[] {
|
|
4
4
|
if (!b) return []
|
|
5
|
-
if (Array.isArray(b.props?.children)) return b.props
|
|
5
|
+
if (Array.isArray(b.props?.["children"])) return b.props["children"]
|
|
6
6
|
if (Array.isArray(b.children)) return b.children
|
|
7
7
|
return []
|
|
8
8
|
}
|
package/src/core/excerpt.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
56
|
-
if (props
|
|
57
|
-
if (Array.isArray(props
|
|
58
|
-
const childText = extractTextFromBlocks(props
|
|
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
|
|
65
|
-
if (props
|
|
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
|
|
70
|
-
chunks.push(`${props
|
|
71
|
-
} else if (props
|
|
72
|
-
chunks.push(String(props
|
|
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
|
|
78
|
-
if (props
|
|
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
|
|
137
|
-
const descText = extractTextFromProperty(props
|
|
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
|
|
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
|
|
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
|
|
16
|
+
return rec[locale] || rec["en"] || Object.values(rec)[0] || ""
|
|
17
17
|
}
|
|
18
18
|
return typeof val === "number" ? String(val) : ""
|
|
19
19
|
}
|
package/src/docs/routing.ts
CHANGED
|
@@ -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
|
|
26
|
-
versions.add(String(entry.properties
|
|
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
|
|
package/src/loader/live.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(`${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
|
|
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
|
|
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
|
|
210
|
+
if (block.props?.["text"]) {
|
|
211
|
+
lines.push(inlinesToMarkdown(block.props["text"]))
|
|
212
212
|
}
|
|
213
213
|
break
|
|
214
214
|
}
|