From 3cf078faeb79454057ec8716e99f8ab8642d8cb6 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Sun, 24 Apr 2022 22:45:56 +0200 Subject: [PATCH 1/6] Write the right "color-scheme" meta tag to the iframe of the framed text-editor (#6656) * Write the right "color-scheme" meta tag to the iframe of the framed text-editor * Update framed.js --- core/modules/editor/engines/framed.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 441ccc243..ea6b7ab90 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -34,8 +34,10 @@ function FramedEngine(options) { this.parentNode.insertBefore(this.iframeNode,this.nextSibling); this.iframeDoc = this.iframeNode.contentWindow.document; // (Firefox requires us to put some empty content in the iframe) + var paletteTitle = this.widget.getTiddlerText("$:/palette"); + var colorScheme = paletteTitle.fields["color-scheme"] || "light"; this.iframeDoc.open(); - this.iframeDoc.write(""); + this.iframeDoc.write(""); this.iframeDoc.close(); // Style the iframe this.iframeNode.className = this.dummyTextArea.className; From e2ef5c933be53c9e729359aeec1138ce9b37d30e Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Sun, 24 Apr 2022 22:46:33 +0200 Subject: [PATCH 2/6] Update CupertinoDark.tid (#6655) --- core/palettes/CupertinoDark.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/palettes/CupertinoDark.tid b/core/palettes/CupertinoDark.tid index 956602a0f..7df078296 100644 --- a/core/palettes/CupertinoDark.tid +++ b/core/palettes/CupertinoDark.tid @@ -87,7 +87,7 @@ tiddler-border: transparent tiddler-controls-foreground-hover: <> tiddler-controls-foreground-selected: <> tiddler-controls-foreground: #48484A -tiddler-editor-background: transparent +tiddler-editor-background: <> tiddler-editor-border-image: tiddler-editor-border: rgba(255, 255, 255, 0.08) tiddler-editor-fields-even: rgba(255, 255, 255, 0.1) From 1410488a2389f5880cc47ddbdb559ec7418e811c Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 25 Apr 2022 09:45:42 +0200 Subject: [PATCH 3/6] Fix my error in framed.js (#6658) * Fix my error in framed.js * ouch --- core/modules/editor/engines/framed.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index ea6b7ab90..6cc50896f 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -34,8 +34,8 @@ function FramedEngine(options) { this.parentNode.insertBefore(this.iframeNode,this.nextSibling); this.iframeDoc = this.iframeNode.contentWindow.document; // (Firefox requires us to put some empty content in the iframe) - var paletteTitle = this.widget.getTiddlerText("$:/palette"); - var colorScheme = paletteTitle.fields["color-scheme"] || "light"; + var paletteTitle = this.widget.wiki.getTiddlerText("$:/palette"); + var colorScheme = this.widget.wiki.getTiddler(paletteTitle).fields["color-scheme"] || "light"; this.iframeDoc.open(); this.iframeDoc.write(""); this.iframeDoc.close(); From 9bcbb9131ecb542bc93cc44381d701245da58016 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Mon, 25 Apr 2022 10:56:34 +0200 Subject: [PATCH 4/6] Add :root { color-sheme: ...; } to vanilla base (#6659) --- themes/tiddlywiki/vanilla/base.tid | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 145c5f2aa..774e3ee69 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -334,6 +334,10 @@ table tfoot tr td { height: 600px; } +:root { + color-scheme: {{{ [{$:/palette}get[color-scheme]] ~light }}}; +} + /* ** Links */ From bdd99edfe8c5d791309b1eac536f434b14b07bd0 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 26 Apr 2022 14:02:08 +0100 Subject: [PATCH 5/6] Tests: Improve transclusion recursion test Previously we were testing a tiddler transcluding itself, but it's clearer to make it an indirect recursion --- editions/test/tiddlers/tests/test-widget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editions/test/tiddlers/tests/test-widget.js b/editions/test/tiddlers/tests/test-widget.js index ac90c39c3..19848e761 100755 --- a/editions/test/tiddlers/tests/test-widget.js +++ b/editions/test/tiddlers/tests/test-widget.js @@ -143,7 +143,8 @@ describe("Widget module", function() { var wiki = new $tw.Wiki(); // Add a tiddler wiki.addTiddlers([ - {title: "TiddlerOne", text: "<$transclude tiddler='TiddlerOne'/>\n"} + {title: "TiddlerOne", text: "<$transclude tiddler='TiddlerTwo'/>\n"}, + {title: "TiddlerTwo", text: "<$transclude tiddler='TiddlerOne'/>"} ]); // Test parse tree var parseTreeNode = {type: "widget", children: [ From 0bffae21088aafc0cdebafe6a5de7907d7c52a3a Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 26 Apr 2022 14:02:31 +0100 Subject: [PATCH 6/6] Add utility method for getting ordered attributes --- core/modules/utils/parsetree.js | 14 ++++++++++++++ core/modules/widgets/let.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 52dc203e8..e056b0fdd 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -21,6 +21,20 @@ exports.addAttributeToParseTreeNode = function(node,name,value) { } }; +exports.getOrderedAttributesFromParseTreeNode = function(node) { + if(node.orderedAttributes) { + return node.orderedAttributes; + } else { + var attributes = []; + $tw.utils.each(node.attributes,function(attribute) { + attributes.push(attribute); + }); + return attributes.sort(function(a,b) { + return a.name < b.name ? -1 : (a.name > b.name ? 1 : 0); + }); + } +}; + exports.getAttributeValueFromParseTreeNode = function(node,name,defaultValue) { if(node.attributes && node.attributes[name] && node.attributes[name].value !== undefined) { return node.attributes[name].value; diff --git a/core/modules/widgets/let.js b/core/modules/widgets/let.js index b3ed89828..5c4b3aa90 100644 --- a/core/modules/widgets/let.js +++ b/core/modules/widgets/let.js @@ -48,7 +48,7 @@ LetWidget.prototype.computeAttributes = function() { var changedAttributes = {}, self = this; this.currentValueFor = Object.create(null); - $tw.utils.each(this.parseTreeNode.orderedAttributes,function(attribute,index) { + $tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attribute) { var value = self.computeAttribute(attribute), name = attribute.name; if(name.charAt(0) !== "$") {