mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 14:23:53 +00:00
Use parse tree to render source text of filter
This commit is contained in:
parent
002c319518
commit
e741816a70
@ -235,7 +235,7 @@ exports.compileFilter = function(filterString,options) {
|
|||||||
this.filterCache = Object.create(null);
|
this.filterCache = Object.create(null);
|
||||||
this.filterCacheCount = 0;
|
this.filterCacheCount = 0;
|
||||||
}
|
}
|
||||||
if(this.filterCache[filterString] !== undefined && !wrappers) {
|
if(this.filterCache[filterString] !== undefined && !wrappers.prefix && !wrappers.operator) {
|
||||||
return this.filterCache[filterString];
|
return this.filterCache[filterString];
|
||||||
}
|
}
|
||||||
var filterParseTree;
|
var filterParseTree;
|
||||||
@ -290,6 +290,7 @@ exports.compileFilter = function(filterString,options) {
|
|||||||
}
|
}
|
||||||
// Invoke the appropriate filteroperator module
|
// Invoke the appropriate filteroperator module
|
||||||
results = operatorFunction(accumulator,{
|
results = operatorFunction(accumulator,{
|
||||||
|
parseTree: operator,
|
||||||
operator: operator.operator,
|
operator: operator.operator,
|
||||||
operatorName: operatorName,
|
operatorName: operatorName,
|
||||||
operand: operands.length > 0 ? operands[0] : undefined,
|
operand: operands.length > 0 ? operands[0] : undefined,
|
||||||
@ -391,7 +392,9 @@ exports.compileFilter = function(filterString,options) {
|
|||||||
this.filterCache = Object.create(null);
|
this.filterCache = Object.create(null);
|
||||||
this.filterCacheCount = 0;
|
this.filterCacheCount = 0;
|
||||||
}
|
}
|
||||||
this.filterCache[filterString] = fnMeasured;
|
if(!wrappers.prefix && !wrappers.operator) {
|
||||||
this.filterCacheCount++;
|
this.filterCache[filterString] = fnMeasured;
|
||||||
|
this.filterCacheCount++;
|
||||||
|
}
|
||||||
return fnMeasured;
|
return fnMeasured;
|
||||||
};
|
};
|
||||||
|
@ -43,6 +43,7 @@ exports.inspect = function(source,operator,options) {
|
|||||||
var details = {
|
var details = {
|
||||||
operatorName: innerOperator.operatorName,
|
operatorName: innerOperator.operatorName,
|
||||||
operands: innerOperator.operands,
|
operands: innerOperator.operands,
|
||||||
|
parseTree: innerOperator.parseTree,
|
||||||
prefix: innerOperator.prefix,
|
prefix: innerOperator.prefix,
|
||||||
suffix: innerOperator.suffix,
|
suffix: innerOperator.suffix,
|
||||||
suffixes: innerOperator.suffixes,
|
suffixes: innerOperator.suffixes,
|
||||||
|
@ -3,7 +3,7 @@ tags: $:/tags/Macro
|
|||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
|
|
||||||
\procedure inspect-list(jsonList,prompt,class:"tc-box")
|
\procedure inspect-list(jsonList,class:"tc-box")
|
||||||
<$let
|
<$let
|
||||||
transclusion={{{ [[list-]addsuffix<class>] }}}
|
transclusion={{{ [[list-]addsuffix<class>] }}}
|
||||||
>
|
>
|
||||||
@ -11,22 +11,20 @@ tags: $:/tags/Macro
|
|||||||
<$let
|
<$let
|
||||||
state=<<qualify "$:/temp/filter-inspector">>
|
state=<<qualify "$:/temp/filter-inspector">>
|
||||||
stateFolded={{{ [<state>addsuffix[folded]] }}}
|
stateFolded={{{ [<state>addsuffix[folded]] }}}
|
||||||
folded={{{ [<stateFolded>get[text]else[yes]match[yes]] }}}
|
folded={{{ [<stateFolded>get[text]else[no]match[yes]] }}}
|
||||||
stateMaxRows={{{ [<state>addsuffix[max-rows]] }}}
|
stateMaxRows={{{ [<state>addsuffix[max-rows]] }}}
|
||||||
maxRows={{{ [<stateMaxRows>get[text]!match[]else[50]] }}}
|
maxRows={{{ [<stateMaxRows>get[text]!match[]else[10]] }}}
|
||||||
>
|
>
|
||||||
<div class="tc-box-header">
|
<div class="tc-box-header">
|
||||||
<$button class="tc-btn-invisible" style.fill="inherit">
|
<$button class="tc-btn-invisible" style.fill="inherit">
|
||||||
<%if [<folded>match[yes]] %>
|
<%if [<folded>match[yes]] %>
|
||||||
<$action-setfield $tiddler=<<stateFolded>> text="no"/>
|
<$action-setfield $tiddler=<<stateFolded>> text="no"/>
|
||||||
{{$:/core/images/right-arrow}}
|
|
||||||
<%else%>
|
<%else%>
|
||||||
<$action-setfield $tiddler=<<stateFolded>> text="yes"/>
|
<$action-setfield $tiddler=<<stateFolded>> text="yes"/>
|
||||||
{{$:/core/images/down-arrow}}
|
|
||||||
<%endif%>
|
<%endif%>
|
||||||
|
<$text text={{{ [<jsonList>jsonindexes[]count[]] }}}/>
|
||||||
|
{{$:/core/images/right-arrow}}
|
||||||
</$button>
|
</$button>
|
||||||
<$text text=<<prompt>>/>
|
|
||||||
<span class="tc-pill"><$text text={{{ [<jsonList>jsonindexes[]count[]] }}}/></span>
|
|
||||||
</div>
|
</div>
|
||||||
<%if [<folded>!match[yes]] %>
|
<%if [<folded>!match[yes]] %>
|
||||||
<div class="tc-box-content">
|
<div class="tc-box-content">
|
||||||
@ -45,7 +43,7 @@ tags: $:/tags/Macro
|
|||||||
</$list>
|
</$list>
|
||||||
<%if [<jsonList>jsonindexes[]count[]compare:number:gt<maxRows>] %>
|
<%if [<jsonList>jsonindexes[]count[]compare:number:gt<maxRows>] %>
|
||||||
<$button class="tc-btn-invisible" style.fill="inherit">
|
<$button class="tc-btn-invisible" style.fill="inherit">
|
||||||
<$action-setfield $tiddler=<<stateMaxRows>> text={{{ [<maxRows>add[50]] }}}/>
|
<$action-setfield $tiddler=<<stateMaxRows>> text={{{ [<maxRows>add[10]] }}}/>
|
||||||
{{$:/core/images/chevron-down}}
|
{{$:/core/images/chevron-down}}
|
||||||
</$button>
|
</$button>
|
||||||
<%endif%>
|
<%endif%>
|
||||||
@ -60,7 +58,7 @@ tags: $:/tags/Macro
|
|||||||
\procedure inspect-operator(jsonOperator)
|
\procedure inspect-operator(jsonOperator)
|
||||||
<div class="tc-box tc-inspect-operator-box">
|
<div class="tc-box tc-inspect-operator-box">
|
||||||
<div class="tc-box-header">
|
<div class="tc-box-header">
|
||||||
<span class="tc-pill">
|
<span class="">
|
||||||
<$text text={{{ [<jsonOperator>jsonget[prefix]] }}} />
|
<$text text={{{ [<jsonOperator>jsonget[prefix]] }}} />
|
||||||
<$text text={{{ [<jsonOperator>jsonget[operatorName]] }}} />
|
<$text text={{{ [<jsonOperator>jsonget[operatorName]] }}} />
|
||||||
</span>
|
</span>
|
||||||
@ -72,14 +70,25 @@ tags: $:/tags/Macro
|
|||||||
</$list>
|
</$list>
|
||||||
<%endif%>
|
<%endif%>
|
||||||
<$list filter="[<jsonOperator>jsonindexes[operands]nsort[]]" variable="indexOperand">
|
<$list filter="[<jsonOperator>jsonindexes[operands]nsort[]]" variable="indexOperand">
|
||||||
<span class="tc-pill">
|
<div class="tc-split-pill">
|
||||||
<$text text={{{ [<jsonOperator>jsonget[operands],<indexOperand>] }}} />
|
<div class="tc-split-pill-top">
|
||||||
</span>
|
<%if [<jsonOperator>jsonget[parseTree],[operands],<indexOperand>,[variable]match[true]] %>
|
||||||
|
<$text text="<"/><$text text={{{ [<jsonOperator>jsonget[parseTree],[operands],<indexOperand>,[text]] }}}/><$text text=">"/>
|
||||||
|
<%elseif [<jsonOperator>jsonget[parseTree],[operands],<indexOperand>,[indirect]match[true]] %>
|
||||||
|
<$text text="{"/><$text text={{{ [<jsonOperator>jsonget[parseTree],[operands],<indexOperand>,[text]] }}}/><$text text="}"/>
|
||||||
|
<%else%>
|
||||||
|
<$text text="["/><$text text={{{ [<jsonOperator>jsonget[parseTree],[operands],<indexOperand>,[text]] }}}/><$text text="]"/>
|
||||||
|
<%endif%>
|
||||||
|
</div>
|
||||||
|
<div class="tc-split-pill-bottom">
|
||||||
|
<$text text={{{ [<jsonOperator>jsonget[operands],<indexOperand>] }}} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</$list>
|
</$list>
|
||||||
</div>
|
</div>
|
||||||
<div class="tc-box-content">
|
<div class="tc-box-content">
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<jsonOperator>jsonextract[input]] }}} prompt="In" class="tc-box tc-inspect-input-box"/>
|
<$transclude $variable="inspect-list" jsonList={{{ [<jsonOperator>jsonextract[input]] }}} class="tc-box tc-inspect-input-box"/>
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<jsonOperator>jsonextract[output]] }}} prompt="Out" class="tc-box tc-inspect-output-box"/>
|
<$transclude $variable="inspect-list" jsonList={{{ [<jsonOperator>jsonextract[output]] }}} class="tc-box tc-inspect-output-box"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\end inspect-operator
|
\end inspect-operator
|
||||||
@ -87,7 +96,7 @@ tags: $:/tags/Macro
|
|||||||
\procedure inspect-run(jsonRun)
|
\procedure inspect-run(jsonRun)
|
||||||
<div class="tc-box tc-inspect-run-box">
|
<div class="tc-box tc-inspect-run-box">
|
||||||
<div class="tc-box-header">
|
<div class="tc-box-header">
|
||||||
<span class="tc-pill">:<$text text={{{ [<jsonRun>jsonget[prefixName]] }}} /></span>
|
<span class="">:<$text text={{{ [<jsonRun>jsonget[prefixName]] }}} /></span>
|
||||||
<%if [<jsonRun>jsonindexes[suffixes]length[]compare:number:gt[0]] %>
|
<%if [<jsonRun>jsonindexes[suffixes]length[]compare:number:gt[0]] %>
|
||||||
<$list filter="[<jsonRun>jsonindexes[suffixes]nsort[]]" variable="indexSuffix">
|
<$list filter="[<jsonRun>jsonindexes[suffixes]nsort[]]" variable="indexSuffix">
|
||||||
<span class="tc-pill">
|
<span class="tc-pill">
|
||||||
@ -97,32 +106,34 @@ tags: $:/tags/Macro
|
|||||||
<%endif%>
|
<%endif%>
|
||||||
</div>
|
</div>
|
||||||
<div class="tc-box-content">
|
<div class="tc-box-content">
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<jsonRun>jsonextract[input]] }}} prompt="In" class="tc-box tc-inspect-input-box"/>
|
<$transclude $variable="inspect-list" jsonList={{{ [<jsonRun>jsonextract[input]] }}} class="tc-box tc-inspect-input-box"/>
|
||||||
<$list filter="[<jsonRun>jsonindexes[operators]nsort[]]" variable="indexOperator">
|
<$list filter="[<jsonRun>jsonindexes[operators]nsort[]]" variable="indexOperator">
|
||||||
<$let transclusion={{{ [[operator-]addsuffix<indexOperator>] }}}>
|
<$let transclusion={{{ [[operator-]addsuffix<indexOperator>] }}}>
|
||||||
<$transclude $variable="inspect-operator" jsonOperator={{{ [<jsonRun>jsonextract[operators],<indexOperator>] }}}/>
|
<$transclude $variable="inspect-operator" jsonOperator={{{ [<jsonRun>jsonextract[operators],<indexOperator>] }}}/>
|
||||||
</$let>
|
</$let>
|
||||||
</$list>
|
</$list>
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<jsonRun>jsonextract[output]] }}} prompt="Out" class="tc-box tc-inspect-output-box">
|
<$transclude $variable="inspect-list" jsonList={{{ [<jsonRun>jsonextract[output]] }}} class="tc-box tc-inspect-output-box">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\end inspect-run
|
\end inspect-run
|
||||||
|
|
||||||
\procedure inspect-filter(filter,inputFilter:"[all[tiddlers]]",orientation:"horizontal")
|
\procedure inspect-filter(filter,inputFilter:"[all[tiddlers]]",orientation:"horizontal")
|
||||||
<$let json={{{ [subfilter<inputFilter>inspect<filter>] }}}>
|
<$let json={{{ [subfilter<inputFilter>inspect<filter>] }}}>
|
||||||
<div class={{{ tc-box tc-inspect-filter-box [<orientation>match[horizontal]then[tc-inspect-filter-box-horizontal]] +[join[ ]] }}}>
|
<div class={{{ tc-inspect-filter-box [<orientation>match[horizontal]then[tc-inspect-filter-box-horizontal]] +[join[ ]] }}}>
|
||||||
<div class="tc-box-header">
|
<div class="tc-box">
|
||||||
Filter
|
<div class="tc-box-header">
|
||||||
<span class="tc-pill"><$text text={{{ [<json>jsonget[inputFilter]] }}}/></span>
|
Filter
|
||||||
</div>
|
<span class="tc-pill"><$text text={{{ [<json>jsonget[inputFilter]] }}}/></span>
|
||||||
<div class="tc-box-content">
|
</div>
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<json>jsonextract[input]] }}} prompt="In" class="tc-box tc-inspect-input-box"/>
|
<div class="tc-box-content">
|
||||||
<$list filter="[<json>jsonindexes[runs]nsort[]]" variable="indexRun">
|
<$transclude $variable="inspect-list" jsonList={{{ [<json>jsonextract[input]] }}} class="tc-box tc-inspect-input-box"/>
|
||||||
<$let transclusion={{{ [[run-]addsuffix<indexRun>] }}}>
|
<$list filter="[<json>jsonindexes[runs]nsort[]]" variable="indexRun">
|
||||||
<$transclude $variable="inspect-run" jsonRun={{{ [<json>jsonextract[runs],<indexRun>] }}}/>
|
<$let transclusion={{{ [[run-]addsuffix<indexRun>] }}}>
|
||||||
</$let>
|
<$transclude $variable="inspect-run" jsonRun={{{ [<json>jsonextract[runs],<indexRun>] }}}/>
|
||||||
</$list>
|
</$let>
|
||||||
<$transclude $variable="inspect-list" jsonList={{{ [<json>jsonextract[output]] }}} prompt="Out" class="tc-box tc-inspect-output-box"/>
|
</$list>
|
||||||
|
<$transclude $variable="inspect-list" jsonList={{{ [<json>jsonextract[output]] }}} class="tc-box tc-inspect-output-box"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</$let>
|
</$let>
|
||||||
|
@ -28,7 +28,10 @@ The JSON object contains the following properties:
|
|||||||
|
|
||||||
!! Examples
|
!! Examples
|
||||||
|
|
||||||
<$transclude $variable="inspect-filter" filter="[all[shadows+tiddlers]tag[$:/tags/MenuBar]!has[draft.of]] -[all[tiddlers+shadows]tag[$:/tags/TopLeftBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/topleftbar]] -[all[tiddlers+shadows]tag[$:/tags/TopRightBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/toprightbar]]" inputFilter="[all[tiddlers]]"/>
|
<$transclude $variable="inspect-filter" filter="1 2 3" inputFilter="[all[tiddlers]]"/>
|
||||||
|
|
||||||
<$transclude $variable="inspect-filter" filter="[all[shadows+tiddlers]tag[$:/tags/MenuBar]!has[draft.of]] -[all[tiddlers+shadows]tag[$:/tags/TopLeftBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/topleftbar]] -[all[tiddlers+shadows]tag[$:/tags/TopRightBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/toprightbar]]" inputFilter="[all[tiddlers]]" orientation="vertical"/>
|
<$transclude $variable="inspect-filter" filter="[title<currentTiddler>] [{$:/palette}length[]] [[marker]]" inputFilter="[all[tiddlers]]"/>
|
||||||
|
|
||||||
|
<$transclude $variable="inspect-filter" filter="[all[shadows+tiddlers]tag[$:/tags/MenuBar]!has[draft.of]] -[all[tiddlers+shadows]tag[$:/tags/TopLeftBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/topleftbar]]" inputFilter="[all[tiddlers]]"/>
|
||||||
|
|
||||||
|
<$transclude $variable="inspect-filter" filter="[all[shadows+tiddlers]tag[$:/tags/MenuBar]!has[draft.of]] -[all[tiddlers+shadows]tag[$:/tags/TopLeftBar]limit[1]then[]else[$:/plugins/tiddlywiki/menubar/items/topleftbar]]" inputFilter="[all[tiddlers]]" orientation="vertical"/>
|
||||||
|
@ -3510,9 +3510,17 @@ span.tc-translink > a:first-child {
|
|||||||
color: var(--box-background-color);
|
color: var(--box-background-color);
|
||||||
fill: var(--box-background-color);
|
fill: var(--box-background-color);
|
||||||
background-color: var(--box-foreground-color);
|
background-color: var(--box-foreground-color);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tc-box-header button {
|
||||||
|
color: var(--box-background-color);
|
||||||
|
background-color: var(--box-foreground-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tc-box-content {
|
.tc-box-content {
|
||||||
|
min-width: 4em;
|
||||||
padding: 0.25em;
|
padding: 0.25em;
|
||||||
border-bottom-left-radius: 3px;
|
border-bottom-left-radius: 3px;
|
||||||
border-bottom-right-radius: 3px;
|
border-bottom-right-radius: 3px;
|
||||||
@ -3549,6 +3557,24 @@ span.tc-translink > a:first-child {
|
|||||||
background-color: var(--box-background-color);
|
background-color: var(--box-background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tc-split-pill {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.125em 0.25em;
|
||||||
|
margin: 0 0.25em;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--box-foreground-color);
|
||||||
|
background-color: var(--box-background-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tc-split-pill-top {
|
||||||
|
border-bottom: 1px solid var(--box-foreground-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tc-split-pill-bottom {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Filter Inspection
|
** Filter Inspection
|
||||||
*/
|
*/
|
||||||
@ -3558,11 +3584,12 @@ span.tc-translink > a:first-child {
|
|||||||
--box-foreground-color: <<colour code-foreground>>;
|
--box-foreground-color: <<colour code-foreground>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal > .tc-box-content {
|
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal {
|
||||||
overflow: scroll
|
overflow: scroll;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal > .tc-box-content,
|
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal > .tc-box > .tc-box-content,
|
||||||
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal .tc-inspect-run-box > .tc-box-content,
|
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal .tc-inspect-run-box > .tc-box-content,
|
||||||
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal .tc-inspect-operator-box > .tc-box-content {
|
.tc-inspect-filter-box.tc-inspect-filter-box-horizontal .tc-inspect-operator-box > .tc-box-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -3581,12 +3608,12 @@ span.tc-translink > a:first-child {
|
|||||||
--box-foreground-color: #400;
|
--box-foreground-color: #400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tc-inspect-input-box {
|
.tc-box.tc-inspect-input-box {
|
||||||
--box-background-color: #fcf;
|
--box-background-color: #fcf;
|
||||||
--box-foreground-color: #404;
|
--box-foreground-color: #404;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tc-inspect-output-box {
|
.tc-box.tc-inspect-output-box {
|
||||||
--box-background-color: #cff;
|
--box-background-color: #cff;
|
||||||
--box-foreground-color: #044;
|
--box-foreground-color: #044;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user