From e5c96b499d99ca5c23d11b19e3e1cb44763bb4d1 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 20 Aug 2023 12:26:36 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9004 --- app/src/assets/scss/protyle/_wysiwyg.scss | 26 +++++++++++++++-------- app/src/protyle/wysiwyg/index.ts | 26 ++++++++++++----------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index d5bbff5e0..d23ee1f16 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -555,6 +555,23 @@ } } +// 只读情况下列表前的圆点需要可以点击进行缩放 +.protyle .protyle-wysiwyg { + .li[data-subtype="o"] > .protyle-action, + .li[data-subtype="u"] > .protyle-action, + &[contenteditable="true"] .li[data-subtype="t"] > .protyle-action { + cursor: pointer; + + &:hover { + &:after { + background-color: var(--b3-theme-background-light); + } + + color: var(--b3-theme-on-background); + } + } +} + // 导出 html 不需要编辑样式 .protyle-wysiwyg[contenteditable="true"] { span[data-type~="inline-math"], @@ -563,7 +580,6 @@ span[data-type~="file-annotation-ref"], .protyle-action__language, .img > span:nth-child(2), - .li > .protyle-action, .render-node { cursor: pointer; } @@ -577,14 +593,6 @@ opacity: 1; } - .li > .protyle-action:hover { - &:after { - opacity: .68; - } - - color: var(--b3-theme-on-background); - } - .code-block .protyle-action { -webkit-user-modify: read-only; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 87239e20f..e2732a538 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1932,8 +1932,8 @@ export class WYSIWYG { clientX: event.clientX + 4, clientY: event.clientY }); - } else if (!protyle.disabled && actionElement.parentElement.classList.contains("li")) { - if (event.altKey) { + } else if (actionElement.parentElement.classList.contains("li")) { + if (event.altKey && !protyle.disabled) { // 展开/折叠当前层级的所有列表项 if (actionElement.parentElement.parentElement.classList.contains("protyle-wysiwyg")) { // 缩放列表项 https://ld246.com/article/1653123034794 @@ -1961,22 +1961,24 @@ export class WYSIWYG { updateTransaction(protyle, actionElement.parentElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.parentElement.outerHTML, oldHTML); } hideElements(["gutter"], protyle); - } else if (event.shiftKey) { + } else if (event.shiftKey && !protyle.disabled) { openAttr(actionElement.parentElement); } else if (ctrlIsPressed) { zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")}); } else { if (actionElement.classList.contains("protyle-action--task")) { - const html = actionElement.parentElement.outerHTML; - if (actionElement.parentElement.classList.contains("protyle-task--done")) { - actionElement.querySelector("use").setAttribute("xlink:href", "#iconUncheck"); - actionElement.parentElement.classList.remove("protyle-task--done"); - } else { - actionElement.querySelector("use").setAttribute("xlink:href", "#iconCheck"); - actionElement.parentElement.classList.add("protyle-task--done"); + if (!protyle.disabled) { + const html = actionElement.parentElement.outerHTML; + if (actionElement.parentElement.classList.contains("protyle-task--done")) { + actionElement.querySelector("use").setAttribute("xlink:href", "#iconUncheck"); + actionElement.parentElement.classList.remove("protyle-task--done"); + } else { + actionElement.querySelector("use").setAttribute("xlink:href", "#iconCheck"); + actionElement.parentElement.classList.add("protyle-task--done"); + } + actionElement.parentElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); + updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html); } - actionElement.parentElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); - updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html); } else { zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")}); }