From 028dfe39b70dd0b8f901a8b2cb2a5d6c25755cb7 Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Fri, 10 Feb 2023 05:17:32 -0500 Subject: [PATCH] Fixed issue where $genesis didn't pass isBlock (#7230) * Fixed issue where $genesis didn't pass isBlock * Added $mode attribute for genesis * Added documentation for $mode attribute --- core/modules/widgets/genesis.js | 2 ++ .../tests/data/genesis-widget/Block.tid | 30 +++++++++++++++++++ .../tiddlers/widgets/GenesisWidget.tid | 1 + 3 files changed, 33 insertions(+) create mode 100644 editions/test/tiddlers/tests/data/genesis-widget/Block.tid diff --git a/core/modules/widgets/genesis.js b/core/modules/widgets/genesis.js index 6d30f3c36..c8403a3d4 100644 --- a/core/modules/widgets/genesis.js +++ b/core/modules/widgets/genesis.js @@ -46,6 +46,7 @@ GenesisWidget.prototype.execute = function() { this.genesisRemappable = this.getAttribute("$remappable","yes") === "yes"; this.genesisNames = this.getAttribute("$names",""); this.genesisValues = this.getAttribute("$values",""); + this.genesisIsBlock = this.getAttribute("$mode",this.parseTreeNode.isBlock && "block") === "block"; // Do not create a child widget if the $type attribute is missing or blank if(!this.genesisType) { this.makeChildWidgets(this.parseTreeNode.children); @@ -60,6 +61,7 @@ GenesisWidget.prototype.execute = function() { tag: nodeTag, attributes: {}, orderedAttributes: [], + isBlock: this.genesisIsBlock, children: this.parseTreeNode.children || [], isNotRemappable: !this.genesisRemappable }]; diff --git a/editions/test/tiddlers/tests/data/genesis-widget/Block.tid b/editions/test/tiddlers/tests/data/genesis-widget/Block.tid new file mode 100644 index 000000000..dfa5dacaf --- /dev/null +++ b/editions/test/tiddlers/tests/data/genesis-widget/Block.tid @@ -0,0 +1,30 @@ +title: Genesis/Block +description: genesis widget distinguishes between block and inline +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\whitespace trim +<$genesis $type="$reveal" type=nomatch> + +Block + + +<$genesis $type="$reveal" type=nomatch $mode=block> + +Block forced block + + +<$genesis $type="$reveal" type=nomatch $mode=inline> + +Block forced inline + + +<$genesis $type=$reveal type=nomatch>Inline +<$genesis $type=$reveal type=nomatch $mode=block>Inline forced block +<$genesis $type=$reveal type=nomatch $mode=inline>Inline forced inline ++ +title: ExpectedResult + +

Block

Block forced block

Block forced inline

Inline

Inline forced block
Inline forced inline

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid b/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid index 9292e39ba..83bb36e6d 100644 --- a/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/GenesisWidget.tid @@ -17,6 +17,7 @@ The content of the <<.wid genesis>> widget is used as the content of the dynamic |$type |The type of widget or element to create (an initial `$` indicates a widget, otherwise an HTML element will be created) | |$names |An optional filter evaluating to the names of a list of attributes to be applied to the widget | |$values |An optional filter evaluating to the values corresponding to the list of names specified in <<.attr $names>> | +|$mode |An optional override of the parsing mode. May be "inline" or "block" | |//{other attributes starting with $}// |Other attributes starting with a single dollar sign are reserved for future use | |//{attributes starting with $$}// |Attributes starting with two dollar signs are applied as attributes to the output widget, but with the attribute name changed to use a single dollar sign | |//{attributes not starting with $}// |Any other attributes that do not start with a dollar are applied as attributes to the output widget |