This commit is contained in:
Vanessa 2022-08-06 18:01:20 +08:00
parent f7e34c0e71
commit 842e22fde6
4 changed files with 6 additions and 8 deletions

View file

@ -6,10 +6,8 @@ import {fetchPost} from "../../util/fetch";
import {getAllModels} from "../getAll";
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
import {updateHotkeyTip} from "../../protyle/util/compatibility";
import {openFileById, updateBacklinkGraph} from "../../editor/util";
import {openFileById} from "../../editor/util";
import {Constants} from "../../constants";
import {focusBlock} from "../../protyle/util/selection";
import {pushBack} from "../../util/backForward";
import {escapeHtml} from "../../util/escape";
import {unicode2Emoji} from "../../emoji";
import {onGet} from "../../protyle/util/onGet";

View file

@ -7,10 +7,10 @@ import {updateHotkeyTip} from "../util/compatibility";
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
let elementRect = element.getBoundingClientRect();
element.addEventListener("scroll", (event) => {
element.addEventListener("scroll", () => {
if (!protyle.toolbar.element.classList.contains("fn__none")) {
const initY = protyle.toolbar.element.getAttribute("data-inity").split(Constants.ZWSP);
const top = parseInt(initY[0]) + (parseInt(initY[1]) - element.scrollTop)
const top = parseInt(initY[0]) + (parseInt(initY[1]) - element.scrollTop);
if (elementRect.width === 0) {
elementRect = element.getBoundingClientRect();
}

View file

@ -115,7 +115,7 @@ export class Toolbar {
}
const rangePosition = getSelectionPosition(nodeElement, range);
this.element.classList.remove("fn__none");
const y = rangePosition.top - this.toolbarHeight - 4
const y = rangePosition.top - this.toolbarHeight - 4;
this.element.setAttribute("data-inity", y + Constants.ZWSP + protyle.contentElement.scrollTop.toString());
setPosition(this.element, rangePosition.left - 52, y);
this.element.querySelectorAll(".protyle-toolbar__item--current").forEach(item => {

View file

@ -141,7 +141,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
tempElement.innerHTML = `<div${subType === "o" ? " data-marker=\"1.\"" : ""} data-subtype="${subType}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">${html}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
}
}
let lastElement: Element
let lastElement: Element;
Array.from(tempElement.content.children).reverse().forEach((item) => {
const addId = item.getAttribute("data-node-id");
if (addId === id) {
@ -192,7 +192,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
// https://github.com/siyuan-note/siyuan/issues/5591
focusBlock(lastElement, undefined, false);
}
const wbrElement = protyle.wysiwyg.element.querySelector("wbr")
const wbrElement = protyle.wysiwyg.element.querySelector("wbr");
if (wbrElement) {
wbrElement.remove();
}