Vanessa 2023-09-30 14:40:45 +08:00
parent f8b272d596
commit 82bed847e6

View file

@ -21,10 +21,10 @@ const getSlashItem = (value: string, icon: string, text: string, focus = "false"
} else {
iconHTML = icon;
}
return `<div class="keyboard__slash-item" data-focus="${focus}" data-value="${encodeURIComponent(value)}">
return `<button class="keyboard__slash-item" data-focus="${focus}" data-value="${encodeURIComponent(value)}">
${iconHTML}
<span class="keyboard__slash-text">${text}</span>
</div>`;
</button>`;
};
export const renderTextMenu = (protyle: IProtyle, toolbarElement: Element) => {
@ -500,9 +500,9 @@ export const initKeyboardToolbar = () => {
</div>
<div class="keyboard__util"></div>`;
toolbarElement.addEventListener("click", (event) => {
const protyle = getCurrentEditor()?.protyle;
const target = event.target as HTMLElement;
const slashBtnElement = hasClosestByClassName(event.target as HTMLElement, "keyboard__slash-item");
const protyle = getCurrentEditor()?.protyle;
if (slashBtnElement && !slashBtnElement.getAttribute("data-type")) {
const dataValue = decodeURIComponent(slashBtnElement.getAttribute("data-value"));
protyle.hint.fill(dataValue, protyle, false); // 点击后 range 会改变