Skip to content

Commit 800aeb2

Browse files
committed
fix: clipboard parse error
1 parent de1b6b0 commit 800aeb2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/editor/extensions/Clipboard/clipboard-extension.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { wysiwygTransformer } from '@/editor/components/WysiwygEditor'
22
import type { CreateExtensionPlugin } from '@remirror/core'
33
import { PlainExtension } from '@remirror/core'
44
import type { Slice, Node } from '@remirror/pm/model'
5-
import { DOMSerializer, DOMParser } from '@remirror/pm/model'
5+
import { DOMParser } from '@remirror/pm/model'
66

77
type UnknownRecord = Record<string, unknown>
88
function isPureText(content: UnknownRecord | UnknownRecord[] | undefined | null): boolean {
@@ -57,11 +57,12 @@ export class ClipboardExtension extends PlainExtension {
5757

5858
const domParser = DOMParser.fromSchema(schema)
5959
let dom
60-
if (html.length === 0) {
60+
if (text) {
6161
const slice = parser?.(text)
6262
if (!slice || typeof slice === 'string') return false
6363

64-
dom = DOMSerializer.fromSchema(schema).serializeFragment(slice.content)
64+
view.dispatch(view.state.tr.replaceSelectionWith(slice, true))
65+
return true
6566
} else {
6667
const template = document.createElement('template')
6768
template.innerHTML = html

src/editor/utils/prosemirrorNodeToHtml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const rmeProsemirrorNodeToHtml = async (
9292

9393
try {
9494
await Promise.all(imageLoadTasks)
95-
return HTML.stringify(fullAst)
95+
return HTML.stringify(fullAst) as string
9696
} catch (error) {
9797
return html
9898
}

0 commit comments

Comments
 (0)