@@ -386,10 +386,13 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
386386 }
387387
388388 if ( types . includes ( "block-ref" ) ) {
389- protyle . toolbar . setInlineMark ( protyle , "block-ref" , "range" , {
389+ const refElement = protyle . toolbar . setInlineMark ( protyle , "block-ref" , "range" , {
390390 type : "id" ,
391391 color : `${ linkElement . dataset . id } ${ Constants . ZWSP } s${ Constants . ZWSP } ${ range . toString ( ) } `
392392 } ) ;
393+ if ( refElement [ 0 ] ) {
394+ protyle . toolbar . range . selectNodeContents ( refElement [ 0 ] ) ;
395+ }
393396 return ;
394397 }
395398 if ( types . includes ( "a" ) ) {
@@ -508,12 +511,12 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
508511 }
509512 if ( linkElement ) {
510513 const selectText = range . toString ( ) ;
511- const aElements = protyle . toolbar . setInlineMark ( protyle , "a" , "range" , {
514+ const aElements = protyle . toolbar . setInlineMark ( protyle , "a" , "range" , {
512515 type : "a" ,
513516 color : `${ linkElement . getAttribute ( "href" ) } ${ Constants . ZWSP } ${ selectText || linkElement . textContent } `
514517 } ) ;
515518 if ( ! selectText ) {
516- if ( aElements [ 0 ] . lastChild ) {
519+ if ( aElements [ 0 ] . lastChild ) {
517520 // https://github.com/siyuan-note/siyuan/issues/15801
518521 range . setEnd ( aElements [ 0 ] . lastChild , aElements [ 0 ] . lastChild . textContent . length ) ;
519522 }
@@ -546,11 +549,14 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
546549 if ( range . toString ( ) !== "" ) {
547550 const firstLine = textPlain . split ( "\n" ) [ 0 ] ;
548551 if ( isDynamicRef ( textPlain ) ) {
549- protyle . toolbar . setInlineMark ( protyle , "block-ref" , "range" , {
552+ const refElement = protyle . toolbar . setInlineMark ( protyle , "block-ref" , "range" , {
550553 type : "id" ,
551554 // range 不能 escape,否则 https://github.com/siyuan-note/siyuan/issues/8359
552555 color : `${ textPlain . substring ( 2 , 22 + 2 ) } ${ Constants . ZWSP } s${ Constants . ZWSP } ${ range . toString ( ) } `
553556 } ) ;
557+ if ( refElement [ 0 ] ) {
558+ protyle . toolbar . range . selectNodeContents ( refElement [ 0 ] ) ;
559+ }
554560 return ;
555561 } else if ( isFileAnnotation ( firstLine ) ) {
556562 protyle . toolbar . setInlineMark ( protyle , "file-annotation-ref" , "range" , {
0 commit comments