| | @@ -8,11 +8,12 @@ |
| 8 | 8 | const BlobXferState = { |
| 9 | 9 | dropDetails: document.querySelector('#chat-drop-details'), |
| 10 | 10 | blob: undefined |
| 11 | 11 | }; |
| 12 | 12 | /** Updates the paste/drop zone with details of the pasted/dropped |
| 13 | | - data. */ |
| 13 | + data. The argument must be a Blob or Blob-like object (File) or |
| 14 | + it can be falsy to reset/clear that state.*/ |
| 14 | 15 | const updateDropZoneContent = function(blob){ |
| 15 | 16 | const bx = BlobXferState, dd = bx.dropDetails; |
| 16 | 17 | bx.blob = blob; |
| 17 | 18 | D.clearElement(dd); |
| 18 | 19 | if(!blob){ |
| | @@ -65,31 +66,27 @@ |
| 65 | 66 | //console.debug("pasted item =",item); |
| 66 | 67 | if('file'===item.kind){ |
| 67 | 68 | updateDropZoneContent(false/*clear prev state*/); |
| 68 | 69 | updateDropZoneContent(items[0].getAsFile()); |
| 69 | 70 | }else if(false && 'string'===item.kind){ |
| 70 | | - /* ----^^^^^ disabled for now: |
| 71 | | - |
| 72 | | - The intent here is that if form.msg is not active, populate |
| 73 | | - it with this text, but whether populating it from ctrl-v when |
| 74 | | - it does not have focus is a feature or a bug is debatable. |
| 75 | | - */ |
| 71 | + /* ----^^^^^ disabled for now: the intent here is that if |
| 72 | + form.msg is not active, populate it with this text, but |
| 73 | + whether populating it from ctrl-v when it does not have focus |
| 74 | + is a feature or a bug is debatable. It seems useful but may |
| 75 | + violate the Principle of Least Surprise. */ |
| 76 | 76 | if(document.activeElement !== form.msg){ |
| 77 | 77 | /* Overwrite input field if it DOES NOT have focus, |
| 78 | 78 | otherwise let it do its own paste handling. */ |
| 79 | 79 | item.getAsString((v)=>form.msg.value = v); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | }; |
| 83 | 83 | if(true){/* Add help button for drag/drop/paste zone */ |
| 84 | | - const help = D.div(); |
| 85 | | - form.file.parentNode.insertBefore(help, form.file); |
| 86 | | - F.helpButtonlets.create( |
| 87 | | - help, |
| 88 | | - "Select a file to upload, drag/drop a file into this spot, ", |
| 89 | | - "or paste an image from the clipboard if supported by ", |
| 90 | | - "your environment." |
| 84 | + form.file.parentNode.insertBefore( |
| 85 | + F.helpButtonlets.create( |
| 86 | + document.querySelector('#chat-input-file-area .help-buttonlet') |
| 87 | + ), form.file |
| 91 | 88 | ); |
| 92 | 89 | } |
| 93 | 90 | //////////////////////////////////////////////////////////// |
| 94 | 91 | // File drag/drop visual notification. |
| 95 | 92 | const dropHighlight = form.file /* target zone */; |
| 96 | 93 | |