Skip to content

Commit

Permalink
Allow global keyboard shortcuts to work in framed editor (#6705)
Browse files Browse the repository at this point in the history
Co-authored-by: Maurycy Zarzycki <maurycy@evidentlycube.com>
  • Loading branch information
EvidentlyCube and EvidentlyCube committed Jun 11, 2022
1 parent bb47cc9 commit 8e64e21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/modules/editor/engines/framed.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ function FramedEngine(options) {
// Copy the styles from the dummy textarea
this.copyStyles();
// Add event listeners
$tw.utils.addEventListeners(this.iframeDoc, [
{name: "keydown",handlerObject: $tw.keyboardManager,handlerMethod: "handleKeydownEvent", capture: true},
]);
$tw.utils.addEventListeners(this.domNode,[
{name: "click",handlerObject: this,handlerMethod: "handleClickEvent"},
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},
Expand Down
3 changes: 2 additions & 1 deletion core/modules/utils/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Each entry in the events array is an object with these properties:
handlerFunction: optional event handler function
handlerObject: optional event handler object
handlerMethod: optionally specifies object handler method name (defaults to `handleEvent`)
capture: optionally specifies the listener should use capture (defaults to `false`)
*/
exports.addEventListeners = function(domNode,events) {
$tw.utils.each(events,function(eventInfo) {
Expand All @@ -213,7 +214,7 @@ exports.addEventListeners = function(domNode,events) {
handler = eventInfo.handlerObject;
}
}
domNode.addEventListener(eventInfo.name,handler,false);
domNode.addEventListener(eventInfo.name,handler,!!eventInfo.capture);
});
};

Expand Down

0 comments on commit 8e64e21

Please sign in to comment.