Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 数据库改进

Vanessa3cde9f52192f
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index f983069184..cc7abd45b7 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -23,7 +23,7 @@ export const initBlockPopover = (app: App) => {
if (aElement) {
let tip = aElement.getAttribute("aria-label") || aElement.getAttribute("data-inline-memo-content");
if (aElement.classList.contains("av__celltext")) {
- if (aElement.offsetWidth > aElement.parentElement.clientWidth - 5) { // 只能减左边 padding,换行时字体会穿透到右侧 padding
+ if (aElement.offsetWidth > aElement.parentElement.clientWidth - (aElement.classList.contains("fn__flex-shrink") ? 19 : 5)) { // 只能减左边 padding,换行时字体会穿透到右侧 padding
if (aElement.querySelector(".av__cellicon")) {
tip = `${aElement.firstChild.textContent} → ${aElement.lastChild.textContent}`;
} else {
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index b95212b627..65df6926e4 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -217,6 +217,9 @@ export class Gutter {
return;
}
if (buttonElement.dataset.type === "NodeAttributeViewRow") {
+ blockElement.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => {
+ cellElement.classList.remove("av__cell--select");
+ });
const avID = blockElement.getAttribute("data-av-id");
const srcIDs = [Lute.NewNodeID()];
const previousID = event.altKey ? (rowElement.previousElementSibling.getAttribute("data-id") || "") : buttonElement.dataset.rowId;
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 03cfe04661..24991bf0ef 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -399,7 +399,10 @@ ${genHintItemHTML(item)}
return;
}
if (this.source === "av") {
- const cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell");
+ let cellElement = hasClosestByClassName(protyle.toolbar.range.startContainer, "av__cell");
+ if (!cellElement) {
+ cellElement = nodeElement.querySelector(".av__cell--select") as HTMLElement;
+ }
if (!cellElement) {
return;
}
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index e30fcd9ad9..1f53964a12 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -315,8 +315,15 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
inputElement.addEventListener("input", (event: InputEvent) => {
if (Constants.BLOCK_HINT_KEYS.includes(inputElement.value.substring(0, 2))) {
protyle.toolbar.range = document.createRange();
+ if (!blockElement.contains(cellElements[0])) {
+ const rowElement = hasClosestByClassName(cellElements[0], "av__row") as HTMLElement;
+ if (cellElements[0]) {
+ cellElements[0] = blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${cellElements[0].dataset.colId}"]`) as HTMLElement;
+ }
+ }
protyle.toolbar.range.selectNodeContents(cellElements[0].lastChild);
focusByRange(protyle.toolbar.range);
+ cellElements[0].classList.add("av__cell--select");
hintRef(inputElement.value.substring(2), protyle, "av");
avMaskElement?.remove();
event.preventDefault();
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index a61cd9a76b..4a8cbfc980 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -98,7 +98,7 @@ data-icon="${column.icon}" data-dtype="${column.type}" data-wrap="${column.wrap}
style="width: ${column.width || "200px"};">
<div draggable="true" class="av__cellheader">
${column.icon ? unicode2Emoji(column.icon, "av__cellheadericon", true) : `<svg class="av__cellheadericon"><use xlink:href="#${getColIconByType(column.type)}"></use></svg>`}
- <span class="av__celltext">${column.name}</span>
+ <span class="av__celltext fn__flex-shrink">${column.name}</span>
${column.pin ? '<div class="fn__flex-1"></div><svg class="av__cellheadericon"><use xlink:href="#iconPin"></use></svg>' : ""}
</div>
<div class="av__widthdrag"></div>
@@ -292,11 +292,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
item.removeAttribute("data-render");
avRender(item, protyle, () => {
- if (operation.action === "insertAttrViewBlock") {
- item.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => {
- cellElement.classList.remove("av__cell--select");
- });
- } else if (operation.action === "addAttrViewCol" && item.querySelector(".av__pulse")) {
+ if (operation.action === "addAttrViewCol" && item.querySelector(".av__pulse")) {
openMenuPanel({protyle, blockElement: item, type: "edit", colId: operation.id});
}
}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 06ea105e09..966e76c85a 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1326,6 +1326,17 @@ export class WYSIWYG {
/// #endif
return false;
}
+ // 在 span 前面,防止单元格哪 block-ref 被修改
+ const avRowElement = hasClosestByClassName(target, "av__row");
+ if (avRowElement && avContextmenu(protyle, avRowElement, {
+ x: event.clientX,
+ y: avRowElement.getBoundingClientRect().bottom,
+ h: avRowElement.clientHeight
+ })) {
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
protyle.toolbar.range = getEditorRange(protyle.element);
if (target.tagName === "SPAN") { // https://ld246.com/article/1665141518103
let types = protyle.toolbar.getCurrentType(protyle.toolbar.range);
@@ -1373,17 +1384,6 @@ export class WYSIWYG {
});
return false;
}
-
- const avRowElement = hasClosestByClassName(target, "av__row");
- if (avRowElement && avContextmenu(protyle, avRowElement, {
- x: event.clientX,
- y: avRowElement.getBoundingClientRect().bottom,
- h: avRowElement.clientHeight
- })) {
- event.stopPropagation();
- event.preventDefault();
- return;
- }
const nodeElement = hasClosestBlock(target);
if (!nodeElement) {
return false;