mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
e22573b4eb
commit
f53c2fdebd
3 changed files with 19 additions and 5 deletions
|
|
@ -89,7 +89,7 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
|
||||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconCode"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.code}</span><span class="b3-menu__accelerator">\`\`\`Enter</span></div>`,
|
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconCode"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.code}</span><span class="b3-menu__accelerator">\`\`\`Enter</span></div>`,
|
||||||
}, {
|
}, {
|
||||||
filter: ["表格", "biaoge", "bg", "table"],
|
filter: ["表格", "biaoge", "bg", "table"],
|
||||||
value: `| col1${Lute.Caret} | col2 | col3 |\n| --- | --- | --- |\n| | | |\n| | | |`,
|
value: `| ${Lute.Caret} | | |\n| --- | --- | --- |\n| | | |\n| | | |`,
|
||||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconTable"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.table}</span><span class="b3-menu__accelerator">${updateHotkeyTip((window.siyuan.config.keymap.editor.insert.table.custom))}</span></div>`,
|
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconTable"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.table}</span><span class="b3-menu__accelerator">${updateHotkeyTip((window.siyuan.config.keymap.editor.insert.table.custom))}</span></div>`,
|
||||||
}, {
|
}, {
|
||||||
filter: ["分割线", "fengexian", "fgx", "divider"],
|
filter: ["分割线", "fengexian", "fgx", "divider"],
|
||||||
|
|
|
||||||
|
|
@ -590,6 +590,13 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
}
|
}
|
||||||
nodeElement.outerHTML = newHTML;
|
nodeElement.outerHTML = newHTML;
|
||||||
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
|
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);
|
updateTransaction(protyle, id, newHTML, html);
|
||||||
} else {
|
} else {
|
||||||
let newHTML = protyle.lute.SpinBlockDOM(textContent);
|
let newHTML = protyle.lute.SpinBlockDOM(textContent);
|
||||||
|
|
@ -597,13 +604,21 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
newHTML = `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeHTMLBlock" class="render-node" data-subtype="block"><div class="protyle-icons"><span class="protyle-icon protyle-icon--first protyle-action__edit"><svg><use xlink:href="#iconEdit"></use></svg></span><span class="protyle-icon protyle-action__menu protyle-icon--last"><svg><use xlink:href="#iconMore"></use></svg></span></div><div><protyle-html data-content=""></protyle-html><span style="position: absolute">${Constants.ZWSP}</span></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
newHTML = `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeHTMLBlock" class="render-node" data-subtype="block"><div class="protyle-icons"><span class="protyle-icon protyle-icon--first protyle-action__edit"><svg><use xlink:href="#iconEdit"></use></svg></span><span class="protyle-icon protyle-action__menu protyle-icon--last"><svg><use xlink:href="#iconMore"></use></svg></span></div><div><protyle-html data-content=""></protyle-html><span style="position: absolute">${Constants.ZWSP}</span></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
||||||
}
|
}
|
||||||
nodeElement.insertAdjacentHTML("afterend", newHTML);
|
nodeElement.insertAdjacentHTML("afterend", newHTML);
|
||||||
|
const oldHTML = nodeElement.outerHTML;
|
||||||
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
|
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, [{
|
transaction(protyle, [{
|
||||||
data: nodeElement.outerHTML,
|
data: oldHTML,
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
}, {
|
}, {
|
||||||
data: newHTML,
|
data: nodeElement.outerHTML,
|
||||||
id: newId,
|
id: newId,
|
||||||
previousID: id,
|
previousID: id,
|
||||||
action: "insert"
|
action: "insert"
|
||||||
|
|
@ -615,7 +630,6 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
}]);
|
}]);
|
||||||
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
|
|
||||||
}
|
}
|
||||||
if (value === "<div>" || value === "$$" || (value.indexOf("```") > -1 && value.length > 3)) {
|
if (value === "<div>" || value === "$$" || (value.indexOf("```") > -1 && value.length > 3)) {
|
||||||
protyle.toolbar.showRender(protyle, nodeElement);
|
protyle.toolbar.showRender(protyle, nodeElement);
|
||||||
|
|
|
||||||
|
|
@ -1330,7 +1330,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.insert.table.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.insert.table.custom, event)) {
|
||||||
protyle.hint.splitChar = "/";
|
protyle.hint.splitChar = "/";
|
||||||
protyle.hint.lastIndex = -1;
|
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.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue