From 8e64e21039d9e8a76704e85a5c80f23495fd61e4 Mon Sep 17 00:00:00 2001 From: Maurycy Zarzycki Date: Sat, 11 Jun 2022 09:57:08 +0200 Subject: [PATCH 1/2] Allow global keyboard shortcuts to work in framed editor (#6705) Co-authored-by: Maurycy Zarzycki --- core/modules/editor/engines/framed.js | 3 +++ core/modules/utils/dom/dom.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 957a9156e..610bda5dc 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -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"}, diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 330d184cc..b18f26e00 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -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) { @@ -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); }); }; From 35b0833e0cafc477e402309c006a163eb59a94ca Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 14 Jun 2022 08:33:47 +0100 Subject: [PATCH 2/2] Fix handling of {!!title} in a filter with no currentTiddler Fixes #6721 --- core/modules/wiki.js | 2 +- editions/test/tiddlers/tests/test-filters.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 87d78344e..c3f272348 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -50,7 +50,7 @@ exports.getTextReference = function(textRef,defaultText,currTiddlerTitle) { if(tr.field) { var tiddler = this.getTiddler(title); if(tr.field === "title") { // Special case so we can return the title of a non-existent tiddler - return title; + return title || defaultText; } else if(tiddler && $tw.utils.hop(tiddler.fields,tr.field)) { return tiddler.getFieldString(tr.field); } else { diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 18545221b..3103af17a 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -621,6 +621,8 @@ Tests the filtering mechanism. }); it("should handle indirect operands", function() { + expect(wiki.filterTiddlers("[{!!missing}]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[{!!title}]").join(",")).toBe(""); expect(wiki.filterTiddlers("[prefix{Tiddler8}] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); expect(wiki.filterTiddlers("[modifier{Tiddler8!!test-field}] +[sort[title]]").join(",")).toBe("TiddlerOne"); var fakeWidget = {wiki: wiki, getVariable: function() {return "Tiddler Three";}};