@@ -20,26 +20,61 @@ const website: Website = {
20
20
const editor = unsafeWindow . pad . editor ;
21
21
if ( editor . getCopyContent ) {
22
22
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 || "" ;
25
25
return {
26
26
[ TEXT_PLAIN ] : plainText ,
27
27
[ TEXT_HTML ] : htmlText ,
28
28
} ;
29
29
} else {
30
30
editor . _docEnv . copyable = true ;
31
31
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 || "" ;
34
34
editor . _docEnv . copyable = false ;
35
35
return {
36
36
[ TEXT_PLAIN ] : plainText ,
37
37
[ TEXT_HTML ] : htmlText ,
38
38
} ;
39
39
}
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 "" ;
40
66
}
41
67
return "" ;
42
68
} ,
43
69
} ;
44
70
45
71
export 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