Merge branch 'dev' into dev-emoji

This commit is contained in:
Jeffrey Chen 2024-12-24 23:12:20 +08:00 committed by GitHub
commit e0a2774c17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 60 additions and 23 deletions

View file

@ -311,21 +311,29 @@ html {
opacity: .38;
}
.dragover__top,
.dragover__bottom {
box-shadow: none !important;
}
.dragover__top::after,
.dragover__bottom::after {
content: "";
width: var(--file-toggle-width);
height: 4px;
background-color: var(--b3-theme-surface);
position: absolute;
left: 0;
bottom: -2px;
height: 4px;
width: calc(100% - var(--file-toggle-width));
left: var(--file-toggle-width);
background-color: var(--b3-theme-primary-lighter);
z-index: 1;
pointer-events: none;
}
.dragover__top::after {
top: -3px;
bottom: auto;
}
.dragover__bottom::after {
bottom: -2px;
}
&__close {

View file

@ -52,7 +52,7 @@ import {hideTooltip} from "../../dialog/tooltip";
import {appearanceMenu} from "../toolbar/Font";
import {setPosition} from "../../util/setPosition";
import {emitOpenMenu} from "../../plugin/EventBus";
import {insertAttrViewBlockAnimation} from "../render/av/row";
import {insertAttrViewBlockAnimation, updateHeader} from "../render/av/row";
import {avContextmenu, duplicateCompletely} from "../render/av/action";
import {getPlainText} from "../util/paste";
import {addEditorToDatabase} from "../render/av/addToDatabase";
@ -94,7 +94,10 @@ export class Gutter {
return true;
}
});
avElement.querySelector(`.av__row[data-id="${buttonElement.dataset.rowId}"]`).classList.add("av__row--select");
const rowElement = avElement.querySelector(`.av__row[data-id="${buttonElement.dataset.rowId}"]`);
rowElement.classList.add("av__row--select");
rowElement.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconCheck");
updateHeader(rowElement as HTMLElement);
avElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(item => {
selectIds.push(item.getAttribute("data-id"));
selectElements.push(item);
@ -437,7 +440,7 @@ export class Gutter {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${buttonElement.getAttribute("data-node-id")}"]`)).find(item => {
if (!isInEmbedBlock(item) && this.isMatchNode(item)) {
const rowItem = item.querySelector(`.av__row[data-id="${buttonElement.dataset.rowId}"]`);
Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, av__row--hl")).forEach(hlItem => {
Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, .av__row--hl")).forEach(hlItem => {
if (!item.isSameNode(hlItem)) {
hlItem.classList.remove("protyle-wysiwyg--hl");
}

View file

@ -440,6 +440,12 @@ export const hintRef = (key: string, protyle: IProtyle, source: THintSource): IH
let value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="d">${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
if (source === "search") {
value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${key}${Constants.ZWSP}${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
} else if (source === "av") {
let refText = item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "");
if (nodeElement) {
refText = item.ial["custom-sy-av-s-text-" + nodeElement.getAttribute("data-av-id")] || refText;
}
value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${refText}</span>`;
}
dataList.push({
value,

View file

@ -339,7 +339,11 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
let blockRefHTML;
if (source === "av") {
// av 搜索时需要获取值 https://github.com/siyuan-note/siyuan/issues/12020
blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "")}</span>`;
let refText = item.name || item.refText.replace(new RegExp(Constants.ZWSP, "g"), "");
if (nodeElement) {
refText = item.ial["custom-sy-av-s-text-" + nodeElement.getAttribute("data-av-id")] || refText;
}
blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${refText}</span>`;
} else {
blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${oldValue}</span>`;
}

View file

@ -329,7 +329,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
id: "copyBlockRef",
iconHTML: "",
label: window.siyuan.languages.copyBlockRef,
click: async () => {
click: () => {
let text = "";
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
@ -338,8 +338,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
if (cellElement.getAttribute("data-detached") === "true") {
content = cellElement.querySelector(".av__celltext").textContent;
} else {
const response = await fetchSyncPost("/api/block/getRefText", {id});
content = `((${id} '${response.data}'))`;
content = `((${id} '${cellElement.querySelector(".av__celltext").textContent}'))`;
}
if (ids.length > 1) {
text += "* ";
@ -399,7 +398,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
id: "copyProtocolInMd",
iconHTML: "",
label: window.siyuan.languages.copyProtocolInMd,
click: async () => {
click: () => {
let text = "";
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
@ -408,8 +407,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
if (cellElement.getAttribute("data-detached") === "true") {
content = cellElement.querySelector(".av__celltext").textContent;
} else {
const response = await fetchSyncPost("/api/block/getRefText", {id});
content = `[${response.data}](siyuan://blocks/${id})`;
content = `[${cellElement.querySelector(".av__celltext").textContent}](siyuan://blocks/${id})`;
}
if (ids.length > 1) {
text += "* ";

View file

@ -113,12 +113,14 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
return;
}
// https://github.com/siyuan-note/siyuan/issues/9015
if (trimStartText === "¥¥<wbr>" || trimStartText === "¥¥<wbr>") {
editElement.innerHTML = "$$<wbr>";
} else if (trimStartText.indexOf("\n¥¥<wbr>") > -1 || trimStartText.indexOf("\n¥¥<wbr>") > -1) {
if (type === "NodeParagraph" && (
editElement.innerHTML.startsWith("¥¥<wbr>") || editElement.innerHTML.startsWith("¥¥<wbr>") ||
// https://ld246.com/article/1730020516427
editElement.innerHTML = trimStartText.replace("\n¥¥<wbr>", "\n$$$$<wbr>").replace("\n¥¥<wbr>", "\n$$$$<wbr>");
trimStartText.indexOf("\n¥¥<wbr>") > -1 || trimStartText.indexOf("\n¥¥<wbr>") > -1
)) {
editElement.innerHTML = editElement.innerHTML.replace("¥¥<wbr>", "$$$$<wbr>").replace("¥¥<wbr>", "$$$$<wbr>");
}
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
if (refElement && refElement.getAttribute("data-subtype") === "d") {
const response = await fetchSyncPost("/api/block/getRefText", {id: refElement.getAttribute("data-id")});

View file

@ -57,6 +57,9 @@ func statAsset(c *gin.Context) {
if strings.Contains(p, ":") {
p = strings.TrimPrefix(p, "/")
}
if strings.Contains(p, "?") {
p = p[:strings.Index(p, "?")]
}
} else {
ret.Code = 1
return

View file

@ -116,6 +116,9 @@ func NetAssets2LocalAssets(rootID string, onlyImg bool, originalURL string) (err
if strings.Contains(u, ":") {
u = strings.TrimPrefix(u, "/")
}
if strings.Contains(u, "?") {
u = u[:strings.Index(u, "?")]
}
if !gulu.File.IsExist(u) || gulu.File.IsDir(u) {
continue

View file

@ -3108,12 +3108,22 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID string, valueDa
} else { // 之前绑定的块和现在绑定的块一样
content := strings.TrimSpace(val.Block.Content)
node, tree, _ := getNodeByBlockID(tx, val.BlockID)
updateStaticText := true
_, blockText := getNodeAvBlockText(node)
if "" == content {
_, val.Block.Content = getNodeAvBlockText(node)
val.Block.Content = blockText
} else {
if blockText == content {
updateStaticText = false
} else {
val.Block.Content = blockText
}
}
// 设置静态锚文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
updateBlockValueStaticText(tx, node, tree, avID, content)
if updateStaticText {
// 设置静态锚文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049
updateBlockValueStaticText(tx, node, tree, avID, content)
}
}
}
}