File tree Expand file tree Collapse file tree 6 files changed +16
-16
lines changed
Expand file tree Collapse file tree 6 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 1- const skipformattingMap = new WeakMap < HTMLElement , boolean > ( )
1+ const skipFormattingMap = new WeakMap < HTMLElement , boolean > ( )
22
33function setSkipFormattingFlag ( event : KeyboardEvent ) : void {
44 const { currentTarget : el } = event
55 const isSkipFormattingKeys = event . code === 'KeyV' && ( event . ctrlKey || event . metaKey ) && event . shiftKey
66
77 // Supports Cmd+Shift+V (Chrome) / Cmd+Shift+Opt+V (Safari, Firefox and Edge) to mimic paste and match style shortcut on MacOS.
88 if ( isSkipFormattingKeys || ( isSkipFormattingKeys && event . altKey ) ) {
9- skipformattingMap . set ( el as HTMLElement , true )
9+ skipFormattingMap . set ( el as HTMLElement , true )
1010 }
1111}
1212
1313function unsetSkipFormattedFlag ( event : ClipboardEvent ) : void {
1414 const { currentTarget : el } = event
15- skipformattingMap . delete ( el as HTMLElement )
15+ skipFormattingMap . delete ( el as HTMLElement )
1616}
1717
18- export function shouldSkipformatting ( el : HTMLElement ) : boolean {
19- const shouldSkipformattingState = skipformattingMap . get ( el ) ?? false
18+ export function shouldSkipFormatting ( el : HTMLElement ) : boolean {
19+ const shouldSkipFormattingState = skipFormattingMap . get ( el ) ?? false
2020
21- return shouldSkipformattingState
21+ return shouldSkipFormattingState
2222}
2323
2424export function installAround ( el : HTMLElement , ...installCallbacks : Array < ( el : HTMLElement ) => void > ) : void {
Original file line number Diff line number Diff line change 11import { insertText } from './text'
2- import { shouldSkipformatting } from './paste-keyboard-shortcut-helper'
2+ import { shouldSkipFormatting } from './paste-keyboard-shortcut-helper'
33
44export function install ( el : HTMLElement ) : void {
55 el . addEventListener ( 'paste' , onPaste )
@@ -12,7 +12,7 @@ export function uninstall(el: HTMLElement): void {
1212function onPaste ( event : ClipboardEvent ) {
1313 const transfer = event . clipboardData
1414 const { currentTarget : el } = event
15- if ( shouldSkipformatting ( el as HTMLElement ) ) return
15+ if ( shouldSkipFormatting ( el as HTMLElement ) ) return
1616 // if there is no clipboard data, or
1717 // if there is no html content in the clipboard, return
1818 if ( ! transfer || ! hasHTML ( transfer ) ) return
Original file line number Diff line number Diff line change 11/* @flow strict */
22import { insertText } from './text'
3- import { shouldSkipformatting } from './paste-keyboard-shortcut-helper'
3+ import { shouldSkipFormatting } from './paste-keyboard-shortcut-helper'
44
55export function install ( el : HTMLElement ) : void {
66 el . addEventListener ( 'dragover' , onDragover )
@@ -39,7 +39,7 @@ function onDragover(event: DragEvent) {
3939
4040function onPaste ( event : ClipboardEvent ) {
4141 const { currentTarget : el } = event
42- if ( shouldSkipformatting ( el as HTMLElement ) ) return
42+ if ( shouldSkipFormatting ( el as HTMLElement ) ) return
4343
4444 const transfer = event . clipboardData
4545 if ( ! transfer || ! hasLink ( transfer ) ) return
Original file line number Diff line number Diff line change 11import { insertText } from './text'
2- import { shouldSkipformatting } from './paste-keyboard-shortcut-helper'
2+ import { shouldSkipFormatting } from './paste-keyboard-shortcut-helper'
33
44export function install ( el : HTMLElement ) : void {
55 el . addEventListener ( 'paste' , onPaste )
@@ -11,7 +11,7 @@ export function uninstall(el: HTMLElement): void {
1111
1212function onPaste ( event : ClipboardEvent ) {
1313 const { currentTarget : el } = event
14- if ( shouldSkipformatting ( el as HTMLElement ) ) return
14+ if ( shouldSkipFormatting ( el as HTMLElement ) ) return
1515
1616 const transfer = event . clipboardData
1717 if ( ! transfer || ! hasPlainText ( transfer ) ) return
Original file line number Diff line number Diff line change 11import { insertText } from './text'
2- import { shouldSkipformatting } from './paste-keyboard-shortcut-helper'
2+ import { shouldSkipFormatting } from './paste-keyboard-shortcut-helper'
33
44export function install ( el : HTMLElement ) : void {
55 el . addEventListener ( 'dragover' , onDragover )
@@ -37,7 +37,7 @@ function onDragover(event: DragEvent) {
3737
3838function onPaste ( event : ClipboardEvent ) {
3939 const { currentTarget : el } = event
40- if ( shouldSkipformatting ( el as HTMLElement ) ) return
40+ if ( shouldSkipFormatting ( el as HTMLElement ) ) return
4141
4242 if ( ! event . clipboardData ) return
4343
Original file line number Diff line number Diff line change 11import { insertText } from './text'
2- import { shouldSkipformatting } from './paste-keyboard-shortcut-helper'
2+ import { shouldSkipFormatting } from './paste-keyboard-shortcut-helper'
33
44export function install ( el : HTMLElement ) : void {
55 el . addEventListener ( 'paste' , onPaste )
@@ -11,7 +11,7 @@ export function uninstall(el: HTMLElement): void {
1111
1212function onPaste ( event : ClipboardEvent ) {
1313 const { currentTarget : el } = event
14- if ( shouldSkipformatting ( el as HTMLElement ) ) return
14+ if ( shouldSkipFormatting ( el as HTMLElement ) ) return
1515
1616 const transfer = event . clipboardData
1717 if ( ! transfer || ! hasMarkdown ( transfer ) ) return
You can’t perform that action at this time.
0 commit comments