-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify paste from browser event #1963
Conversation
@@ -215,7 +215,8 @@ export default interface IEditor { | |||
clipboardData: ClipboardData, | |||
pasteAsText?: boolean, | |||
applyCurrentFormat?: boolean, | |||
pasteAsImage?: boolean | |||
pasteAsImage?: boolean, | |||
nativePaste?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding new parameter here, how about put it into ClipboardData, so that we don't polute this function interface.
@@ -125,7 +125,8 @@ export type CreatePasteFragment = ( | |||
position: NodePosition | null, | |||
pasteAsText: boolean, | |||
applyCurrentStyle: boolean, | |||
pasteAsImage: boolean | |||
pasteAsImage: boolean, | |||
nativePaste: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
/** | ||
* If true, the event was triggered by a native paste event (keyboard or native context menu paste) | ||
*/ | ||
readonly pasteNativeEvent: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to ClipboardData, then no need to change here
false /*pasteAsText*/, | ||
false /*applyCurrentStyle*/, | ||
false /*pasteAsImage*/, | ||
true /*nativePaste */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to ClipboardData, then set this value when extractClipboardItems()
…u/juliaroldi/rooster-paste
d893fc6
to
50b7dce
Compare
/** | ||
* If true, the event was triggered by a native paste event (keyboard or native context menu paste) | ||
*/ | ||
readonly pasteNativeEvent: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make any new property optional, to be compatible with older build
@@ -27,22 +27,23 @@ export default function extractClipboardEvent( | |||
event: ClipboardEvent, | |||
callback: (clipboardData: ClipboardData) => void, | |||
options?: ExtractClipboardEventOption, | |||
rangeBeforePaste?: Range | |||
rangeBeforePaste?: Range, | |||
pasteNativeEvent: boolean = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there is ClipboardEvent, it must be from native paste, so no need to provide this parameter here, and always pass true
@@ -21,7 +21,8 @@ import { | |||
export default function extractClipboardItemsForIE( | |||
dataTransfer: DataTransfer, | |||
callback: (data: ClipboardData) => void, | |||
options?: ExtractClipboardItemsForIEOptions | |||
options?: ExtractClipboardItemsForIEOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IE is deprecated. So no need to change this file any more
The pasteNativeEvent was created in the BeforePasteEvent object, so it is possible to differentiate a paste event triggered by RoosterJS api and paste event from browser (keyboard shortcut and native context menu).
A paste button was added to ContentModel ribbon and a log was added in EventViewer Pane.
Paste control:
If the paste event was triggered by a native event:
If the event was triggered by paste control: