|
|
@@ -1,22 +1,22 @@
|
|
|
<script setup lang="ts">
|
|
|
import { watchDebounced } from "@vueuse/core"
|
|
|
import { EditorState, Selection, type Transaction } from "prosemirror-state"
|
|
|
-import { schema } from "../lib/schema"
|
|
|
+import { schema } from "@/lib/schema"
|
|
|
import { EditorView } from "prosemirror-view"
|
|
|
import { onMounted, onUnmounted, useTemplateRef, watch } from "vue"
|
|
|
-import { createBlockKeyboardHandler } from "../composables/useBlockKeyboardHandlers"
|
|
|
+import { createBlockKeyboardHandler } from "@/composables/useBlockKeyboardHandlers"
|
|
|
import {
|
|
|
createMarkdownDecorationsPlugin,
|
|
|
type MarkerVisibilityMode,
|
|
|
-} from "../composables/useMarkdownDecorations"
|
|
|
-import { createPatternPlugin } from "../composables/usePatternPlugin"
|
|
|
+} from "@/composables/useMarkdownDecorations"
|
|
|
+import { createPatternPlugin } from "@/composables/usePatternPlugin"
|
|
|
import type {
|
|
|
PatternClosePayload,
|
|
|
PatternOpenPayload,
|
|
|
PatternUpdatePayload,
|
|
|
-} from "../composables/usePatternPlugin.ts"
|
|
|
-import { contentToDoc, docToContent } from "../lib/content-model"
|
|
|
-import { classifyBlock } from "../lib/markdown-rules/block-classifier"
|
|
|
+} from "@/composables/usePatternPlugin"
|
|
|
+import { contentToDoc, docToContent } from "@/lib/content-model"
|
|
|
+import { classifyBlock } from "@/lib/markdown-rules/block-classifier"
|
|
|
|
|
|
const content = defineModel<string>("content")
|
|
|
|
|
|
@@ -182,7 +182,7 @@ onMounted(() => {
|
|
|
if (lines.length <= 1) return false
|
|
|
|
|
|
const classifications = lines.map((line) => classifyBlock(line))
|
|
|
- const firstType = classifications[0].kind
|
|
|
+ const firstType = classifications[0]!.kind
|
|
|
|
|
|
const isContinuationBlock = (kind: string) =>
|
|
|
kind === "blockquote" &&
|
|
|
@@ -213,20 +213,21 @@ onMounted(() => {
|
|
|
schema.nodes.doc.create(null, afterDoc.content),
|
|
|
)
|
|
|
|
|
|
- const firstGroupLines: string[] = [lines[0]]
|
|
|
+ const firstGroupLines: string[] = [lines[0]!]
|
|
|
const restLines: string[] = []
|
|
|
|
|
|
let foundBreak = false
|
|
|
for (let i = 1; i < lines.length; i++) {
|
|
|
+ const c = classifications[i]!
|
|
|
+ const line = lines[i]!
|
|
|
if (
|
|
|
!foundBreak &&
|
|
|
- (classifications[i].kind === firstType ||
|
|
|
- classifications[i].kind === "paragraph")
|
|
|
+ (c.kind === firstType || c.kind === "paragraph")
|
|
|
) {
|
|
|
- firstGroupLines.push(lines[i])
|
|
|
+ firstGroupLines.push(line)
|
|
|
} else {
|
|
|
foundBreak = true
|
|
|
- restLines.push(lines[i])
|
|
|
+ restLines.push(line)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -264,12 +265,12 @@ onMounted(() => {
|
|
|
// different block type, auto-promote it by firing a split.
|
|
|
const lines = newContent.split("\n")
|
|
|
if (lines.length > 1) {
|
|
|
- const firstBlock = classifyBlock(lines[0])
|
|
|
+ const firstBlock = classifyBlock(lines[0]!)
|
|
|
const isContinuationBlock = (kind: string) =>
|
|
|
kind === "blockquote" &&
|
|
|
(firstBlock.kind === "callout" || firstBlock.kind === "blockquote")
|
|
|
for (let i = 1; i < lines.length; i++) {
|
|
|
- const block = classifyBlock(lines[i])
|
|
|
+ const block = classifyBlock(lines[i]!)
|
|
|
if (
|
|
|
block.kind !== "paragraph" &&
|
|
|
!isContinuationBlock(block.kind) &&
|