|
|
|
@ -163,15 +163,7 @@ function Editor(holder, input) {
|
|
|
|
|
return span[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
transform(text, element, id, editor) {
|
|
|
|
|
if (text === undefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let converted = text
|
|
|
|
|
|
|
|
|
|
if (converted === '{{table}}') {
|
|
|
|
|
function transformTable(editor, id, element) {
|
|
|
|
|
editor.treeForId(id).then(tree => {
|
|
|
|
|
let [header, rows] = tree[0].children
|
|
|
|
|
let rowData = _.map(rows.children, row => {
|
|
|
|
@ -184,7 +176,7 @@ function Editor(holder, input) {
|
|
|
|
|
el("td", [renderInline(row.text)]),
|
|
|
|
|
..._.map(header.children, col => {
|
|
|
|
|
let td = el("td")
|
|
|
|
|
this.transform(rowData[_.snakeCase(_.trim(col.text))], $(td), id, editor)
|
|
|
|
|
transform(rowData[_.snakeCase(_.trim(col.text))], $(td), id, editor)
|
|
|
|
|
return td
|
|
|
|
|
})
|
|
|
|
|
])
|
|
|
|
@ -211,6 +203,17 @@ function Editor(holder, input) {
|
|
|
|
|
])
|
|
|
|
|
}).then(table => element.html(table))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function transform(text, element, id, editor) {
|
|
|
|
|
if (text === undefined) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let converted = text
|
|
|
|
|
|
|
|
|
|
if (converted === '{{table}}') {
|
|
|
|
|
transformTable.call(this, editor, id, element);
|
|
|
|
|
return
|
|
|
|
|
} else if (converted.startsWith("```", 0) || converted.startsWith("$$", 0)) {
|
|
|
|
|
converted = MD.render(converted)
|
|
|
|
@ -236,6 +239,9 @@ function Editor(holder, input) {
|
|
|
|
|
|
|
|
|
|
element.html(converted)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
transform
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let inputData = input ? input : JSON.parse(holder.dataset.input)
|
|
|
|
|