@@ -51,18 +51,18 @@ class CopyPasteEditProvider implements vscode.DocumentPasteEditProvider {
51
51
// create updated metadata for cell (prep for WorkspaceEdit)
52
52
const b64string = encodeBase64 ( fileDataAsUint8 ) ;
53
53
const startingAttachments = currentCell . metadata . custom ?. attachments ;
54
- const [ newMetadata , revisedFilename ] = buildMetadata ( b64string , currentCell , filename , filetype , startingAttachments ) ;
54
+ const newAttachment = buildAttachment ( b64string , currentCell , filename , filetype , startingAttachments ) ;
55
55
56
56
// build edits
57
- const nbEdit = vscode . NotebookEdit . updateCellMetadata ( currentCell . index , newMetadata ) ;
57
+ const nbEdit = vscode . NotebookEdit . updateCellMetadata ( currentCell . index , newAttachment . metadata ) ;
58
58
const workspaceEdit = new vscode . WorkspaceEdit ( ) ;
59
59
workspaceEdit . set ( notebookUri , [ nbEdit ] ) ;
60
60
61
61
// create a snippet for paste
62
62
const pasteSnippet = new vscode . SnippetString ( ) ;
63
63
pasteSnippet . appendText ( '` ) ;
64
+ pasteSnippet . appendPlaceholder ( `${ clipboardFilename } ` ) ;
65
+ pasteSnippet . appendText ( `](attachment:${ newAttachment . filename } )` ) ;
66
66
67
67
return { insertText : pasteSnippet , additionalEdit : workspaceEdit } ;
68
68
}
@@ -122,7 +122,7 @@ function encodeBase64(buffer: Uint8Array, padded = true, urlSafe = false) {
122
122
return output ;
123
123
}
124
124
125
- function buildMetadata ( b64 : string , cell : vscode . NotebookCell , filename : string , filetype : string , startingAttachments : any ) : [ { [ key : string ] : any } , string ] {
125
+ function buildAttachment ( b64 : string , cell : vscode . NotebookCell , filename : string , filetype : string , startingAttachments : any ) : { metadata : { [ key : string ] : any } ; filename : string } {
126
126
const outputMetadata = { ...cell . metadata } ;
127
127
let tempFilename = filename + filetype ;
128
128
@@ -142,7 +142,10 @@ function buildMetadata(b64: string, cell: vscode.NotebookCell, filename: string,
142
142
}
143
143
outputMetadata . custom . attachments [ tempFilename ] = { 'image/png' : b64 } ;
144
144
}
145
- return [ outputMetadata , tempFilename ] ;
145
+ return {
146
+ metadata : outputMetadata ,
147
+ filename : tempFilename
148
+ } ;
146
149
}
147
150
148
151
export function imagePasteSetup ( ) {
0 commit comments