mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
0aa9c82450
6 changed files with 51 additions and 16 deletions
|
|
@ -674,8 +674,8 @@ export const updateBacklinkGraph = (models: IModels, protyle: IProtyle) => {
|
|||
}
|
||||
item.element.querySelector('.block__icon[data-type="refresh"] svg').classList.add("fn__rotate");
|
||||
fetchPost("/api/ref/getBacklink2", {
|
||||
sort: item.status[blockId] ? item.status[blockId].sort : "3",
|
||||
mSort: item.status[blockId] ? item.status[blockId].mSort : "3",
|
||||
sort: item.status[blockId] ? item.status[blockId].sort.toString() : window.siyuan.config.editor.backlinkSort.toString(),
|
||||
mSort: item.status[blockId] ? item.status[blockId].mSort.toString() : window.siyuan.config.editor.backmentionSort.toString(),
|
||||
id: blockId || "",
|
||||
k: item.inputsElement[0].value,
|
||||
mk: item.inputsElement[1].value,
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ export class Backlink extends Model {
|
|||
public editors: Protyle[] = [];
|
||||
public status: {
|
||||
[key: string]: {
|
||||
sort: string,
|
||||
mSort: string,
|
||||
sort: number,
|
||||
mSort: number,
|
||||
scrollTop: number,
|
||||
mScrollTop: number,
|
||||
backlinkOpenIds: string[],
|
||||
|
|
@ -80,6 +80,8 @@ export class Backlink extends Model {
|
|||
this.type = options.type;
|
||||
this.element = options.tab.panelElement;
|
||||
this.element.classList.add("fn__flex-column", "file-tree", "sy__backlink");
|
||||
const backlinkSort = window.siyuan.config.editor.backlinkSort;
|
||||
const backmentionSort = window.siyuan.config.editor.backmentionSort;
|
||||
this.element.innerHTML = `<div class="block__icons">
|
||||
<div class="block__logo">
|
||||
<svg class="block__logoicon"><use xlink:href="#iconLink"></use></svg>${window.siyuan.languages.backlinks}
|
||||
|
|
@ -92,7 +94,7 @@ export class Backlink extends Model {
|
|||
<span class="fn__space"></span>
|
||||
<span data-type="refresh" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.refresh}"><svg><use xlink:href='#iconRefresh'></use></svg></span>
|
||||
<span class="fn__space"></span>
|
||||
<span data-type="sort" data-sort="3" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.sort}"><svg><use xlink:href='#iconSort'></use></svg></span>
|
||||
<span data-type="sort" data-sort="${backlinkSort}" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.sort}"><svg><use xlink:href='#iconSort'></use></svg></span>
|
||||
<span class="fn__space"></span>
|
||||
<span data-type="expand" class="block__icon b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.expand}${updateHotkeyAfterTip(window.siyuan.config.keymap.editor.general.expand.custom)}">
|
||||
<svg><use xlink:href="#iconExpand"></use></svg>
|
||||
|
|
@ -115,7 +117,7 @@ export class Backlink extends Model {
|
|||
<input class="b3-text-field search__label fn__none fn__size200" placeholder="${window.siyuan.languages.filterKeywordEnter}" />
|
||||
<span data-type="search" class="block__icon b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.filter}"><svg><use xlink:href='#iconFilter'></use></svg></span>
|
||||
<span class="fn__space"></span>
|
||||
<span data-type="mSort" data-sort="3" class="block__icon b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.sort}"><svg><use xlink:href='#iconSort'></use></svg></span>
|
||||
<span data-type="mSort" data-sort="${backmentionSort}" class="block__icon b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.sort}"><svg><use xlink:href='#iconSort'></use></svg></span>
|
||||
<span class="fn__space"></span>
|
||||
<span data-type="mExpand" class="block__icon b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.expand}">
|
||||
<svg><use xlink:href="#iconExpand"></use></svg>
|
||||
|
|
@ -353,6 +355,14 @@ export class Backlink extends Model {
|
|||
private showSortMenu(type: string, sort: string) {
|
||||
const clickEvent = (currentSort: string) => {
|
||||
(type === "sort" ? this.tree : this.mTree).element.previousElementSibling.querySelector(`[data-type="${type}"]`).setAttribute("data-sort", currentSort);
|
||||
// 保存排序状态到配置
|
||||
const sortValue = parseInt(currentSort);
|
||||
if (type === "sort") {
|
||||
window.siyuan.config.editor.backlinkSort = sortValue;
|
||||
} else {
|
||||
window.siyuan.config.editor.backmentionSort = sortValue;
|
||||
}
|
||||
fetchPost("/api/setting/setEditor", window.siyuan.config.editor);
|
||||
this.searchBacklinks();
|
||||
};
|
||||
window.siyuan.menus.menu.remove();
|
||||
|
|
@ -489,8 +499,8 @@ export class Backlink extends Model {
|
|||
}
|
||||
element.classList.add("fn__rotate");
|
||||
fetchPost("/api/ref/getBacklink2", {
|
||||
sort: this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').getAttribute("data-sort"),
|
||||
mSort: this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').getAttribute("data-sort"),
|
||||
sort: parseInt(this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').getAttribute("data-sort")).toString(),
|
||||
mSort: parseInt(this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').getAttribute("data-sort")).toString(),
|
||||
k: this.inputsElement[0].value,
|
||||
mk: this.inputsElement[1].value,
|
||||
id: this.blockId,
|
||||
|
|
@ -504,8 +514,8 @@ export class Backlink extends Model {
|
|||
|
||||
public saveStatus() {
|
||||
this.status[this.blockId] = {
|
||||
sort: this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').getAttribute("data-sort"),
|
||||
mSort: this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').getAttribute("data-sort"),
|
||||
sort: parseInt(this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').getAttribute("data-sort")),
|
||||
mSort: parseInt(this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').getAttribute("data-sort")),
|
||||
scrollTop: this.tree.element.scrollTop,
|
||||
mScrollTop: this.mTree.element.scrollTop,
|
||||
backlinkOpenIds: [],
|
||||
|
|
@ -582,8 +592,8 @@ export class Backlink extends Model {
|
|||
|
||||
if (!this.status[this.blockId]) {
|
||||
this.status[this.blockId] = {
|
||||
sort: "3",
|
||||
mSort: "3",
|
||||
sort: window.siyuan.config.editor.backlinkSort,
|
||||
mSort: window.siyuan.config.editor.backmentionSort,
|
||||
scrollTop: 0,
|
||||
mScrollTop: 0,
|
||||
backlinkOpenIds: [],
|
||||
|
|
@ -653,8 +663,8 @@ export class Backlink extends Model {
|
|||
layoutElement.setAttribute("aria-label", window.siyuan.languages.down);
|
||||
layoutElement.querySelector("use").setAttribute("xlink:href", "#iconDown");
|
||||
}
|
||||
this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort);
|
||||
this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort);
|
||||
this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort.toString());
|
||||
this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort.toString());
|
||||
|
||||
setTimeout(() => {
|
||||
this.tree.element.scrollTop = this.status[this.blockId].scrollTop;
|
||||
|
|
|
|||
8
app/src/types/config.d.ts
vendored
8
app/src/types/config.d.ts
vendored
|
|
@ -362,6 +362,14 @@ declare namespace Config {
|
|||
* Whether the backlink contains children
|
||||
*/
|
||||
backlinkContainChildren: boolean;
|
||||
/**
|
||||
* Backlink sort mode
|
||||
*/
|
||||
backlinkSort: number;
|
||||
/**
|
||||
* Backmention sort mode
|
||||
*/
|
||||
backmentionSort: number;
|
||||
/**
|
||||
* The maximum length of the dynamic anchor text for block references
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -520,7 +520,11 @@ func NewFormattedValueNumber(content float64, format NumberFormat) (ret *ValueNu
|
|||
}
|
||||
|
||||
func (number *ValueNumber) FormatNumber() {
|
||||
number.FormattedContent = formatNumber(number.Content, number.Format)
|
||||
if !number.IsNotEmpty {
|
||||
number.FormattedContent = ""
|
||||
} else {
|
||||
number.FormattedContent = formatNumber(number.Content, number.Format)
|
||||
}
|
||||
}
|
||||
|
||||
func formatNumber(content float64, format NumberFormat) string {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ type Editor struct {
|
|||
BacklinkExpandCount int `json:"backlinkExpandCount"` // 反向链接默认展开数量
|
||||
BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
|
||||
BacklinkContainChildren bool `json:"backlinkContainChildren"` // 反向链接是否包含子块进行计算
|
||||
BacklinkSort *int `json:"backlinkSort"` // 反向链接排序方式
|
||||
BackmentionSort *int `json:"backmentionSort"` // 反链提及排序方式
|
||||
HeadingEmbedMode int `json:"headingEmbedMode"` // 标题嵌入块模式,0:显示标题与下方的块,1:仅显示标题,2:仅显示标题下方的块
|
||||
Markdown *util.Markdown `json:"markdown"` // Markdown 配置
|
||||
}
|
||||
|
|
@ -89,6 +91,8 @@ func NewEditor() *Editor {
|
|||
BacklinkExpandCount: 8,
|
||||
BackmentionExpandCount: -1,
|
||||
BacklinkContainChildren: true,
|
||||
BacklinkSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
|
||||
BackmentionSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
|
||||
HeadingEmbedMode: 0,
|
||||
Markdown: util.MarkdownSettings,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,8 +229,17 @@ func InitConf() {
|
|||
Conf.Tag = conf.NewTag()
|
||||
}
|
||||
|
||||
defaultEditor := conf.NewEditor()
|
||||
if nil == Conf.Editor {
|
||||
Conf.Editor = conf.NewEditor()
|
||||
Conf.Editor = defaultEditor
|
||||
}
|
||||
// 新增字段的默认值
|
||||
// 使用指针类型来区分字段不存在(nil)和用户设置为 0(非 nil)
|
||||
if nil == Conf.Editor.BacklinkSort {
|
||||
Conf.Editor.BacklinkSort = defaultEditor.BacklinkSort
|
||||
}
|
||||
if nil == Conf.Editor.BackmentionSort {
|
||||
Conf.Editor.BackmentionSort = defaultEditor.BackmentionSort
|
||||
}
|
||||
if 1 > len(Conf.Editor.Emoji) {
|
||||
Conf.Editor.Emoji = []string{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue