File tree Expand file tree Collapse file tree 9 files changed +43
-18
lines changed
Expand file tree Collapse file tree 9 files changed +43
-18
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ export const FOCUS = "focus";
1919export const BLUR = "blur" ;
2020export const FOCUS_IN = "focusin" ;
2121export const FOCUS_OUT = "focusout" ;
22+ export const PASTE = "paste" ;
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ const CI_REQUEST_ENUM = [
88 "DEBUG_MOUSE_EVENT" ,
99 "DEBUG_FOCUS_EVENT" ,
1010 "DEBUG_EDITABLE" ,
11+ "DEBUG_PASTE" ,
1112] as const ;
13+
1214export const CONTENT_TO_INJECT_REQUEST = CI_REQUEST_ENUM . reduce (
1315 ( acc , cur ) => ( { ...acc , [ cur ] : `__${ cur } __${ MARK } __` } ) ,
1416 { } as { [ K in typeof CI_REQUEST_ENUM [ number ] ] : `__${K } __${typeof MARK } __` }
@@ -28,6 +30,7 @@ export type EventMap = {
2830 [ CONTENT_TO_INJECT_REQUEST . DEBUG_MOUSE_EVENT ] : null ;
2931 [ CONTENT_TO_INJECT_REQUEST . DEBUG_FOCUS_EVENT ] : null ;
3032 [ CONTENT_TO_INJECT_REQUEST . DEBUG_EDITABLE ] : null ;
33+ [ CONTENT_TO_INJECT_REQUEST . DEBUG_PASTE ] : null ;
3134} ;
3235
3336export type CIRequestType = Reflex . Tuple < EventMap > ;
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ const PC_REQUEST_TYPE = [
99 "DEBUG_MOUSE_EVENT" ,
1010 "DEBUG_FOCUS_EVENT" ,
1111 "DEBUG_EDITABLE" ,
12+ "DEBUG_PASTE_EVENT" ,
1213] as const ;
14+
1315export const POPUP_TO_CONTENT_REQUEST = PC_REQUEST_TYPE . reduce (
1416 ( acc , cur ) => ( { ...acc , [ cur ] : `__${ cur } __${ MARK } __` } ) ,
1517 { } as { [ K in typeof PC_REQUEST_TYPE [ number ] ] : `__${K } __${typeof MARK } __` }
@@ -23,6 +25,7 @@ type EventMap = {
2325 [ POPUP_TO_CONTENT_REQUEST . DEBUG_MOUSE_EVENT ] : null ;
2426 [ POPUP_TO_CONTENT_REQUEST . DEBUG_FOCUS_EVENT ] : null ;
2527 [ POPUP_TO_CONTENT_REQUEST . DEBUG_EDITABLE ] : null ;
28+ [ POPUP_TO_CONTENT_REQUEST . DEBUG_PASTE_EVENT ] : null ;
2629} ;
2730
2831export type PCRequestType = Reflex . Tuple < EventMap > ;
Original file line number Diff line number Diff line change @@ -84,5 +84,12 @@ export const onPopupMessage = (data: PCRequestType) => {
8484 } ) ;
8585 break ;
8686 }
87+ case PCBridge . REQUEST . DEBUG_PASTE_EVENT : {
88+ CIBridge . postToInject ( {
89+ type : CIBridge . REQUEST . DEBUG_PASTE ,
90+ payload : null ,
91+ } ) ;
92+ break ;
93+ }
8794 }
8895} ;
Original file line number Diff line number Diff line change @@ -48,6 +48,10 @@ export const onContentMessage = (handler: WebSite) => {
4848 document . body . contentEditable = "true" ;
4949 break ;
5050 }
51+ case CIBridge . REQUEST . DEBUG_PASTE : {
52+ EventBus . on ( EVENTS_ENUM . PASTE_CAPTURE , stopNativePropagation ) ;
53+ break ;
54+ }
5155 }
5256 } ;
5357} ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const EVENTS_TYPE = [
2121 "MOUSE_MOVE_CAPTURE" ,
2222 "TOUCH_MOVE_CAPTURE" ,
2323 "TOUCH_END_CAPTURE" ,
24+ "PASTE_CAPTURE" ,
2425] as const ;
2526
2627export const EVENTS_ENUM = EVENTS_TYPE . reduce (
@@ -48,6 +49,7 @@ interface EventBusParams {
4849 [ EVENTS_ENUM . BLUR_CAPTURE ] : FocusEvent ;
4950 [ EVENTS_ENUM . TOUCH_MOVE_CAPTURE ] : TouchEvent ;
5051 [ EVENTS_ENUM . TOUCH_END_CAPTURE ] : TouchEvent ;
52+ [ EVENTS_ENUM . PASTE_CAPTURE ] : ClipboardEvent ;
5153}
5254
5355declare module "laser-utils/dist/es/event-bus" {
Original file line number Diff line number Diff line change @@ -8,10 +8,4 @@ $box-shadow: 0 0 4px var(--color-border-2);
88 border-radius : 4px ;
99 box-shadow : $box-shadow ;
1010
11- .row {
12- margin-bottom : 5px ;
13- & :last-child {
14- margin-bottom : auto ;
15- }
16- }
1711}
Original file line number Diff line number Diff line change @@ -4,17 +4,16 @@ import type { FC } from "react";
44import type { I18n } from "@/popup/i18n" ;
55import { PCBridge } from "@/bridge/popup-content" ;
66
7- const Row = Grid . Row ;
8- const Col = Grid . Col ;
7+ const GridItem = Grid . GridItem ;
98
109export const Tools : FC < {
1110 i18n : I18n ;
1211 visible ?: boolean ;
1312} > = ( { i18n } ) => {
1413 return (
1514 < div className = { styles . container } >
16- < Row className = { styles . row } gutter = { 10 } >
17- < Col span = { 12 } >
15+ < Grid cols = { 2 } colGap = { 10 } rowGap = { 5 } >
16+ < GridItem >
1817 < Button
1918 size = "mini"
2019 onClick = { ( ) =>
@@ -26,8 +25,8 @@ export const Tools: FC<{
2625 >
2726 { i18n . t ( "Tools.MouseEvent" ) }
2827 </ Button >
29- </ Col >
30- < Col span = { 12 } >
28+ </ GridItem >
29+ < GridItem >
3130 < Button
3231 onClick = { ( ) =>
3332 PCBridge . postToContent ( {
@@ -39,10 +38,8 @@ export const Tools: FC<{
3938 >
4039 { i18n . t ( "Tools.FocusEvent" ) }
4140 </ Button >
42- </ Col >
43- </ Row >
44- < Row className = { styles . row } >
45- < Col span = { 12 } >
41+ </ GridItem >
42+ < GridItem >
4643 < Button
4744 onClick = { ( ) =>
4845 PCBridge . postToContent ( {
@@ -54,8 +51,21 @@ export const Tools: FC<{
5451 >
5552 { i18n . t ( "Tools.Editable" ) }
5653 </ Button >
57- </ Col >
58- </ Row >
54+ </ GridItem >
55+ < GridItem >
56+ < Button
57+ onClick = { ( ) =>
58+ PCBridge . postToContent ( {
59+ type : PCBridge . REQUEST . DEBUG_PASTE_EVENT ,
60+ payload : null ,
61+ } )
62+ }
63+ size = "mini"
64+ >
65+ { i18n . t ( "Tools.PasteEvent" ) }
66+ </ Button >
67+ </ GridItem >
68+ </ Grid >
5969 </ div >
6070 ) ;
6171} ;
Original file line number Diff line number Diff line change @@ -20,5 +20,6 @@ export const en = {
2020 MouseEvent : "MouseEvent" ,
2121 FocusEvent : "FocusEvent" ,
2222 Editable : "Editable" ,
23+ PasteEvent : "PasteEvent" ,
2324 } ,
2425} ;
You can’t perform that action at this time.
0 commit comments