Quellcode durchsuchen

refactor: clean up dead code, fix type errors, and remove debug logging

- Fix compile error: DecorationSpec → Decoration in useMarkdownDecorations.ts
- Remove duplicate wrapperAttrs property in local ParsedToken interface
- Remove unused defaultMarkdownEngine export and dead @cursor-change listeners
- Strip debug console.warn statements from production code
Zander Hawke vor 1 Monat
Ursprung
Commit
ea612de577

+ 0 - 4
apps/dev/src/App.vue

@@ -1,7 +1,3 @@
-<script setup>
-// import Editor from "./components/Editor.vue"
-</script>
-
 <template>
   <UApp>
     <UHeader :toggle="false">

+ 0 - 4
apps/dev/src/components/Editor.vue

@@ -52,7 +52,6 @@ function log(event: string, payload?: unknown) {
       @focus="log('focus', $event)"
       @blur="log('blur')"
       @selection-change="log('selection-change', $event)"
-      @cursor-change="log('cursor-change', $event)"
     />
 
     <Block
@@ -73,7 +72,6 @@ function log(event: string, payload?: unknown) {
       @focus="log('focus', $event)"
       @blur="log('blur')"
       @selection-change="log('selection-change', $event)"
-      @cursor-change="log('cursor-change', $event)"
     />
 
     <Block
@@ -94,7 +92,6 @@ function log(event: string, payload?: unknown) {
       @focus="log('focus', $event)"
       @blur="log('blur')"
       @selection-change="log('selection-change', $event)"
-      @cursor-change="log('cursor-change', $event)"
     />
 
     <Block
@@ -115,7 +112,6 @@ function log(event: string, payload?: unknown) {
       @focus="log('focus', $event)"
       @blur="log('blur')"
       @selection-change="log('selection-change', $event)"
-      @cursor-change="log('cursor-change', $event)"
     />
   </div>
 </template>

+ 0 - 1
packages/editor/package.json

@@ -43,7 +43,6 @@
   },
   "dependencies": {
     "@lezer/common": "^1.2.2",
-    "@lezer/lr": "^1.4.2",
     "@lezer/markdown": "^1.6.3",
     "@nuxt/ui": "^4.7.1",
     "@tailwindcss/vite": "^4.3.0",

+ 17 - 2
packages/editor/src/assets/style.css

@@ -25,8 +25,7 @@
   font-family: var(--ui-font-mono, ui-monospace, "SF Mono", monospace);
   @apply text-(--ui-text-muted) text-[0.85em] select-none;
 
-  /* 3. The secret sauce: Transition layout boundaries and opacity together */
-  /* max-width: 4ch; */
+  /* 3. Transition layout boundaries and opacity together */
   opacity: 0.4;
   letter-spacing: normal;
   transition:
@@ -80,6 +79,9 @@
 .md-page-ref {
   @apply bg-(--ui-primary)/10 text-(--ui-primary) border-(--ui-primary)/20 hover:bg-(--ui-primary)/20;
 }
+.md-page-ref-alias {
+  @apply text-(--ui-text-muted) text-[0.85em];
+}
 
 .md-block-ref {
   @apply bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 hover:bg-purple-500/20;
@@ -131,6 +133,9 @@
 .md-task-marker {
   @apply font-bold uppercase text-[0.8em] tracking-wide mr-2 select-none;
 }
+.md-task-content {
+  @apply text-(--ui-text-main);
+}
 
 [data-task-state="TODO"] {
   @apply text-red-500/80;
@@ -156,6 +161,13 @@
 
 /* ── Priority ────────────────────────────────────────────────────── */
 
+.md-priority-marker {
+  @apply font-bold text-[0.8em] px-1 rounded-xs select-none;
+}
+.md-priority-content {
+  @apply text-(--ui-text-muted);
+}
+
 [data-priority="A"] {
   @apply text-red-500 font-bold bg-red-500/10 px-1 rounded-sm;
 }
@@ -181,6 +193,9 @@
 .md-callout-marker {
   @apply font-semibold text-[0.75em] tracking-wider uppercase px-2 py-0.5 rounded-md inline-flex items-center mb-1 select-none;
 }
+.md-callout-content {
+  @apply text-(--ui-text-main);
+}
 
 [data-callout-type="NOTE"] {
   @apply bg-blue-500/10 text-blue-600 dark:text-blue-400;

+ 3 - 18
packages/editor/src/composables/useMarkdownDecorations.ts

@@ -31,11 +31,6 @@ interface ParsedToken {
   type: string
   decorationRanges: DecorationRange[]
   wrapperAttrs?: Record<string, string>
-  wrapperAttrs?: Record<string, string>
-  pageName?: string
-  blockId?: string
-  tag?: string
-  alias?: string
 }
 
 /**
@@ -109,7 +104,7 @@ function buildDecorationsFromCache(
   _cursorTo: number,
   markerMode: MarkerVisibilityMode,
 ): DecorationSet {
-  const decorationSpecs: DecorationSpec[] = []
+  const decorationSpecs: Decoration[] = []
 
   doc.descendants((node: ProsemirrorNode, pos: number) => {
     if (!node.isTextblock) return
@@ -172,7 +167,7 @@ function buildDecorationsFromCache(
 function buildTokenDecorations(
   token: ParsedToken,
   offset: number,
-  decorationSpecs: DecorationSpec[],
+  decorationSpecs: Decoration[],
   isFocused: boolean,
   _cursorFrom: number,
   _cursorTo: number,
@@ -183,16 +178,6 @@ function buildTokenDecorations(
 
   const sorted = [...ranges].sort((a, b) => a.from - b.from)
 
-  if (import.meta.env?.DEV) {
-    for (let i = 1; i < sorted.length; i++) {
-      if (sorted[i].from < sorted[i - 1].to) {
-        console.warn(
-          `[markdown-decorations] Overlapping ranges in token "${token.type}": [${sorted[i - 1].from}-${sorted[i - 1].to}] and [${sorted[i].from}-${sorted[i].to}]`,
-        )
-      }
-    }
-  }
-
   for (const range of sorted) {
     const rangeFrom = offset + range.from
     const rangeTo = offset + range.to
@@ -240,7 +225,7 @@ function buildPropertyDecorations(
     value?: string
   }>,
   childOffset: number,
-  decorationSpecs: DecorationSpec[],
+  decorationSpecs: Decoration[],
   _isFocused: boolean,
   _cursorFrom: number,
   _cursorTo: number,

+ 0 - 2
packages/editor/src/composables/usePatternPlugin.ts

@@ -137,8 +137,6 @@ function findPattern(
     }
   }
 
-  const offset = textBefore.length
-
   for (const spec of PATTERN_SPECS) {
     const match = matchPattern(textBefore, spec)
     if (!match) continue

+ 2 - 6
packages/editor/src/lib/markdown-rules.ts

@@ -780,10 +780,8 @@ export class MarkdownRuleEngine {
             }
           }
         })
-      } catch (error) {
-        if (import.meta.env?.DEV) {
-          console.warn("Markdown parse error:", error)
-        }
+      } catch {
+        // Skip lines that fail to parse
       }
 
       // Pipeline 2: Line/block rules
@@ -841,5 +839,3 @@ export class MarkdownRuleEngine {
     } while (cursor.nextSibling())
   }
 }
-
-export const defaultMarkdownEngine = new MarkdownRuleEngine()