@@ -20,26 +20,61 @@ const website: Website = {
2020 const editor = unsafeWindow . pad . editor ;
2121 if ( editor . getCopyContent ) {
2222 const content = editor . getCopyContent ( ) || { } ;
23- const plainText : string | undefined = content . plain ;
24- const htmlText : string | undefined = content . html ;
23+ const plainText : string = content . plain || "" ;
24+ const htmlText : string = content . html || "" ;
2525 return {
2626 [ TEXT_PLAIN ] : plainText ,
2727 [ TEXT_HTML ] : htmlText ,
2828 } ;
2929 } else {
3030 editor . _docEnv . copyable = true ;
3131 editor . clipboardManager . copy ( ) ;
32- const plainText : string | undefined = editor . clipboardManager . customClipboard . plain ;
33- const htmlText : string | undefined = editor . clipboardManager . customClipboard . html ;
32+ const plainText : string = editor . clipboardManager . customClipboard . plain || "" ;
33+ const htmlText : string = editor . clipboardManager . customClipboard . html || "" ;
3434 editor . _docEnv . copyable = false ;
3535 return {
3636 [ TEXT_PLAIN ] : plainText ,
3737 [ TEXT_HTML ] : htmlText ,
3838 } ;
3939 }
40+ } else if (
41+ unsafeWindow . SpreadsheetApp &&
42+ unsafeWindow . SpreadsheetApp . permissions &&
43+ unsafeWindow . SpreadsheetApp . permissions . sheetStatus &&
44+ unsafeWindow . SpreadsheetApp . permissions . sheetStatus . canCopy === false &&
45+ unsafeWindow . SpreadsheetApp . permissions . sheetStatus . canEdit &&
46+ unsafeWindow . SpreadsheetApp . permissions . sheetStatus . canEdit ( ) === false
47+ ) {
48+ utils . showButton ( ) ;
49+ const SpreadsheetApp = unsafeWindow . SpreadsheetApp ;
50+ const [ selection ] = SpreadsheetApp . view . getSelectionRanges ( ) ;
51+ if ( selection ) {
52+ const text : string [ ] = [ ] ;
53+ const { startColIndex, startRowIndex, endColIndex, endRowIndex } = selection ;
54+ for ( let i = startRowIndex ; i <= endRowIndex ; i ++ ) {
55+ for ( let k = startColIndex ; k <= endColIndex ; k ++ ) {
56+ const cell = SpreadsheetApp . workbook . activeSheet . getCellDataAtPosition ( i , k ) ;
57+ if ( ! cell ) continue ;
58+ text . push ( " " , cell . value || "" ) ;
59+ }
60+ i !== endRowIndex && text . push ( "\n" ) ;
61+ }
62+ const str = text . join ( "" ) ;
63+ return / ^ \s * $ / . test ( str ) ? "" : str ;
64+ }
65+ return "" ;
4066 }
4167 return "" ;
4268 } ,
4369} ;
4470
4571export default website ;
72+
73+ // Sheet
74+ // SpreadsheetApp.feature._copyPaste.copyPasteCache.onCopy({
75+ // selectGridRange: SpreadsheetApp.view.getSelectionRanges()[0],
76+ // copyType: 0,
77+ // app: SpreadsheetApp.feature.app,
78+ // isSelectAll: undefined,
79+ // });
80+ // SpreadsheetApp.sheetStatus.workbookStatus.status.setCanCopy(true);
0 commit comments