Compare commits

...

7 commits

11 changed files with 139 additions and 70 deletions

View file

@ -67,10 +67,14 @@ export const viewCards = (app: App, deckID: string, title: string, deckType: "Tr
if (response.data.blocks.length > 0) {
edit = new Protyle(app, dialog.element.querySelector("#cardPreview") as HTMLElement, {
blockId: "",
action: [Constants.CB_GET_ALL],
render: {
gutter: true,
breadcrumbDocName: true
breadcrumbDocName: true,
title: true,
hideTitleOnZoom: true,
},
typewriterMode: false
});
if (window.siyuan.mobile) {
window.siyuan.mobile.popEditor = edit;
@ -310,6 +314,10 @@ const getArticle = (edit: Protyle, id: string) => {
data: getResponse,
protyle: edit.protyle,
action: getResponse.data.rootID === getResponse.data.id ? [Constants.CB_GET_HTML] : [Constants.CB_GET_ALL, Constants.CB_GET_HTML],
afterCB() {
edit.protyle.title.element.removeAttribute("data-render");
edit.protyle.title.render(edit.protyle, response);
}
});
});
});

View file

@ -866,7 +866,7 @@ data-type="navigation-root" data-path="/">
}
window.siyuan.storage[Constants.LOCAL_FILESPATHS].forEach((item: IFilesPath) => {
item.openPaths.forEach((openPath) => {
this.selectItem(item.notebookId, openPath, undefined, false);
this.selectItem(item.notebookId, openPath, undefined, false, false);
});
});
if (!init) {
@ -1081,7 +1081,11 @@ data-type="navigation-root" data-path="/">
}, 2);
}
private onLsSelect(data: { files: IFile[], box: string, path: string }, filePath: string, setStorage: boolean) {
private async onLsSelect(data: {
files: IFile[],
box: string,
path: string
}, filePath: string, setStorage: boolean, isSetCurrent: boolean) {
let fileHTML = "";
data.files.forEach((item: IFile) => {
fileHTML += this.genFileHTML(item);
@ -1102,28 +1106,30 @@ data-type="navigation-root" data-path="/">
emojiElement.textContent = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder);
}
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
data.files.forEach((item: IFile) => {
let newLiElement;
for (let i = 0; i < data.files.length; i++) {
const item = data.files[i];
if (filePath === item.path) {
this.selectItem(data.box, filePath, undefined, setStorage);
newLiElement = await this.selectItem(data.box, filePath, undefined, setStorage, isSetCurrent);
} else if (filePath.startsWith(item.path.replace(".sy", ""))) {
fetchPost("/api/filetree/listDocsByPath", {
const response = await fetchSyncPost("/api/filetree/listDocsByPath", {
notebook: data.box,
path: item.path
}, response => {
this.selectItem(response.data.box, filePath, response.data, setStorage);
});
newLiElement = await this.selectItem(response.data.box, filePath, response.data, setStorage, isSetCurrent);
}
});
if (setStorage) {
this.setCurrent(this.element.querySelector(`ul[data-url="${data.box}"] li[data-path="${filePath}"]`));
}
if (isSetCurrent) {
this.setCurrent(newLiElement);
}
return newLiElement;
}
private setCurrent(target: HTMLElement, isScroll = true) {
public setCurrent(target: HTMLElement, isScroll = true) {
if (!target) {
return;
}
this.element.querySelectorAll("li").forEach((liItem) => {
this.element.querySelectorAll("li.b3-list-item--focus").forEach((liItem) => {
liItem.classList.remove("b3-list-item--focus");
});
target.classList.add("b3-list-item--focus");
@ -1155,11 +1161,11 @@ data-type="navigation-root" data-path="/">
});
}
public selectItem(notebookId: string, filePath: string, data?: {
public async selectItem(notebookId: string, filePath: string, data?: {
files: IFile[],
box: string,
path: string
}, setStorage = true) {
}, setStorage = true, isSetCurrent = true) {
const treeElement = this.element.querySelector(`[data-url="${notebookId}"]`);
if (!treeElement) {
// 有文件树和编辑器的布局初始化时,文件树还未挂载
@ -1181,24 +1187,24 @@ data-type="navigation-root" data-path="/">
if (liElement.getAttribute("data-path") === filePath) {
if (setStorage) {
this.setCurrent(liElement);
this.getOpenPaths();
} else {
this.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
}
return;
if (isSetCurrent) {
this.setCurrent(liElement);
}
return liElement;
}
if (data && data.path === currentPath) {
this.onLsSelect(data, filePath, setStorage);
liElement = await this.onLsSelect(data, filePath, setStorage, isSetCurrent);
} else {
fetchPost("/api/filetree/listDocsByPath", {
const response = await fetchSyncPost("/api/filetree/listDocsByPath", {
notebook: notebookId,
path: currentPath
}, response => {
this.onLsSelect(response.data, filePath, setStorage);
});
liElement = await this.onLsSelect(response.data, filePath, setStorage, isSetCurrent);
}
return liElement;
}
private getOpenPaths() {

View file

@ -5,7 +5,7 @@ import {Constants} from "../../constants";
import {getDisplayName, pathPosix, setNoteBook} from "../../util/pathName";
import {initFileMenu, initNavigationMenu, sortMenu} from "../../menus/navigation";
import {showMessage} from "../../dialog/message";
import {fetchPost} from "../../util/fetch";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {genUUID} from "../../util/genID";
import {openMobileFileById} from "../editor";
import {unicode2Emoji} from "../../emoji";
@ -361,7 +361,7 @@ export class MobileFiles extends Model {
}
window.siyuan.storage[Constants.LOCAL_FILESPATHS].forEach((item: IFilesPath) => {
item.openPaths.forEach((openPath) => {
this.selectItem(item.notebookId, openPath, undefined, false);
this.selectItem(item.notebookId, openPath, undefined, false, false);
});
});
if (!init) {
@ -577,20 +577,14 @@ export class MobileFiles extends Model {
}, 2);
}
private onLsSelect(data: { files: IFile[], box: string, path: string }, filePath: string, setStorage: boolean) {
private async onLsSelect(data: {
files: IFile[],
box: string,
path: string
}, filePath: string, setStorage: boolean, isSetCurrent: boolean) {
let fileHTML = "";
data.files.forEach((item: IFile) => {
fileHTML += this.genFileHTML(item);
if (filePath === item.path) {
this.selectItem(data.box, filePath, undefined, setStorage);
} else if (filePath.startsWith(item.path.replace(".sy", ""))) {
fetchPost("/api/filetree/listDocsByPath", {
notebook: data.box,
path: item.path
}, response => {
this.selectItem(response.data.box, filePath, response.data, setStorage);
});
}
});
if (fileHTML === "") {
return;
@ -600,26 +594,45 @@ export class MobileFiles extends Model {
// 文件展开时,刷新
liElement.nextElementSibling.remove();
}
liElement.querySelector(".b3-list-item__arrow").classList.add("b3-list-item__arrow--open");
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
if (setStorage) {
this.setCurrent(this.element.querySelector(`ul[data-url="${data.box}"] li[data-path="${filePath}"]`));
const arrowElement = liElement.querySelector(".b3-list-item__arrow");
arrowElement.classList.add("b3-list-item__arrow--open");
arrowElement.parentElement.classList.remove("fn__hidden");
const emojiElement = liElement.querySelector(".b3-list-item__icon");
if (emojiElement.textContent === unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].file)) {
emojiElement.textContent = unicode2Emoji(window.siyuan.storage[Constants.LOCAL_IMAGES].folder);
}
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
let newLiElement;
for (let i = 0; i < data.files.length; i++) {
const item = data.files[i];
if (filePath === item.path) {
newLiElement = await this.selectItem(data.box, filePath, undefined, setStorage, isSetCurrent);
} else if (filePath.startsWith(item.path.replace(".sy", ""))) {
const response = await fetchSyncPost("/api/filetree/listDocsByPath", {
notebook: data.box,
path: item.path
});
newLiElement = await this.selectItem(response.data.box, filePath, response.data, setStorage, isSetCurrent);
}
}
if (isSetCurrent) {
this.setCurrent(newLiElement);
}
return newLiElement;
}
private setCurrent(target: HTMLElement) {
public setCurrent(target: HTMLElement, isScroll = true) {
if (!target) {
return;
}
this.element.querySelectorAll("li").forEach((liItem) => {
this.element.querySelectorAll("li.b3-list-item--focus").forEach((liItem) => {
liItem.classList.remove("b3-list-item--focus");
});
target.classList.add("b3-list-item--focus");
const titleHeight = this.actionsElement.clientHeight;
if (target.offsetTop - titleHeight < this.element.scrollTop) {
this.element.scrollTop = target.offsetTop - titleHeight;
} else if (target.offsetTop - this.element.clientHeight - titleHeight + target.clientHeight > this.element.scrollTop) {
this.element.scrollTop = target.offsetTop - this.element.clientHeight - titleHeight + target.clientHeight;
if (isScroll) {
const elementRect = this.element.getBoundingClientRect();
this.element.scrollTop = this.element.scrollTop + (target.getBoundingClientRect().top - (elementRect.top + elementRect.height / 2));
}
}
@ -644,11 +657,11 @@ export class MobileFiles extends Model {
});
}
public selectItem(notebookId: string, filePath: string, data?: {
public async selectItem(notebookId: string, filePath: string, data?: {
files: IFile[],
box: string,
path: string
}, setStorage = true) {
}, setStorage = true, isSetCurrent = true) {
const treeElement = this.element.querySelector(`[data-url="${notebookId}"]`);
if (!treeElement) {
// 有文件树和编辑器的布局初始化时,文件树还未挂载
@ -670,24 +683,24 @@ export class MobileFiles extends Model {
if (liElement.getAttribute("data-path") === filePath) {
if (setStorage) {
this.setCurrent(liElement);
this.getOpenPaths();
} else {
this.element.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
}
return;
if (isSetCurrent) {
this.setCurrent(liElement);
}
return liElement;
}
if (data && data.path === currentPath) {
this.onLsSelect(data, filePath, setStorage);
liElement = await this.onLsSelect(data, filePath, setStorage, isSetCurrent);
} else {
fetchPost("/api/filetree/listDocsByPath", {
const response = await fetchSyncPost("/api/filetree/listDocsByPath", {
notebook: notebookId,
path: currentPath
}, response => {
this.onLsSelect(response.data, filePath, setStorage);
});
liElement = await this.onLsSelect(response.data, filePath, setStorage, isSetCurrent);
}
return liElement;
}
private getOpenPaths() {

View file

@ -30,6 +30,7 @@ import {globalCommand} from "../boot/globalEvent/command/global";
import {exportLayout} from "../layout/util";
import {saveScroll} from "../protyle/scroll/saveScroll";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {Files} from "../layout/dock/Files";
let openTab;
let openWindow;
@ -248,6 +249,43 @@ const getActiveEditor = (wndActive = true) => {
return editor;
};
export const expandDocTree = async (options: {
id: string,
isSetCurrent?: boolean
}) => {
let isNotebook = false;
window.siyuan.notebooks.find(item => {
if (options.id === item.id) {
isNotebook = true;
return true;
}
});
let liElement: HTMLElement;
let notebookId = options.id;
const file = getModelByDockType("file") as Files;
if (typeof options.isSetCurrent === "undefined") {
options.isSetCurrent = true;
}
if (isNotebook) {
liElement = file.element.querySelector(`.b3-list[data-url="${options.id}"]`).firstElementChild as HTMLElement;
} else {
const response = await fetchSyncPost("api/block/getBlockInfo", {id: options.id});
notebookId = response.data.box;
liElement = await file.selectItem(response.data.box, response.data.path, undefined, undefined, options.isSetCurrent);
}
if (!liElement) {
return;
}
if (options.isSetCurrent || typeof options.isSetCurrent === "undefined") {
file.setCurrent(liElement);
}
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
return;
}
file.getLeaf(liElement, notebookId);
};
export const API = {
adaptHotkey: updateHotkeyTip,
confirm: confirmDialog,
@ -281,4 +319,5 @@ export const API = {
openAttributePanel,
saveLayout,
globalCommand,
expandDocTree
};

View file

@ -24,6 +24,7 @@ import {transferBlockRef} from "../../menus/block";
import {addEditorToDatabase} from "../render/av/addToDatabase";
import {openFileById} from "../../editor/util";
import {hasTopClosestByClassName} from "../util/hasClosest";
import {openMobileFileById} from "../../mobile/editor";
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
hideTooltip();
@ -214,22 +215,24 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
transferBlockRef(protyle.block.rootID);
}
window.siyuan.menus.menu.append(new MenuItem({id: "separator_3", type: "separator"}).element);
/// #if !MOBILE
if (!protyle.model) {
window.siyuan.menus.menu.append(new MenuItem({
id: "openBy",
label: window.siyuan.languages.openBy,
icon: "iconOpen",
click() {
/// #if !MOBILE
openFileById({
app: protyle.app,
id: protyle.block.id,
action: protyle.block.rootID !== protyle.block.id ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_CONTEXT],
});
/// #else
openMobileFileById(protyle.app, protyle.block.id, protyle.block.rootID !== protyle.block.id ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_CONTEXT]);
/// #endif
}
}).element);
}
/// #endif
/// #if !BROWSER
window.siyuan.menus.menu.append(new MenuItem({
id: "openByNewWindow",

View file

@ -309,7 +309,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
content2: dateObj2.valueOf() || 0,
isNotEmpty2: !isNaN(dateObj2.valueOf()),
hasEndDate: !isNaN(dateObj2.valueOf()),
isNotTime: dateObj1.hour() === 0,
isNotTime: dateObj1.hour() === 0 && values[0].split(":").length === 1,
formattedContent: "",
}
};

File diff suppressed because one or more lines are too long

View file

@ -538,17 +538,17 @@ func filterRelativeTime(valueMills int64, valueIsNotEmpty bool, operator FilterO
switch operator {
case FilterOperatorIsEqual:
return (valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && valueTime.Before(otherValueEnd)
return (valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)) && (valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd))
case FilterOperatorIsNotEqual:
return valueTime.Before(otherValueStart) || valueTime.After(otherValueEnd)
case FilterOperatorIsGreater:
return valueTime.After(otherValueStart)
return valueTime.After(otherValueEnd)
case FilterOperatorIsGreaterOrEqual:
return valueTime.After(otherValueStart) || valueTime.Equal(otherValueStart)
case FilterOperatorIsLess:
return valueTime.Before(otherValueStart)
case FilterOperatorIsLessOrEqual:
return valueTime.Before(otherValueStart) || valueTime.Equal(otherValueStart)
return valueTime.Before(otherValueEnd) || valueTime.Equal(otherValueEnd)
case FilterOperatorIsBetween:
if RelativeDateDirectionBefore == direction {
if RelativeDateDirectionBefore == direction2 {

View file

@ -8,7 +8,7 @@ require (
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689
github.com/88250/lute v1.7.7-0.20250828030734-1d304fa491d3
github.com/88250/lute v1.7.7-0.20250903032105-b1737f9621fb
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
github.com/ConradIrwin/font v0.2.1

View file

@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689 h1:39y5g7vnFAIcXhTN3IXPk7h2xBhC4a9hBTykDhHJqRY=
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=
github.com/88250/lute v1.7.7-0.20250828030734-1d304fa491d3 h1:Y/ZKnwrgdICSxkXMGJZL7R18FlCrumP9VQQTdyTQZrM=
github.com/88250/lute v1.7.7-0.20250828030734-1d304fa491d3/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
github.com/88250/lute v1.7.7-0.20250903032105-b1737f9621fb h1:ioONtSsO7UCA3CrJMu2wbDkdmYDXrYY51lj8PD8pLNI=
github.com/88250/lute v1.7.7-0.20250903032105-b1737f9621fb/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46 h1:Bq1JsDfVbHKUxNL/B2JXd8cC/1h6aFjrlXpGycnh0Hk=
github.com/88250/pdfcpu v0.3.14-0.20250424122812-f10e8d9d8d46/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

View file

@ -197,8 +197,8 @@ func Upload(c *gin.Context) {
succMap[baseName] = existAsset.Path
} else {
if skipIfDuplicated {
// https://github.com/siyuan-note/siyuan/issues/10666
matches, globErr := filepath.Glob(assetsDirPath + string(os.PathSeparator) + strings.TrimSuffix(fName, ext) + "*")
// 复制 PDF 矩形注解时不再重复插入图片 No longer upload image repeatedly when copying PDF rectangle annotation https://github.com/siyuan-note/siyuan/issues/10666
matches, globErr := filepath.Glob(assetsDirPath + string(os.PathSeparator) + strings.TrimSuffix(fName, ext) + "*" + ext)
if nil != globErr {
logging.LogErrorf("glob failed: %s", globErr)
} else {