This commit is contained in:
parent
3e57c2155d
commit
0370d203c4
2 changed files with 24 additions and 19 deletions
|
@ -505,13 +505,33 @@ export const initKeyboardToolbar = () => {
|
|||
return;
|
||||
}
|
||||
const buttonElement = hasClosestByMatchTag(target, "BUTTON");
|
||||
if (!buttonElement || buttonElement.getAttribute("disabled") || getSelection().rangeCount === 0) {
|
||||
if (!buttonElement || buttonElement.getAttribute("disabled")) {
|
||||
return;
|
||||
}
|
||||
const type = buttonElement.getAttribute("data-type");
|
||||
// appearance
|
||||
if (["clear", "style2", "style4", "color", "backgroundColor", "fontSize", "style1"].includes(type)) {
|
||||
const nodeElements = getFontNodeElements(protyle);
|
||||
if (type === "style1") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.backgroundColor + Constants.ZWSP + buttonElement.firstElementChild.style.color);
|
||||
} else if (type === "fontSize") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.textContent.trim());
|
||||
} else if (type === "backgroundColor") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.backgroundColor);
|
||||
} else if (type === "color") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.color);
|
||||
} else {
|
||||
fontEvent(protyle, nodeElements, type);
|
||||
}
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (getSelection().rangeCount === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const range = getSelection().getRangeAt(0);
|
||||
const type = buttonElement.getAttribute("data-type");
|
||||
if (type === "done") {
|
||||
if (toolbarElement.clientHeight > 100) {
|
||||
hideKeyboardToolbarUtil();
|
||||
|
@ -623,20 +643,5 @@ export const initKeyboardToolbar = () => {
|
|||
focusByRange(range);
|
||||
return;
|
||||
}
|
||||
// appearance
|
||||
if (["clear", "style2", "style4", "color", "backgroundColor", "fontSize", "style1"].includes(type)) {
|
||||
const nodeElements = getFontNodeElements(protyle);
|
||||
if (type === "style1") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.backgroundColor + Constants.ZWSP + buttonElement.firstElementChild.style.color);
|
||||
} else if (type === "fontSize") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.textContent.trim());
|
||||
} else if (type === "backgroundColor") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.backgroundColor);
|
||||
} else if (type === "color") {
|
||||
fontEvent(protyle, nodeElements, type, buttonElement.firstElementChild.style.color);
|
||||
} else {
|
||||
fontEvent(protyle, nodeElements, type);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -433,10 +433,10 @@ export class Gutter {
|
|||
dynamicElements[1].classList.remove("fn__none");
|
||||
toolbarElement.querySelector('.keyboard__action[data-type="text"]').classList.add("protyle-toolbar__item--current");
|
||||
toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconCloseRound");
|
||||
const oldScrollTop = protyle.contentElement.scrollTop;
|
||||
toolbarElement.classList.remove("fn__none");
|
||||
const oldScrollTop = protyle.contentElement.scrollTop + 333.5; // toolbarElement.clientHeight
|
||||
renderTextMenu(protyle, toolbarElement);
|
||||
showKeyboardToolbarUtil(oldScrollTop);
|
||||
toolbarElement.classList.remove("fn__none");
|
||||
}
|
||||
|
||||
public renderMultipleMenu(protyle: IProtyle, selectsElement: Element[]) {
|
||||
|
|
Loading…
Add table
Reference in a new issue