Kaynağa Gözat

fix: indent continuation lines on Shift+Enter in list blocks

Serialized block continuation lines are now indented by (depth + 1) * 2
spaces so markdown stays structurally valid. Blank lines are preserved
as-is to avoid corrupting code fence content.
Zander Hawke 5 gün önce
ebeveyn
işleme
f08f4c9854

+ 2 - 0
.gitignore

@@ -40,3 +40,5 @@ dist-ssr
 auto-imports.d.ts
 components.d.ts
 
+# Repomix
+repomix*

+ 4 - 2
package.json

@@ -5,9 +5,11 @@
     "dev": "pnpm run --filter @enesis/dev dev",
     "build": "pnpm run --filter @enesis/editor build",
     "test": "pnpm run --filter @enesis/editor test",
-    "check": "biome check"
+    "check": "biome check",
+    "mix": "repomix --compress --style xml --include \"**/*.ts,*.md\" --ignore \"**/*.test.ts,docs/,tmp/\" --token-count-tree --remove-empty-lines"
   },
   "devDependencies": {
-    "@biomejs/biome": "^2.4.15"
+    "@biomejs/biome": "^2.4.15",
+    "repomix": "^1.14.1"
   }
 }

+ 1 - 0
packages/editor/src/components/Block.vue

@@ -70,6 +70,7 @@ const props = defineProps<{
   debug?: string
   registry?: FocusRegistry
   onBoundaryExit?: (direction: "up" | "down") => void
+  depth?: number
 }>()
 
 const emit = defineEmits<{

+ 1 - 0
packages/editor/src/components/Editor.vue

@@ -512,6 +512,7 @@ defineExpose({ undo, redo, canUndo, canRedo })
           v-model:content="block.content"
           :focused="focused && i === 0"
           :marker-mode="markerMode"
+          :depth="block.depth"
           :debug="debug"
           :registry="registry"
           class="flex-1 min-w-0"

+ 18 - 1
packages/editor/src/lib/block-parser.ts

@@ -145,9 +145,26 @@ export function splitMarkdownIntoBlocks(
 
 /**
  * Serialize an array of editor blocks back to markdown.
+ *
+ * Continuation lines (second and subsequent lines within a single block's
+ * content) are indented by `(depth + 1) * 2` spaces so the markdown stays
+ * structurally valid — continuation paragraphs remain inside the list item.
  */
 export function serializeBlocks(blocks: EditorBlock[]): string {
   return blocks
-    .map((block) => `${"  ".repeat(block.depth)}* ${block.content}`)
+    .map((block) => {
+      const indent = "  ".repeat(block.depth)
+      const prefix = `${indent}* `
+      const lines = block.content.split("\n")
+      const continuationIndent = " ".repeat((block.depth + 1) * 2)
+      return lines
+        .map((line, i) => {
+          if (i === 0) return `${prefix}${line}`
+          if (!line.trim()) return line
+          const trimmed = line.trimStart()
+          return `${continuationIndent}${trimmed}`
+        })
+        .join("\n")
+    })
     .join("\n")
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 532 - 2
pnpm-lock.yaml


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor