Vanessa 2024-04-12 23:44:53 +08:00
parent f822e4d69e
commit 45e04e645d
5 changed files with 25 additions and 24 deletions

View file

@ -8,6 +8,11 @@
opacity: 1;
}
&__cursor {
width: .1px;
height: 0;
}
&__container {
overflow: auto;
cursor: auto;
@ -70,13 +75,6 @@
color: var(--b3-theme-on-surface);
content: attr(data-tip);
}
&--hide {
width: .1px;
overflow: hidden;
height: 0;
min-height: .1px !important;
}
}
&__counter {

View file

@ -229,7 +229,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}</div>`;
${response.data.isMirror ? ` <span data-av-id="${response.data.id}" data-popover-url="/api/av/getMirrorDatabaseBlocks" class="popover__block block__icon block__icon--show ariaLabel" aria-label="${window.siyuan.languages.mirrorTip}">
<svg><use xlink:href="#iconSplitLR"></use></svg></span><div class="fn__space"></div>` : ""}
</div>
<div contenteditable="${protyle.disabled ? "false" : "true"}" spellcheck="${window.siyuan.config.editor.spellcheck.toString()}" class="av__title${viewData.hideAttrViewName ? " av__title--hide" : ""}" data-title="${response.data.name || ""}" data-tip="${window.siyuan.languages.title}">${response.data.name || ""}</div>
<div contenteditable="${protyle.disabled ? "false" : "true"}" spellcheck="${window.siyuan.config.editor.spellcheck.toString()}" class="av__title${viewData.hideAttrViewName ? " fn__none" : ""}" data-title="${response.data.name || ""}" data-tip="${window.siyuan.languages.title}">${response.data.name || ""}</div>
<div class="av__counter fn__none"></div>
</div>
<div class="av__scroll">
@ -254,6 +254,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}</div>`;
<div class="av__row--footer">${calcHTML}</div>
</div>
</div>
<div class="av__cursor" contenteditable="true">${Constants.ZWSP}</div>
</div>`;
e.setAttribute("data-render", "true");
// 历史兼容

View file

@ -135,7 +135,7 @@ export const bindViewEvent = (options: {
blockID,
data: false
}]);
options.blockElement.querySelector(".av__title").classList.add("av__title--hide");
options.blockElement.querySelector(".av__title").classList.add("fn__none");
} else {
transaction(options.protyle, [{
action: "hideAttrViewName",
@ -148,7 +148,7 @@ export const bindViewEvent = (options: {
blockID,
data: true
}]);
options.blockElement.querySelector(".av__title").classList.remove("av__title--hide");
options.blockElement.querySelector(".av__title").classList.remove("fn__none");
}
});
};

View file

@ -491,7 +491,7 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
return false;
}
// hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等删除段落块后光标位置矫正 https://github.com/siyuan-note/siyuan/issues/4143
if (element.classList.contains("render-node") || element.classList.contains("iframe") || element.classList.contains("hr")) {
if (element.classList.contains("render-node") || element.classList.contains("iframe") || element.classList.contains("hr") || element.classList.contains("av")) {
const range = document.createRange();
const type = element.getAttribute("data-type");
let setRange = false;
@ -531,6 +531,14 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
range.selectNodeContents(element);
range.collapse(true);
setRange = true;
} else if (type === "NodeAttributeView") {
const cursorElement = element.querySelector(".av__cursor")
if (cursorElement) {
range.setStart(cursorElement.firstChild, 0);
setRange = true;
} else {
return false;
}
}
if (setRange) {
focusByRange(range);
@ -539,17 +547,6 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
focusSideBlock(element);
return false;
}
} else if (element.classList.contains("av")) {
const avTitleElement = element.querySelector(".av__title");
if (avTitleElement) {
const range = document.createRange();
range.selectNodeContents(avTitleElement);
range.collapse();
focusByRange(range);
return range;
} else {
return false;
}
}
let cursorElement;
if (toStart) {

View file

@ -9,7 +9,7 @@ import {getContenteditableElement, getNextBlock, hasNextSibling, isNotEditBlock}
import {genEmptyBlock} from "../../block/util";
import {blockRender} from "../render/blockRender";
import {hideElements} from "../ui/hideElements";
import {hasClosestByAttribute} from "../util/hasClosest";
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {headingTurnIntoList, turnIntoTaskList} from "./turnIntoList";
import {updateAVName} from "../render/av/action";
@ -20,7 +20,12 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
return;
}
if (blockElement.classList.contains("av")) {
const avCursorElement = hasClosestByClassName(range.startContainer, "av__cursor")
if (avCursorElement) {
range.startContainer.textContent = Constants.ZWSP;
} else {
updateAVName(protyle, blockElement);
}
return;
}
const editElement = getContenteditableElement(blockElement) as HTMLElement;