1+ import { IPublicModelClipboard } from '@alilc/lowcode-types' ;
2+
13function getDataFromPasteEvent ( event : ClipboardEvent ) {
24 const { clipboardData } = event ;
35 if ( ! clipboardData ) {
@@ -23,7 +25,13 @@ function getDataFromPasteEvent(event: ClipboardEvent) {
2325 }
2426}
2527
26- class Clipboard {
28+ export interface IClipboard extends IPublicModelClipboard {
29+
30+ initCopyPaster ( el : HTMLTextAreaElement ) : void ;
31+
32+ injectCopyPaster ( document : Document ) : void ;
33+ }
34+ class Clipboard implements IClipboard {
2735 private copyPasters : HTMLTextAreaElement [ ] = [ ] ;
2836
2937 private waitFn ?: ( data : any , e : ClipboardEvent ) => void ;
@@ -56,7 +64,7 @@ class Clipboard {
5664 }
5765
5866 injectCopyPaster ( document : Document ) {
59- if ( this . copyPasters . find ( x => x . ownerDocument === document ) ) {
67+ if ( this . copyPasters . find ( ( x ) => x . ownerDocument === document ) ) {
6068 return ;
6169 }
6270 const copyPaster = document . createElement < 'textarea' > ( 'textarea' ) ;
@@ -69,8 +77,8 @@ class Clipboard {
6977 } ;
7078 }
7179
72- setData ( data : any ) {
73- const copyPaster = this . copyPasters . find ( x => x . ownerDocument ) ;
80+ setData ( data : any ) : void {
81+ const copyPaster = this . copyPasters . find ( ( x ) => x . ownerDocument ) ;
7482 if ( ! copyPaster ) {
7583 return ;
7684 }
@@ -81,12 +89,12 @@ class Clipboard {
8189 copyPaster . blur ( ) ;
8290 }
8391
84- waitPasteData ( e : KeyboardEvent , cb : ( data : any , e : ClipboardEvent ) => void ) {
85- const win = e . view ;
92+ waitPasteData ( keyboardEvent : KeyboardEvent , cb : ( data : any , e : ClipboardEvent ) => void ) {
93+ const win = keyboardEvent . view ;
8694 if ( ! win ) {
8795 return ;
8896 }
89- const copyPaster = this . copyPasters . find ( cp => cp . ownerDocument === win . document ) ;
97+ const copyPaster = this . copyPasters . find ( ( cp ) => cp . ownerDocument === win . document ) ;
9098 if ( copyPaster ) {
9199 copyPaster . select ( ) ;
92100 this . waitFn = cb ;
0 commit comments