@@ -45,17 +45,23 @@ class PasteReference {
4545 this . copyMode = args . copyMode ;
4646 DocumentService . ready ( ) . then ( ( ) => {
4747 if ( document . querySelectorAll ( '.t3js-page-columns' ) . length > 0 ) {
48- this . getClipboardData ( ) ;
49- this . generateButtonTemplates ( ) ;
50- this . activatePasteIcons ( ) ;
51- this . initializeEvents ( ) ;
52- this . initModalEventListener ( ) ;
48+ // promise to assure that most recent data are used
49+ this . getClipboardData ( )
50+ . then ( ( ) => {
51+ this . generateButtonTemplates ( ) ;
52+ this . activatePasteIcons ( ) ;
53+ this . initializeEvents ( ) ;
54+ this . initModalEventListener ( ) ;
55+ } )
56+ . catch ( ( err ) => {
57+ console . error ( 'Error initializing PasteReference:' , err ) ;
58+ } ) ;
5359 }
5460 } ) ;
5561 }
5662
5763 getClipboardData ( ) {
58- ( new AjaxRequest ( top . TYPO3 . settings . Clipboard . moduleUrl ) )
64+ return ( new AjaxRequest ( top . TYPO3 . settings . Clipboard . moduleUrl ) )
5965 . withQueryArguments ( { action : 'getClipboardData' } )
6066 . post ( { table : 'tt_content' } )
6167 . then ( async ( response ) => {
@@ -73,6 +79,9 @@ class PasteReference {
7379 this . itemOnClipboardTitleHtml = record ? record . title : '' ;
7480 this . itemOnClipboardTable = table ;
7581 }
82+ else {
83+ console . error ( 'Error: ClipboardData couldn\'t be retieved.' ) ;
84+ } ;
7685 } ) ;
7786 }
7887
@@ -112,7 +121,8 @@ class PasteReference {
112121 resolve ( elementAbove . querySelector ( selector ) ) ;
113122 }
114123 } ) ;
115- // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
124+ // If you get "parameter 1 is not of type 'Node'" error,
125+ // see https://stackoverflow.com/a/77855838/492336
116126 observer . observe ( document . body , {
117127 childList : true ,
118128 subtree : true
@@ -215,7 +225,7 @@ class PasteReference {
215225 . setPid ( page )
216226 . setColpos ( colpos )
217227 . setUid ( tableUid ) ;
218-
228+
219229 if ( txContainerParent > 0 ) {
220230 draggableObj . setTxContainerParent ( txContainerParent ) ;
221231 }
@@ -255,9 +265,12 @@ class PasteReference {
255265 + ' title="' + TYPO3 . lang [ 'tx_paste_reference_js.copyfrompage' ] + '">'
256266 + '<typo3-backend-icon identifier="actions-insert-reference" size="small"></typo3-backend-icon>'
257267 + '</button>' ;
268+ /*
269+ // might removal fix issue #79?
258270 if (!this.itemOnClipboardUid) {
259271 return;
260272 }
273+ */
261274 this . pasteAfterLinkTemplate = '<button'
262275 + ' type="button"'
263276 + ' class="t3js-paste t3js-paste' + ( this . copyMode ? '-' + this . copyMode : '' ) + ' t3js-paste-after btn btn-default btn-sm"'
@@ -570,12 +583,3 @@ class PasteReference {
570583}
571584
572585export default PasteReference ;
573-
574- if ( ! PasteReference . instance && top . pasteReferenceAllowed ) {
575- const pollTime = 100 ;
576- window . setTimeout ( function ( ) {
577- if ( ! PasteReference . instance ) {
578- const pasteReference = new PasteReference ( { } ) ;
579- }
580- } , pollTime ) ;
581- }
0 commit comments