Compare commits

...

4 commits

Author SHA1 Message Date
Vanessa
c150c16273 Merge remote-tracking branch 'origin/dev' into dev 2025-09-13 12:25:27 +08:00
Vanessa
9fff044869 🎨 https://github.com/siyuan-note/siyuan/issues/15839 2025-09-13 12:25:13 +08:00
Daniel
be6e92ad7a
🐛 Optimize typography exception when code block contains ``` https://github.com/siyuan-note/siyuan/issues/15843
Signed-off-by: Daniel <845765@qq.com>
2025-09-13 11:59:08 +08:00
Vanessa
bcc0472ed0 🎨 https://github.com/siyuan-note/siyuan/issues/15839 2025-09-13 11:50:13 +08:00
4 changed files with 41 additions and 18 deletions

View file

@ -335,7 +335,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
cellValue = {
type: colType,
number: {
content: null,
content: 0,
isNotEmpty: false
}
};
@ -863,6 +863,10 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
doOperations.push(...operations.doOperations);
undoOperations.push(...operations.undoOperations);
}
// formattedContent 在单元格渲染时没有用到,需对比保持一致
if (type === "date") {
cellValue.date.formattedContent = oldValue.date.formattedContent;
}
if (objEquals(cellValue, oldValue)) {
return;
}

View file

@ -2,7 +2,7 @@ import * as dayjs from "dayjs";
import {genCellValueByElement, updateCellsValue} from "./cell";
export const getDateHTML = (cellElements: HTMLElement[]) => {
const cellValue = genCellValueByElement("date", cellElements[0]).date;
const cellValue = genCellValueByElement("date", cellElements[0]).date;
const isNotTime = cellValue.isNotTime;
let value = "";
const currentDate = new Date().getTime();
@ -64,9 +64,9 @@ export const bindDateEvent = (options: {
}
if (event.key === "Enter") {
updateCellsValue(options.protyle, options.blockElement as HTMLElement, {
content: getFullYearTime(inputElements[0].dataset.value),
content: getFullYearTime(inputElements[0].dataset.value) || 0,
isNotEmpty: inputElements[0].value !== "",
content2: getFullYearTime(inputElements[1].dataset.value),
content2: getFullYearTime(inputElements[1].dataset.value) || 0,
isNotEmpty2: inputElements[1].value !== "",
hasEndDate: inputElements[2].checked,
isNotTime: !inputElements[3].checked,
@ -114,9 +114,9 @@ export const bindDateEvent = (options: {
});
return () => {
updateCellsValue(options.protyle, options.blockElement as HTMLElement, {
content: getFullYearTime(inputElements[0].dataset.value),
content: getFullYearTime(inputElements[0].dataset.value) || 0,
isNotEmpty: inputElements[0].value !== "",
content2: getFullYearTime(inputElements[1].dataset.value),
content2: getFullYearTime(inputElements[1].dataset.value) || 0,
isNotEmpty2: inputElements[1].value !== "",
hasEndDate: inputElements[2].checked,
isNotTime: !inputElements[3].checked,

View file

@ -39,7 +39,7 @@ import {
openViewMenu
} from "./view";
import {focusBlock} from "../../util/selection";
import {setPageSize} from "./row";
import {getFieldIdByCellElement, setPageSize} from "./row";
import {bindRelationEvent, getRelationHTML, openSearchAV, setRelationCell, updateRelation} from "./relation";
import {bindRollupData, getRollupHTML, goSearchRollupCol} from "./rollup";
import {updateCellsValue} from "./cell";
@ -157,7 +157,18 @@ export const openMenuPanel = (options: {
const menuElement = avPanelElement.lastElementChild as HTMLElement;
let tabRect = options.blockElement.querySelector(`.av__views, .av__row[data-col-id="${options.colId}"] > .block__logo`)?.getBoundingClientRect();
if (["select", "date", "asset", "relation", "rollup"].includes(options.type)) {
const cellRect = options.cellElements[options.cellElements.length - 1].getBoundingClientRect();
let lastElement = options.cellElements[options.cellElements.length - 1];
if (!options.blockElement.contains(lastElement)) {
// https://github.com/siyuan-note/siyuan/issues/15839
const rowID = getFieldIdByCellElement(lastElement, data.viewType);
if (data.viewType === "table") {
lastElement = options.blockElement.querySelector(`.av__row[data-id="${rowID}"] .av__cell[data-col-id="${lastElement.dataset.colId}"]`);
} else {
lastElement = options.blockElement.querySelector(`.av__gallery-item[data-id="${rowID}"] .av__cell[data-field-id="${lastElement.dataset.fieldId}"]`);
}
}
const cellRect = (lastElement || options.cellElements[options.cellElements.length - 1]).getBoundingClientRect();
if (options.type === "select") {
bindSelectEvent(options.protyle, data, menuElement, options.cellElements, options.blockElement);
} else if (options.type === "date") {
@ -1201,10 +1212,10 @@ export const openMenuPanel = (options: {
title: isTwoWay ? window.siyuan.languages.removeColConfirm : window.siyuan.languages.deleteOpConfirm,
content: `<div class="b3-dialog__content">
${isTwoWay ? window.siyuan.languages.confirmRemoveRelationField
.replace("${x}", menuElement.querySelector("input").value || window.siyuan.languages._kernel[272])
.replace("${y}", menuElement.querySelector('.b3-menu__item[data-type="goSearchAV"] .b3-menu__accelerator').textContent)
.replace("${z}", (menuElement.querySelector('input[data-type="colName"]') as HTMLInputElement).value || window.siyuan.languages._kernel[272])
: window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value || window.siyuan.languages._kernel[272])}
.replace("${x}", menuElement.querySelector("input").value || window.siyuan.languages._kernel[272])
.replace("${y}", menuElement.querySelector('.b3-menu__item[data-type="goSearchAV"] .b3-menu__accelerator').textContent)
.replace("${z}", (menuElement.querySelector('input[data-type="colName"]') as HTMLInputElement).value || window.siyuan.languages._kernel[272])
: window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value || window.siyuan.languages._kernel[272])}
<div class="fn__hr--b"></div>
<button class="fn__block b3-button b3-button--remove" data-action="delete">${isTwoWay ? window.siyuan.languages.removeBothRelationField : window.siyuan.languages.delete}</button>
<div class="fn__hr"></div>

View file

@ -17,7 +17,10 @@
package model
import (
"bytes"
"github.com/88250/lute/ast"
"github.com/88250/lute/editor"
"github.com/88250/lute/render"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
@ -37,13 +40,18 @@ func AutoSpace(rootID string) (err error) {
generateOpTypeHistory(tree, HistoryOpFormat)
luteEngine := NewLute()
// 合并相邻的同类行级节点
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if entering {
switch n.Type {
case ast.NodeTextMark:
luteEngine.MergeSameTextMark(n)
}
if !entering {
return ast.WalkContinue
}
switch n.Type {
case ast.NodeTextMark:
luteEngine.MergeSameTextMark(n) // 合并相邻的同类行级节点
case ast.NodeCodeBlockCode:
// 代码块中包含 ``` 时 `优化排版` 异常 `Optimize typography` exception when code block contains ``` https://github.com/siyuan-note/siyuan/issues/15843
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(editor.Zwj+"```"), []byte("```"))
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("```"), []byte(editor.Zwj+"```"))
}
return ast.WalkContinue
})