diff --git a/src/ts/ir/input.ts b/src/ts/ir/input.ts index 578ac9232..71ce12e46 100644 --- a/src/ts/ir/input.ts +++ b/src/ts/ir/input.ts @@ -40,7 +40,9 @@ export const input = (vditor: IVditor, range: Range) => { } } - if (startSpace || endSpace) { + if ((startSpace || endSpace) + // insert table + && !blockElement.querySelector("wbr")) { blockElement.classList.add("vditor-ir__node--expand"); return; } diff --git a/src/ts/ir/process.ts b/src/ts/ir/process.ts index 56421ba4d..601379c37 100644 --- a/src/ts/ir/process.ts +++ b/src/ts/ir/process.ts @@ -185,6 +185,9 @@ export const processToolbar = (vditor: IVditor, actionBtn: Element, prefix: stri } else { html = `${prefix}${range.toString()}${prefix}`; } + if (commandName === "table" || commandName === "code") { + html = "\n" + html + "\n"; + } document.execCommand("insertHTML", false, html); } }