File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ export type PlaygroundProps = {
82
82
directiveSyntax ?: DirectiveSyntaxValue ;
83
83
disabledHTMLBlockModes ?: EmbeddingMode [ ] ;
84
84
disableMarkdownItAttrs ?: boolean ;
85
+ markupParseHtmlOnPaste ?: boolean ;
85
86
} & Pick < UseMarkdownEditorProps , 'experimental' | 'wysiwygConfig' > &
86
87
Pick <
87
88
MarkdownEditorViewProps ,
@@ -133,6 +134,7 @@ export const Playground = memo<PlaygroundProps>((props) => {
133
134
directiveSyntax,
134
135
disabledHTMLBlockModes,
135
136
disableMarkdownItAttrs,
137
+ markupParseHtmlOnPaste,
136
138
} = props ;
137
139
const [ editorMode , setEditorMode ] = useState < MarkdownEditorMode > ( initialEditor ?? 'wysiwyg' ) ;
138
140
const [ mdRaw , setMdRaw ] = useState < MarkupString > ( initial || '' ) ;
@@ -236,6 +238,7 @@ export const Playground = memo<PlaygroundProps>((props) => {
236
238
: undefined ,
237
239
} ,
238
240
markupConfig : {
241
+ parseHtmlOnPaste : true ,
239
242
extensions : markupConfigExtensions ,
240
243
parseInsertedUrlAsImage,
241
244
renderPreview,
@@ -260,6 +263,7 @@ export const Playground = memo<PlaygroundProps>((props) => {
260
263
experimental ?. prepareRawMarkup ,
261
264
directiveSyntax ,
262
265
disableMarkdownItAttrs ,
266
+ markupParseHtmlOnPaste ,
263
267
] ,
264
268
) ;
265
269
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
178
178
onScroll ( event ) ;
179
179
} ,
180
180
paste ( event , editor ) {
181
- if ( ! event . clipboardData ) return ;
181
+ if ( ! event . clipboardData ) return false ;
182
182
183
183
const pasteLogger = logger . nested ( {
184
184
domEvent : 'paste' ,
@@ -197,7 +197,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
197
197
logger . event ( { event : 'paste-markup' } ) ;
198
198
const reindentedYfmContent = smartReindent ( yfmContent , currentLine ) ;
199
199
editor . dispatch ( editor . state . replaceSelection ( reindentedYfmContent ) ) ;
200
- return ;
200
+ return true ;
201
201
}
202
202
203
203
// checking if a copy buffer content is suitable for convertion
@@ -231,7 +231,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
231
231
currentLine ,
232
232
) ;
233
233
editor . dispatch ( editor . state . replaceSelection ( reindentedHtmlContent ) ) ;
234
- return ;
234
+ return true ;
235
235
}
236
236
}
237
237
@@ -260,6 +260,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
260
260
title,
261
261
} ,
262
262
] ) ( editor ) ;
263
+ return true ;
263
264
}
264
265
}
265
266
}
@@ -271,7 +272,10 @@ export function createCodemirror(params: CreateCodemirrorParams) {
271
272
if ( pastedText !== reindentedText ) {
272
273
editor . dispatch ( editor . state . replaceSelection ( reindentedText ) ) ;
273
274
event . preventDefault ( ) ;
275
+ return true ;
274
276
}
277
+
278
+ return false ;
275
279
} ,
276
280
} ) ,
277
281
) ;
Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ export function shouldSkipHtmlConversion(clipboardData: DataTransfer): boolean {
55
55
// If there's no HTML content, skip conversion
56
56
if ( ! hasHtml ) return true ;
57
57
58
+ // Check for HTML only (text/html)
59
+ if ( clipboardData . types . length === 1 ) return false ;
60
+
58
61
// Check for standard HTML clipboard (text/plain + text/html)
59
62
if ( clipboardData . types . length === 2 ) return false ;
60
63
You can’t perform that action at this time.
0 commit comments