mirror of https://github.com/laurent22/joplin.git
parent
d4157e14fe
commit
144ec1eea2
|
@ -1,10 +1,10 @@
|
||||||
<body>
|
<body>
|
||||||
<table border="5px" bordercolor="#8707B0">
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Left side of the main table</td>
|
<td>Left side of the main table</td>
|
||||||
<td>
|
<td>
|
||||||
<table border="5px" bordercolor="#F35557">
|
<table>
|
||||||
<h4 align="center">Nested Table</h4>
|
<b>Nested Table</b>
|
||||||
<tr>
|
<tr>
|
||||||
<td>nested table C1</td>
|
<td>nested table C1</td>
|
||||||
<td>nested table C2</td>
|
<td>nested table C2</td>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<table border="5px" bordercolor="#8707B0"><tbody><tr><td>Left side of the main table</td><td><h4 align="center">Nested Table</h4><table border="5px" bordercolor="#F35557"><tbody><tr><td>nested table C1</td><td>nested table C2</td></tr><tr><td>nested table</td><td>nested table</td></tr></tbody></table></td></tr></tbody></table>
|
<table><tbody><tr><td>Left side of the main table</td><td><b>Nested Table</b><table><tbody><tr><td>nested table C1</td><td>nested table C2</td></tr><tr><td>nested table</td><td>nested table</td></tr></tbody></table></td></tr></tbody></table>
|
|
@ -74,8 +74,8 @@ rules.tableRow = {
|
||||||
rules.table = {
|
rules.table = {
|
||||||
// Only convert tables that can result in valid Markdown
|
// Only convert tables that can result in valid Markdown
|
||||||
// Other tables are kept as HTML using `keep` (see below).
|
// Other tables are kept as HTML using `keep` (see below).
|
||||||
filter: function (node) {
|
filter: function (node, options) {
|
||||||
return node.nodeName === 'TABLE' && !tableShouldBeHtml(node);
|
return node.nodeName === 'TABLE' && !tableShouldBeHtml(node, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
replacement: function (content, node) {
|
replacement: function (content, node) {
|
||||||
|
@ -174,7 +174,7 @@ const nodeContains = (node, types) => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tableShouldBeHtml = (tableNode, preserveNestedTables) => {
|
const tableShouldBeHtml = (tableNode, options) => {
|
||||||
const possibleTags = [
|
const possibleTags = [
|
||||||
'UL',
|
'UL',
|
||||||
'OL',
|
'OL',
|
||||||
|
@ -193,7 +193,7 @@ const tableShouldBeHtml = (tableNode, preserveNestedTables) => {
|
||||||
// that's made of HTML tables. In that case we have this logic of removing the
|
// that's made of HTML tables. In that case we have this logic of removing the
|
||||||
// outer table and keeping only the inner ones. For the Rich Text editor
|
// outer table and keeping only the inner ones. For the Rich Text editor
|
||||||
// however we always want to keep nested tables.
|
// however we always want to keep nested tables.
|
||||||
if (preserveNestedTables) possibleTags.push('TABLE');
|
if (options.preserveNestedTables) possibleTags.push('TABLE');
|
||||||
|
|
||||||
return nodeContains(tableNode, 'code') ||
|
return nodeContains(tableNode, 'code') ||
|
||||||
nodeContains(tableNode, possibleTags);
|
nodeContains(tableNode, possibleTags);
|
||||||
|
@ -249,7 +249,7 @@ export default function tables (turndownService) {
|
||||||
isCodeBlock_ = turndownService.isCodeBlock;
|
isCodeBlock_ = turndownService.isCodeBlock;
|
||||||
|
|
||||||
turndownService.keep(function (node) {
|
turndownService.keep(function (node) {
|
||||||
if (node.nodeName === 'TABLE' && tableShouldBeHtml(node, turndownService.options.preserveNestedTables)) return true;
|
if (node.nodeName === 'TABLE' && tableShouldBeHtml(node, turndownService.options)) return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
for (var key in rules) turndownService.addRule(key, rules[key])
|
for (var key in rules) turndownService.addRule(key, rules[key])
|
||||||
|
|
Loading…
Reference in New Issue