Skip to content

Commit 3462331

Browse files
committed
handle special case of two columns
1 parent 522cdb9 commit 3462331

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

resizer/plugin.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Resizer",
44
"description": "General-purpose resizer widget for TiddlyWiki5",
55
"author": "Simon Huber",
6-
"version": "0.4.5",
6+
"version": "0.4.6",
77
"core-version": ">=5.3.0",
88
"source": "https://github.com/BurningTreeC/resizer",
99
"plugin-type": "plugin",

resizer/ui/panels/panels.tid

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,23 @@ code-body: yes
308308

309309
\function tf.get.table.width() [<stateTiddlerPrefix>addsuffix[parent-size]get[text]addsuffix[px]]
310310

311-
\function tf.get.max.column.width()
311+
\function tf.get.max.column.width.more.than.two()
312312
[range<columns>!match<colIndex>!match<nextColIndex>]
313313
:reduce[addprefix<stateTiddlerPrefix>get[text]!prefix[Infinity]else<cellWidth>add<accumulator>]
314314
:and[subtract[100]]
315315
:map[abs<currentTiddler>subtract<tf.get.min.column.width.percentage>addsuffix[%]]
316316
\end
317317

318+
\function tf.get.max.column.width.two()
319+
[<tf.get.table.width>subtract[50]]
320+
:map[tf.convert.px.to.percentage<tf.get.table.width>,<currentTiddler>]
321+
\end
322+
323+
\function tf.get.max.column.width()
324+
[<columns>match[2]then<tf.get.max.column.width.two>]
325+
:else[<columns>!match[2]then<tf.get.max.column.width.more.than.two>]
326+
\end
327+
318328
\function tf.get.min.column.width.percentage() [tf.convert.px.to.percentage<tf.get.table.width>,[50px]addsuffix[%]]
319329
\function tf.get.max.column.width.percentage() [<colIndex>!match<columns>then<tf.get.table.width>!is[blank]then<tf.get.max.column.width>]
320330

@@ -543,6 +553,14 @@ code-body: yes
543553
\function tf.row.split.regexp.get.caption() [function[tf.row.split.regexp]suffix[|c]split[|]butfirst[]butlast[]first[]]
544554

545555

556+
\function tf.get.table.cell() [function[tf.row.split.regexp]!suffix[|h]!suffix[|c]!suffix[|f]!suffix[|k]nth<rowIndex>split[|]butfirst[]butlast[]nth<colIndex>]
557+
\function tf.get.table.cell.align()
558+
[<tableCell>regexp[^\s.*\s$]then[center]]
559+
:else[<tableCell>regexp<alignRightRegexp>then[right]]
560+
:else[<tableCell>regexp<alignLeftRegexp>then[left]]
561+
\end
562+
563+
546564
\procedure resizable-table(columns:"", rows:"", columnFilter:"", rowFilter:"", footerFilter:"", field:"text", editable:"no", tableHeight:"auto", class:"", headerClass:"", cellClass:"", stateTiddlerPrefix:"$:/state/resizable-table/", caption:"", wikitextTable:"")
547565
\whitespace trim
548566
<$let
@@ -568,7 +586,12 @@ code-body: yes
568586
<tr class={{{ tc-resizable-table-header [<headerClass>] +[join[ ]] }}}>
569587
<$list filter="[range<columns>]" variable="column" counter="colIndex">
570588
<$let nextColIndex={{{ [<colIndex>add[1]] }}} row="0">
571-
<th style.position="relative" style.min-width=<<tf.get.min.column.width.percentage>> style.max-width=<<tf.get.max.column.width.percentage>> style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}}>
589+
<th
590+
style.position="relative"
591+
style.min-width=<<tf.get.min.column.width.percentage>>
592+
style.max-width=<<tf.get.max.column.width.percentage>>
593+
style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}}
594+
>
572595
<div class="tc-resizable-table-cell" style.width="100%">
573596
<$transclude $variable="resizable-table-content" filter=<<columnFilter>> tableArea="header"/>
574597
</div>
@@ -601,9 +624,20 @@ code-body: yes
601624
nextColIndex={{{ [<colIndex>add[1]] }}}
602625
colspan={{{ [<wikitextTable>!is[blank]then<tf.get.colspan>] :else[[1]] }}}
603626
rowspan={{{ [<wikitextTable>!is[blank]then<tf.get.rowspan>] :else[[1]] }}}
627+
tableCell=<<tf.get.table.cell>>
628+
alignRightRegexp="^\s.*[^\s]$"
629+
alignLeftRegexp="^[^\s].*\s$"
604630
>
605631
<%if [<colspan>!match[0]then<rowspan>!match[0]] %>
606-
<td style.position="relative" style.min-width=<<tf.get.min.column.width.percentage>> style.max-width=<<tf.get.max.column.width.percentage>> style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}} colspan=<<colspan>> rowspan=<<rowspan>>>
632+
<td
633+
align=<<tf.get.table.cell.align>>
634+
style.position="relative"
635+
style.min-width=<<tf.get.min.column.width.percentage>>
636+
style.max-width=<<tf.get.max.column.width.percentage>>
637+
style.width={{{ [<stateTiddlerPrefix>addsuffix<colIndex>get[text]!prefix[Infinity]] :else[<cellWidth>] }}}
638+
colspan=<<colspan>>
639+
rowspan=<<rowspan>>
640+
>
607641
<div class="tc-resizable-table-cell" style.width="100%">
608642
<$transclude $variable="resizable-table-content" filter=<<rowFilter>> tableArea="rows"/>
609643
</div>

0 commit comments

Comments
 (0)