diff --git a/services/web/frontend/js/features/source-editor/extensions/toolbar/commands.ts b/services/web/frontend/js/features/source-editor/extensions/toolbar/commands.ts index 694adc2422..b6db570f8a 100644 --- a/services/web/frontend/js/features/source-editor/extensions/toolbar/commands.ts +++ b/services/web/frontend/js/features/source-editor/extensions/toolbar/commands.ts @@ -70,13 +70,18 @@ export const insertFigure: Command = view => { export const insertTable = (view: EditorView, sizeX: number, sizeY: number) => { const { state, dispatch } = view + const visual = isVisual(view) + const placeholder = visual ? '' : '#{}' + const placeholderAtStart = visual ? '#{}' : '' const { pos, suffix } = ensureEmptyLine(state, state.selection.main) - const template = `\n\\begin{table}[#{}] + const template = `${placeholderAtStart}\n\\begin{table} \t\\centering -\\begin{tabular}{${'c'.repeat(sizeX)}} -${('\t\t' + '#{} & #{}'.repeat(sizeX - 1) + '\\\\\n').repeat( - sizeY -)}\\end{tabular} +\t\\begin{tabular}{${'c'.repeat(sizeX)}} +${( + '\t\t' + + `${placeholder} & ${placeholder}`.repeat(sizeX - 1) + + '\\\\\n' +).repeat(sizeY)}\t\\end{tabular} \t\\caption{Caption} \t\\label{tab:my_label} \\end{table}${suffix}`