refactor: remove FFmpeg dependencies and related video processing logic

- Deleted FFmpeg related packages from package.json and package-lock.json.
- Removed video transcoding and editing functionalities from FileContent.vue.
- Simplified video handling logic and error management in FileContent.vue.
- Added a clear button in MilkdownEditor.vue for clearing the editor content.
- Enhanced UniverPreview.vue to clear detached popups and mount nodes on destroy.
- Updated docBlockPlugin.ts to improve context handling for document blocks.
- Cleaned up vite.config.js by removing cross-origin isolation headers.
This commit is contained in:
2026-05-03 19:14:55 +08:00
parent 477f090dfa
commit 6dc9933853
8 changed files with 181 additions and 749 deletions
+97 -5
View File
@@ -18,6 +18,8 @@ import {
const FALLBACK_BLOCK_SEPARATOR = '\n\n'
const FALLBACK_LEAF_TEXT = '\n'
const CONTEXT_SEPARATOR = '\n\n'
const MAX_SUFFIX_RATIO = 0.35
function serializeRangeToMarkdown(
doc: ProseNode,
@@ -33,6 +35,75 @@ function serializeRangeToMarkdown(
return sliceDoc ? serializer(sliceDoc) : doc.textBetween(from, to, FALLBACK_BLOCK_SEPARATOR, FALLBACK_LEAF_TEXT)
}
function getJoinedLength(parts: string[]) {
let total = 0
let hasContent = false
for (const part of parts) {
if (!part) continue
if (hasContent) total += CONTEXT_SEPARATOR.length
total += part.length
hasContent = true
}
return total
}
function takeTail(text: string, limit: number) {
if (!text || limit <= 0) return ''
if (text.length <= limit) return text
return text.slice(-limit)
}
function takeHead(text: string, limit: number) {
if (!text || limit <= 0) return ''
if (text.length <= limit) return text
return text.slice(0, limit)
}
function fitPrefixSections(parts: string[], limit: number) {
if (limit <= 0) return ''
const fitted: string[] = []
let remaining = limit
for (let index = parts.length - 1; index >= 0; index -= 1) {
const part = parts[index]
if (!part || remaining <= 0) continue
const separatorCost = fitted.length > 0 ? CONTEXT_SEPARATOR.length : 0
if (remaining <= separatorCost) break
const nextPart = takeTail(part, remaining - separatorCost)
if (!nextPart) continue
fitted.unshift(nextPart)
remaining -= nextPart.length + separatorCost
}
return fitted.join(CONTEXT_SEPARATOR)
}
function fitSuffixSections(parts: string[], limit: number) {
if (limit <= 0) return ''
const fitted: string[] = []
let remaining = limit
for (const part of parts) {
if (!part || remaining <= 0) continue
const separatorCost = fitted.length > 0 ? CONTEXT_SEPARATOR.length : 0
if (remaining <= separatorCost) break
const nextPart = takeHead(part, remaining - separatorCost)
if (!nextPart) continue
fitted.push(nextPart)
remaining -= nextPart.length + separatorCost
}
return fitted.join(CONTEXT_SEPARATOR)
}
function buildDocContext(doc: ProseNode, excludePos?: number) {
const blocks: string[] = []
doc.descendants((node, pos) => {
@@ -112,16 +183,37 @@ class DocBlockNodeView implements NodeView {
const before = stripDocBlockMarkdown(serializeRangeToMarkdown(doc, 0, pos, schema, this.serializer))
const after = stripDocBlockMarkdown(serializeRangeToMarkdown(doc, pos + this.node.nodeSize, doc.content.size, schema, this.serializer))
const docContext = buildDocContext(doc, pos)
const mergedPrefix = [docContext, before, payload.prefix].filter(Boolean).join('\n\n')
const mergedSuffix = [payload.suffix, after].filter(Boolean).join('\n\n')
const prefixParts = [docContext, before, payload.prefix].filter(Boolean)
const suffixParts = [payload.suffix, after].filter(Boolean)
const mergedPrefix = prefixParts.join(CONTEXT_SEPARATOR)
const mergedSuffix = suffixParts.join(CONTEXT_SEPARATOR)
if (mergedPrefix.length + mergedSuffix.length > DOC_CONTEXT_LIMIT) {
const prefixCapacity = getJoinedLength(prefixParts)
const suffixCapacity = getJoinedLength(suffixParts)
const maxSuffixBudget = Math.min(suffixCapacity, Math.floor(DOC_CONTEXT_LIMIT * MAX_SUFFIX_RATIO))
let suffixBudget = maxSuffixBudget
let prefixBudget = DOC_CONTEXT_LIMIT - suffixBudget
if (prefixCapacity < prefixBudget) {
const transferable = prefixBudget - prefixCapacity
suffixBudget = Math.min(suffixCapacity, suffixBudget + transferable)
prefixBudget = DOC_CONTEXT_LIMIT - suffixBudget
} else if (suffixCapacity < suffixBudget) {
const transferable = suffixBudget - suffixCapacity
prefixBudget = Math.min(prefixCapacity, prefixBudget + transferable)
suffixBudget = DOC_CONTEXT_LIMIT - prefixBudget
}
return {
prefix: mergedPrefix.slice(0, DOC_CONTEXT_LIMIT),
suffix: '',
prefix: fitPrefixSections(prefixParts, prefixBudget),
suffix: fitSuffixSections(suffixParts, suffixBudget),
languageId: payload.languageId,
blocked: true,
blocked: false,
}
}
return {
prefix: mergedPrefix,
suffix: mergedSuffix,