diff --git a/app/javascript/template_builder/dynamic_editor.js b/app/javascript/template_builder/dynamic_editor.js index 16ebc367e..cb1affe26 100644 --- a/app/javascript/template_builder/dynamic_editor.js +++ b/app/javascript/template_builder/dynamic_editor.js @@ -1018,8 +1018,17 @@ const Formatting = Extension.create({ } if (dispatch) { - selectedTextblocks(state).forEach(({ node, pos, numbering }) => { - tr.setNodeMarkup(pos, null, { ...node.attrs, htmlAttrs: withNumberingClass(node.attrs.htmlAttrs, `doc-list-${listStyle}-${numbering?.level || 0}`) }) + const blocks = selectedTextblocks(state) + const $before = state.doc.resolve(blocks[0].pos) + const $after = state.doc.resolve(blocks.at(-1).pos + blocks.at(-1).node.nodeSize) + const adjacent = [[$before.nodeBefore, $before.pos - $before.nodeBefore?.nodeSize], [$after.nodeAfter, $after.pos]] + .map(([node, pos]) => node && findNumbering(node) && numberingListStyle(view, pos) === listStyle && findNumbering(node).prefix) + .find(Boolean) + + blocks.forEach(({ node, pos, numbering }) => { + const className = numbering ? `doc-list-${listStyle}-${numbering.level}` : `${adjacent || `doc-list-${listStyle}`}-0` + + tr.setNodeMarkup(pos, null, { ...node.attrs, htmlAttrs: withNumberingClass(node.attrs.htmlAttrs, className) }) }) } diff --git a/app/javascript/template_builder/dynamic_menu.vue b/app/javascript/template_builder/dynamic_menu.vue index 7477affcc..dccc33ce8 100644 --- a/app/javascript/template_builder/dynamic_menu.vue +++ b/app/javascript/template_builder/dynamic_menu.vue @@ -125,7 +125,7 @@ :key="value" class="block w-full text-left px-2 py-1 rounded-md hover:bg-neutral-100" :class="{ 'bg-neutral-200': value === lineHeight }" - @click="setBlockStyle('line-height', value)" + @click="setBlockStyle('line-height', `calc(${value} * 1.15)`)" > {{ value }} @@ -665,7 +665,7 @@ export default { const align = blockStyle.textAlign.replace('start', 'left').replace('end', 'right') this.textAlign = this.alignIcons[align] ? align : 'left' - this.lineHeight = String(Math.round(parseFloat(blockStyle.lineHeight) / parseFloat(blockStyle.fontSize) * 100) / 100) + this.lineHeight = String(Math.round(parseFloat(blockStyle.lineHeight) / parseFloat(blockStyle.fontSize) / 1.15 * 100) / 100) } this.listStyle = findNumbering($from.parent) ? numberingListStyle(view, $from.before()) : null