1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

add tc-table-data as new utility class

This commit is contained in:
pmario 2024-10-30 16:47:38 +01:00
parent 815182cf7a
commit 9c252083d1

View File

@ -128,9 +128,11 @@ var processRow = function(prevColumns,options) {
// Move back to the closing `|` // Move back to the closing `|`
this.parser.pos--; this.parser.pos--;
cell.end = this.parser.pos; cell.end = this.parser.pos;
$tw.utils.addClassToParseTreeNode(cell,colCount%2 ? "oddCol" : "evenCol"); if(this.addData) {
$tw.utils.addAttributeToParseTreeNode(cell,"data-col",colCount); $tw.utils.addClassToParseTreeNode(cell,colCount%2 ? "oddCol" : "evenCol");
$tw.utils.addAttributeToParseTreeNode(cell,"data-addr",options.rowCount + "/" + colCount); $tw.utils.addAttributeToParseTreeNode(cell,"data-col",colCount);
$tw.utils.addAttributeToParseTreeNode(cell,"data-addr",options.rowCount + "/" + colCount);
}
} }
col++; col++;
cellRegExp.lastIndex = this.parser.pos; cellRegExp.lastIndex = this.parser.pos;
@ -155,6 +157,7 @@ exports.parse = function() {
var rowType = rowMatch[2]; var rowType = rowMatch[2];
// Check if it is a class assignment // Check if it is a class assignment
if(rowType === "k") { if(rowType === "k") {
this.addData = rowMatch[1].split(" ").indexOf("tc-table-data") !== -1;
$tw.utils.addClassToParseTreeNode(table,rowMatch[1]); $tw.utils.addClassToParseTreeNode(table,rowMatch[1]);
this.parser.pos = rowMatch.index + rowMatch[0].length; this.parser.pos = rowMatch.index + rowMatch[0].length;
} else { } else {
@ -181,7 +184,9 @@ exports.parse = function() {
// Create the row // Create the row
var theRow = {type: "element", tag: "tr", children: [], start: rowMatch.index}; var theRow = {type: "element", tag: "tr", children: [], start: rowMatch.index};
$tw.utils.addClassToParseTreeNode(theRow,rowCount%2 ? "oddRow" : "evenRow"); $tw.utils.addClassToParseTreeNode(theRow,rowCount%2 ? "oddRow" : "evenRow");
$tw.utils.addAttributeToParseTreeNode(theRow,"data-row",rowCount); if(this.addData) {
$tw.utils.addAttributeToParseTreeNode(theRow,"data-row",rowCount);
}
rowContainer.children.push(theRow); rowContainer.children.push(theRow);
// Process the row // Process the row
theRow.children = processRow.call(this,prevColumns,{rowCount: rowCount}); theRow.children = processRow.call(this,prevColumns,{rowCount: rowCount});