Merge pull request #14759 from overleaf/mj-table-insert-float-specifier

[visual] Remove float specifier from inserted table

GitOrigin-RevId: b24c945117dfb52dd2982d6787985bf4554f5526
This commit is contained in:
Mathias Jakobsen 2023-09-11 10:58:48 +01:00 committed by Copybot
parent a080c7294b
commit 9d3461157c

View file

@ -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}`