1
1
const htmlSnip =
2
- `<div class="div_class">
2
+ `<div class="div_class">
3
3
<h1>Title</h1>
4
4
<p class="p">
5
5
Life is <i>like</i> a box of
@@ -8,65 +8,64 @@ const htmlSnip =
8
8
</div>
9
9
`
10
10
Page ( {
11
- data : {
12
- theme : 'light' ,
13
- disableContextMenu : true ,
14
- showBtn : false ,
15
- btnX : 0 ,
16
- btnY : 0 ,
17
- selectedString : '' ,
18
- htmlSnip,
19
- } ,
20
- onShareAppMessage ( ) {
21
- return {
22
- title : 'selection' ,
23
- path : 'packageComponent/pages/content/selection/selection'
24
- }
25
- } ,
26
- onUnload ( ) {
27
- if ( wx . offThemeChange ) {
28
- wx . offThemeChange ( )
29
- }
30
- } ,
31
- onLoad ( ) {
11
+ data : {
12
+ theme : 'light' ,
13
+ disableContextMenu : true ,
14
+ showBtn : false ,
15
+ btnX : 0 ,
16
+ btnY : 0 ,
17
+ selectedString : '' ,
18
+ htmlSnip,
19
+ } ,
20
+ onShareAppMessage ( ) {
21
+ return {
22
+ title : 'selection' ,
23
+ path : 'packageComponent/pages/content/selection/selection'
24
+ }
25
+ } ,
26
+ onUnload ( ) {
27
+ if ( wx . offThemeChange ) {
28
+ wx . offThemeChange ( )
29
+ }
30
+ } ,
31
+ onLoad ( ) {
32
+ this . setData ( {
33
+ theme : wx . getSystemInfoSync ( ) . theme || 'light'
34
+ } )
35
+
36
+ if ( wx . onThemeChange ) {
37
+ wx . onThemeChange ( ( { theme} ) => {
38
+ this . setData ( { theme} )
39
+ } )
40
+ }
41
+ } ,
42
+ selectionChangeHandler ( e ) {
43
+ const selection = e . detail
44
+ if ( selection . isCollapsed === false ) {
45
+ this . setData ( {
46
+ showBtn : true ,
47
+ selectedString : e . detail . selectedString ,
48
+ btnX : e . detail . firstRangeRect . x ,
49
+ btnY : e . detail . firstRangeRect . y ,
50
+ } )
51
+ } else {
32
52
this . setData ( {
33
- theme : wx . getSystemInfoSync ( ) . theme || 'light'
53
+ showBtn : false
34
54
} )
35
-
36
- if ( wx . onThemeChange ) {
37
- wx . onThemeChange ( ( { theme} ) => {
38
- this . setData ( { theme} )
55
+ }
56
+ } ,
57
+ copySelectedString ( ) {
58
+ wx . setClipboardData ( {
59
+ data : this . data . selectedString ,
60
+ success ( ) {
61
+ wx . getClipboardData ( {
62
+ success ( res ) {
63
+ wx . showToast ( {
64
+ title : `复制成功:${ res . data } `
65
+ } )
66
+ }
39
67
} )
40
68
}
41
- } ,
42
- selectionChangeHandler ( e ) {
43
- const selection = e . detail
44
- if ( selection . isCollapsed === false ) {
45
- this . setData ( {
46
- showBtn : true ,
47
- selectedString : e . detail . selectedString ,
48
- btnX : e . detail . firstRangeRect . x ,
49
- btnY : e . detail . firstRangeRect . y ,
50
- } )
51
- } else {
52
- this . setData ( {
53
- showBtn : false
54
- } )
55
- }
56
- } ,
57
- copySelectedString ( ) {
58
- wx . setClipboardData ( {
59
- data : this . data . selectedString ,
60
- success ( ) {
61
- wx . getClipboardData ( {
62
- success ( res ) {
63
- wx . showToast ( {
64
- title : `复制成功:${ res . data } `
65
- } )
66
- }
67
- } )
68
- }
69
- } )
70
- }
71
- } )
72
-
69
+ } )
70
+ }
71
+ } )
0 commit comments