diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 5c4084e48..5d3b963c5 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -89,7 +89,7 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
html: `
${window.siyuan.languages.code}
`,
}, {
filter: ["表格", "biaoge", "bg", "table"],
- value: `| col1${Lute.Caret} | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |`,
+ value: `| ${Lute.Caret} | | |\n| --- | --- | --- |\n| | | |\n| | | |`,
html: `${window.siyuan.languages.table}
`,
}, {
filter: ["分割线", "fengexian", "fgx", "divider"],
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 5a4531674..7b395a2cd 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -590,6 +590,13 @@ ${unicode2Emoji(emoji.unicode, true)}`;
}
nodeElement.outerHTML = newHTML;
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
+ // https://github.com/siyuan-note/siyuan/issues/6864
+ if (nodeElement.getAttribute("data-type") === "NodeTable") {
+ nodeElement.querySelectorAll("colgroup col").forEach((item: HTMLElement) => {
+ item.style.width = "80px";
+ });
+ newHTML = nodeElement.outerHTML;
+ }
updateTransaction(protyle, id, newHTML, html);
} else {
let newHTML = protyle.lute.SpinBlockDOM(textContent);
@@ -597,13 +604,21 @@ ${unicode2Emoji(emoji.unicode, true)}`;
newHTML = ``;
}
nodeElement.insertAdjacentHTML("afterend", newHTML);
+ const oldHTML = nodeElement.outerHTML;
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
+ nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
+ // https://github.com/siyuan-note/siyuan/issues/6864
+ if (nodeElement.getAttribute("data-type") === "NodeTable") {
+ nodeElement.querySelectorAll("colgroup col").forEach((item: HTMLElement) => {
+ item.style.width = "80px";
+ });
+ }
transaction(protyle, [{
- data: nodeElement.outerHTML,
+ data: oldHTML,
id,
action: "update"
}, {
- data: newHTML,
+ data: nodeElement.outerHTML,
id: newId,
previousID: id,
action: "insert"
@@ -615,7 +630,6 @@ ${unicode2Emoji(emoji.unicode, true)}`;
id,
action: "update"
}]);
- nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
}
if (value === "" || value === "$$" || (value.indexOf("```") > -1 && value.length > 3)) {
protyle.toolbar.showRender(protyle, nodeElement);
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 6c4ddf437..ad3b43001 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1330,7 +1330,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey(window.siyuan.config.keymap.editor.insert.table.custom, event)) {
protyle.hint.splitChar = "/";
protyle.hint.lastIndex = -1;
- protyle.hint.fill(`| col1${Lute.Caret} | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |`, protyle);
+ protyle.hint.fill(`| ${Lute.Caret} | | |\n| --- | --- | --- |\n| | | |\n| | | |`, protyle);
event.preventDefault();
event.stopPropagation();
return;