Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
184 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
export { Decorator, CleanupCallback } from "./types"; | ||
export { default as withAutoHeight } from "./withAutoHeight"; | ||
export { default as withClickEvent } from "./withClickEvent"; | ||
export { default as withSetCommentID } from "./withSetCommentID"; | ||
export { default as withEventEmitter } from "./withEventEmitter"; | ||
export { default as withPymStorage } from "./withPymStorage"; | ||
export { default as withConfig } from "./withConfig"; | ||
export { default as withLiveCommentCount } from "./withLiveCommentCount"; | ||
export { default as withEventEmitter } from "./withEventEmitter"; | ||
export { default as withIOSSafariWidthWorkaround } from "./withIOSSafariWidthWorkaround"; | ||
export { default as withKeypressEvent } from "./withKeypressEvent"; | ||
export { default as withLiveCommentCount } from "./withLiveCommentCount"; | ||
export { default as withPymStorage } from "./withPymStorage"; | ||
export { default as withSetCommentID } from "./withSetCommentID"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Decorator } from "./types"; | ||
|
||
const withKeypressEvent: Decorator = (pym) => { | ||
const handleKeypress = (e: KeyboardEvent) => { | ||
const payload = { | ||
key: e.key, | ||
shiftKey: e.shiftKey, | ||
}; | ||
|
||
pym.sendMessage("keypress", JSON.stringify(payload)); | ||
}; | ||
|
||
document.addEventListener("keypress", handleKeypress); | ||
|
||
// Return cleanup callback. | ||
return () => { | ||
// Remove the event listeners. | ||
document.removeEventListener("keypress", handleKeypress); | ||
}; | ||
}; | ||
|
||
export default withKeypressEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
export { default as getViewer } from "./getViewer"; | ||
export { default as getViewerSourceID } from "./getViewerSourceID"; | ||
export { default as getURLWithCommentID } from "./getURLWithCommentID"; | ||
export { default as urls } from "./urls"; | ||
export { default as createContextHOC } from "./createContextHOC"; | ||
export { default as redirectOAuth2 } from "./redirectOAuth2"; | ||
export { default as getParamsFromHashAndClearIt } from "./getParamsFromHashAndClearIt"; | ||
export { default as getParamsFromHash } from "./getParamsFromHash"; | ||
export { default as clearHash } from "./clearHash"; | ||
export { default as roleIsAtLeast } from "./roleIsAtLeast"; | ||
export { default as resolveStoryURL } from "./resolveStoryURL"; | ||
export { default as createContextHOC } from "./createContextHOC"; | ||
export { default as detectCountScript } from "./detectCountScript"; | ||
export { default as potentiallyInjectAxe } from "./potentiallyInjectAxe"; | ||
export { default as getModerationLink, QUEUE_NAME } from "./getModerationLink"; | ||
export { default as getParamsFromHash } from "./getParamsFromHash"; | ||
export { default as getParamsFromHashAndClearIt } from "./getParamsFromHashAndClearIt"; | ||
export { default as getURLWithCommentID } from "./getURLWithCommentID"; | ||
export { default as getViewer } from "./getViewer"; | ||
export { default as getViewerSourceID } from "./getViewerSourceID"; | ||
export { default as injectConditionalPolyfills } from "./injectConditionalPolyfills"; | ||
export { default as onPymMessage } from "./onPymMessage"; | ||
export { default as polyfillCSSVars } from "./polyfillCSSVars"; | ||
export { default as polyfillIntlLocale } from "./polyfillIntlLocale"; | ||
export { default as getModerationLink, QUEUE_NAME } from "./getModerationLink"; | ||
export { default as potentiallyInjectAxe } from "./potentiallyInjectAxe"; | ||
export { default as redirectOAuth2 } from "./redirectOAuth2"; | ||
export { default as resolveStoryURL } from "./resolveStoryURL"; | ||
export { default as roleIsAtLeast } from "./roleIsAtLeast"; | ||
export { default as urls } from "./urls"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Child, MessageCallback } from "pym.js"; | ||
|
||
function onPymMessage( | ||
child: Child, | ||
messageType: string, | ||
callback: MessageCallback | ||
) { | ||
child.onMessage(messageType, callback); | ||
return () => { | ||
const index = child.messageHandlers[messageType].indexOf(callback); | ||
if (index > -1) { | ||
child.messageHandlers[messageType].splice(index, 1); | ||
if (child.messageHandlers[messageType].length === 0) { | ||
delete child.messageHandlers[messageType]; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
export default onPymMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.