@@ -1989,26 +1989,47 @@ const EditorPage = observer(forwardRef<I.BlockRef, Props>((props, ref) => {
19891989 const length = block . getLength ( ) ;
19901990 const position = length ? I . BlockPosition . Bottom : I . BlockPosition . Replace ;
19911991 const processor = U . Embed . getProcessorByUrl ( url ) ;
1992- const canBlock = ! isInsideTable && ! isLocal ;
1993-
1992+ const canBookmark = ! isInsideTable && ! isLocal ;
1993+
1994+ // Check if URL is an Anytype object link in the same space (but not the current page)
1995+ const linkParam = U . Common . getLinkParamFromUrl ( url ) ;
1996+ const isAnytypeObject = linkParam . isInside && linkParam . target ;
1997+ const isSameSpace = ! linkParam . spaceId || ( linkParam . spaceId == S . Common . space ) ;
1998+ const isSameObject = linkParam . target == rootId ;
1999+ const canObject = isAnytypeObject && isSameSpace && ! isSameObject && canBookmark ;
19942000 const options : any [ ] = [
1995- ! currentMark ? { id : 'link' , name : translate ( 'editorPagePasteLink' ) } : null ,
1996- canBlock ? { id : 'block' , name : translate ( 'editorPageCreateBookmark' ) } : null ,
1997- { id : 'cancel' , name : translate ( 'editorPagePasteText' ) } ,
1998- ] . filter ( it => it ) ;
2001+ { name : translate ( 'editorPagePasteAsHeader' ) , isSection : true }
2002+ ] ;
19992003
20002004 if ( processor !== null ) {
2005+ // Embed-compatible URL: Embed first
20012006 options . push ( { id : 'embed' , name : translate ( 'editorPagePasteEmbed' ) } ) ;
20022007 } ;
20032008
2009+ // Build options based on URL type
2010+ if ( canObject ) {
2011+ // Anytype Object Link: Object, Bookmark, URL, Plain Text
2012+ options . push ( { id : 'object' , name : translate ( 'editorPagePasteObject' ) } ) ;
2013+ } ;
2014+
2015+ if ( canBookmark ) {
2016+ options . push ( { id : 'bookmark' , name : translate ( 'editorPagePasteBookmark' ) } ) ;
2017+ } ;
2018+
2019+ if ( ! currentMark ) {
2020+ options . push ( { id : 'link' , name : translate ( 'editorPagePasteLink' ) } ) ;
2021+ } ;
2022+
2023+ options . push ( { id : 'cancel' , name : translate ( 'editorPagePasteText' ) } ) ;
2024+
20042025 S . Common . clearTimeout ( 'blockContext' ) ;
20052026
2006- const menuParam = {
2027+ const menuParam = {
20072028 component : 'select' ,
20082029 element : `#block-${ focused } ` ,
2009- recalcRect : ( ) => {
2030+ recalcRect : ( ) => {
20102031 const rect = U . Common . getSelectionRect ( ) ;
2011- return rect ? { ...rect , y : rect . y + win . scrollTop ( ) } : null ;
2032+ return rect ? { ...rect , y : rect . y + win . scrollTop ( ) } : null ;
20122033 } ,
20132034 offsetX : ( ) => {
20142035 const rect = U . Common . getSelectionRect ( ) ;
@@ -2025,12 +2046,33 @@ const EditorPage = observer(forwardRef<I.BlockRef, Props>((props, ref) => {
20252046 data : {
20262047 value : '' ,
20272048 options,
2049+ noFilter : true ,
20282050 onSelect : ( event : any , item : any ) => {
20292051 let marks = U . Common . objectCopy ( block . content . marks || [ ] ) ;
20302052 let value = block . content . text ;
20312053 let to = 0 ;
20322054
20332055 switch ( item . id ) {
2056+ case 'object' : {
2057+ const targetId = linkParam . target ;
2058+ const newBlock = {
2059+ type : I . BlockType . Link ,
2060+ content : {
2061+ ...U . Data . defaultLinkSettings ( ) ,
2062+ targetBlockId : targetId ,
2063+ } ,
2064+ } ;
2065+
2066+ C . BlockCreate ( rootId , focused , position , newBlock , ( message : any ) => {
2067+ if ( ! message . error . code ) {
2068+ blockCreate ( message . blockId , I . BlockPosition . Bottom , { type : I . BlockType . Text } ) ;
2069+
2070+ analytics . event ( 'CreateBlock' , { middleTime : message . middleTime , type : I . BlockType . Link } ) ;
2071+ } ;
2072+ } ) ;
2073+ break ;
2074+ } ;
2075+
20342076 case 'link' : {
20352077 if ( currentFrom == currentTo ) {
20362078 value = U . String . insert ( value , url + ' ' , currentFrom , currentFrom ) ;
@@ -2040,7 +2082,7 @@ const EditorPage = observer(forwardRef<I.BlockRef, Props>((props, ref) => {
20402082 } else {
20412083 to = currentTo ;
20422084 } ;
2043-
2085+
20442086 marks . push ( { type : I . MarkType . Link , range : { from : currentFrom , to } , param : url } ) ;
20452087
20462088 U . Data . blockSetText ( rootId , block . id , value , marks , true , ( ) => {
@@ -2050,7 +2092,7 @@ const EditorPage = observer(forwardRef<I.BlockRef, Props>((props, ref) => {
20502092 break ;
20512093 } ;
20522094
2053- case 'block ' : {
2095+ case 'bookmark ' : {
20542096 const bookmark = S . Record . getBookmarkType ( ) ;
20552097
20562098 C . BlockBookmarkCreateAndFetch ( rootId , focused , position , url , bookmark ?. defaultTemplateId , ( message : any ) => {
0 commit comments