@@ -56,6 +56,7 @@ import {
56
56
} from '@lexical/utils' ;
57
57
import {
58
58
$createParagraphNode ,
59
+ $createTextNode ,
59
60
$getNodeByKey ,
60
61
$getRoot ,
61
62
$getSelection ,
@@ -85,6 +86,8 @@ import useModal from '../hooks/useModal';
85
86
import catTypingGif from '../images/cat-typing.gif' ;
86
87
import yellowFlowerImage from '../images/yellow-flower.jpg' ;
87
88
import { $createStickyNode } from '../nodes/StickyNode' ;
89
+ import { $isTweetNode } from '../nodes/TweetNode' ;
90
+ import { $isYouTubeNode } from '../nodes/YouTubeNode' ;
88
91
import Button from '../ui/Button' ;
89
92
import ColorPicker from '../ui/ColorPicker' ;
90
93
import DropDown , { DropDownItem } from '../ui/DropDown' ;
@@ -699,6 +702,23 @@ function BlockFormatDropDown({
699
702
if ( selection . isCollapsed ( ) ) {
700
703
$wrapLeafNodesInElements ( selection , ( ) => $createCodeNode ( ) ) ;
701
704
} else {
705
+ selection . getNodes ( ) . forEach ( ( node ) => {
706
+ // Explicity set fallback text content for some decorators nodes.
707
+ if ( $isTweetNode ( node ) ) {
708
+ node . replace (
709
+ $createTextNode (
710
+ `https://twitter.com/i/web/status/${ node . getId ( ) } ` ,
711
+ ) ,
712
+ ) ;
713
+ } else if ( $isYouTubeNode ( node ) ) {
714
+ node . replace (
715
+ $createTextNode (
716
+ `https://www.youtube.com/watch?v=${ node . getId ( ) } ` ,
717
+ ) ,
718
+ ) ;
719
+ }
720
+ } ) ;
721
+
702
722
const textContent = selection . getTextContent ( ) ;
703
723
const codeNode = $createCodeNode ( ) ;
704
724
selection . insertNodes ( [ codeNode ] ) ;
0 commit comments