From 99ec37e78c6b583ba306b5c8c58bd1b82a5e9586 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 2 Feb 2023 23:16:18 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E8=81=9A=E7=84=A6=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?*=201=20*=202=EF=BC=8C=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B9=E5=8F=8D=E5=90=91=E7=BC=A9=E8=BF=9B=E5=90=8E?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E4=BC=9A=E5=85=B3=E9=97=AD=E9=A1=B5=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/menus/protyle.ts | 9 ++++----- app/src/protyle/gutter/index.ts | 2 +- app/src/protyle/util/paste.ts | 4 ++-- app/src/protyle/wysiwyg/list.ts | 4 ++++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index a5e0cf163..b5c8b44a1 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -39,7 +39,6 @@ import {pushBack} from "../mobile/util/MobileBackFoward"; import {exportAsset} from "./util"; import {removeLink} from "../protyle/toolbar/Link"; import {alignImgCenter, alignImgLeft} from "../protyle/wysiwyg/commonHotkey"; -import {getEnableHTML} from "../protyle/wysiwyg/removeEmbed"; import {renameTag} from "../util/noRelyPCFunction"; export const refMenu = (protyle: IProtyle, element: HTMLElement) => { @@ -666,13 +665,13 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme openMenu(imgSrc, false, false); } window.siyuan.menus.menu.popup({x: position.clientX, y: position.clientY}); - const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea") + const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea"); textElements[0].focus(); window.siyuan.menus.menu.removeCB = () => { imgElement.setAttribute("alt", textElements[2].value.replace(/\n|\r\n|\r|\u2028|\u2029/g, "")); nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); updateTransaction(protyle, id, nodeElement.outerHTML, html); - } + }; }; export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText = false) => { @@ -824,7 +823,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText y: rect.top + 26, h: 26 }); - const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea") + const textElements = window.siyuan.menus.menu.element.querySelectorAll("textarea"); if (focusText || protyle.lute.IsValidLinkDest(linkAddress)) { textElements[1].select(); } else { @@ -846,7 +845,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText } nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); updateTransaction(protyle, id, nodeElement.outerHTML, html); - } + }; }; export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => { diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 666e5dea6..c759813a7 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -21,7 +21,7 @@ import {hideElements} from "../ui/hideElements"; import {processRender} from "../util/processCode"; import {highlightRender} from "../markdown/highlightRender"; import {blockRender} from "../markdown/blockRender"; -import {getEnableHTML, removeEmbed} from "../wysiwyg/removeEmbed"; +import {removeEmbed} from "../wysiwyg/removeEmbed"; import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock"; import * as dayjs from "dayjs"; import {fetchPost, fetchSyncPost} from "../../util/fetch"; diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 567f23067..fc5756c5c 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -168,8 +168,8 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven const range = getEditorRange(protyle.wysiwyg.element); if (siyuanHTML) { // 编辑器内部粘贴 - const tempElement = document.createElement("div") - tempElement.innerHTML = siyuanHTML + const tempElement = document.createElement("div"); + tempElement.innerHTML = siyuanHTML; let isBlock = false; tempElement.querySelectorAll("[data-node-id]").forEach((e) => { const newId = Lute.NewNodeID(); diff --git a/app/src/protyle/wysiwyg/list.ts b/app/src/protyle/wysiwyg/list.ts index 04994be41..12decd266 100644 --- a/app/src/protyle/wysiwyg/list.ts +++ b/app/src/protyle/wysiwyg/list.ts @@ -406,6 +406,10 @@ export const listOutdent = (protyle: IProtyle, liItemElements: Element[], range: action: "delete", id: liId }); + // 聚焦列表,第一个列表项反向缩进后刷新会关闭页签 + if (liId === protyle.block.id) { + protyle.block.id = protyle.block.parentID; + } undoOperations.splice(0, 0, { action: "insert", data: movedHTML,