From 70ee30fdf3c02668bd2bbddb0c5465677579b46e Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sun, 14 May 2023 21:25:35 +0100 Subject: [PATCH] Add fillignore attribute to transclude widget to fix visible transclusion (#7451) * slotignore attribute for transclude widget to fix visible transclusion Fixes #7449 * Remove unneeded depth attribute No longer needed * Replace "slotignore" by "fillignore" --- core/modules/widgets/slot.js | 2 +- core/modules/widgets/transclude.js | 7 +++++++ core/ui/Components/VisibleTransclude.tid | 8 ++++---- editions/tw5.com/tiddlers/widgets/SlotWidget.tid | 2 +- editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/modules/widgets/slot.js b/core/modules/widgets/slot.js index 6fc402ac2..eeaaedefe 100644 --- a/core/modules/widgets/slot.js +++ b/core/modules/widgets/slot.js @@ -48,7 +48,7 @@ SlotWidget.prototype.execute = function() { var pointer = this.parentWidget, depth = this.slotDepth; while(pointer) { - if(pointer instanceof TranscludeWidget) { + if(pointer instanceof TranscludeWidget && pointer.hasVisibleSlots()) { depth--; if(depth <= 0) { break; diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 90b640c42..f50e32c64 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -384,6 +384,13 @@ TranscludeWidget.prototype.getTransclusionSlotFill = function(name,defaultParseT } }; +/* +Return whether this transclusion should be visible to the slot widget +*/ +TranscludeWidget.prototype.hasVisibleSlots = function() { + return this.getAttribute("$fillignore","no") === "no"; +} + /* Compose a string comprising the title, field and/or index to identify this transclusion for recursion detection */ diff --git a/core/ui/Components/VisibleTransclude.tid b/core/ui/Components/VisibleTransclude.tid index cbc981abe..27fdff998 100644 --- a/core/ui/Components/VisibleTransclude.tid +++ b/core/ui/Components/VisibleTransclude.tid @@ -30,15 +30,15 @@ Block transclusions are shown in red, and inline transclusions are shown in gree <$list filter="[<@params>jsonindexes[]] :filter[prefix[$]] +[limit[1]]" variable="ignore" emptyMessage=""" - <$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget]" recursionMarker="no" mode=<>> + <$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget]" recursionMarker="no" mode=<> $$fillignore="yes"> - <$slot $name="ts-raw" $depth="2"/> + <$slot $name="ts-raw"/> """> - <$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget]" $$recursionMarker="no" $$mode=<>> + <$genesis $type="$transclude" $remappable="no" $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget]" $$recursionMarker="no" $$mode=<> $$fillignore="yes"> - <$slot $name="ts-raw" $depth="2"/> + <$slot $name="ts-raw"/> diff --git a/editions/tw5.com/tiddlers/widgets/SlotWidget.tid b/editions/tw5.com/tiddlers/widgets/SlotWidget.tid index aca173512..08f277ea8 100644 --- a/editions/tw5.com/tiddlers/widgets/SlotWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/SlotWidget.tid @@ -17,7 +17,7 @@ The content of the <<.wlink SlotWidget>> widget is used as a fallback for the sl |!Attribute |!Description | |$name |The name of the slot being defined | -|$depth |Optional number indicating how deep the <<.wlink SlotWidget>> widget is compared to the matching <<.wlink FillWidget>> widget as measured by the number of nested transclude widgets (defaults to 1) | +|$depth |Optional number indicating how deep the <<.wlink SlotWidget>> widget is compared to the matching <<.wlink FillWidget>> widget as measured by the number of nested transclude widgets (defaults to 1). Transclude widgets whose <<.attr $fillignore>> attribute is set to ''yes'' are ignored, and do not affect the depth count | ! Examples diff --git a/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid b/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid index 799e17c1b..a44c91dd6 100644 --- a/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TranscludeWidget.tid @@ -51,6 +51,7 @@ Modern mode is recommended for use in new applications. |$type |– |Optional ContentType used when transcluding variables, indexes or fields other than the ''text'' field| |$output |- |ContentType for the output rendering (defaults to `text/html`, can also be `text/plain` or `text/raw`) | |$recursionMarker |recursionMarker |Set to ''no'' to prevent creation of [[Legacy Transclusion Recursion Marker]] (defaults to ''yes'') | +|$fillignore |- |Set to ''yes'' to make this transclusion invisible to the <<.attr $depth>> attribute of the <<.wlink SlotWidget>> widget (defaults to ''no'') | |//{attributes not starting with $}// |– |Any other attributes that do not start with a dollar are used as parameters to the transclusion | |//{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 used as parameters to the transclusion, but with the name changed to use a single dollar sign |