Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2026-01-26 16:13:33 +08:00
commit e7af283cd3
18 changed files with 1995 additions and 62 deletions

2
API.md
View file

@ -1,4 +1,4 @@
[中文](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md)
[中文](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md)| [日本語](https://github.com/siyuan-note/siyuan/blob/master/API_ja_JP.md)
* [Specification](#Specification)
* [Parameters and return values](#Parameters-and-return-values)

1570
API_ja_JP.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
[English](https://github.com/siyuan-note/siyuan/blob/master/API.md)
[English](https://github.com/siyuan-note/siyuan/blob/master/API.md)| [日本語](https://github.com/siyuan-note/siyuan/blob/master/API_ja_JP.md)
* [规范](#规范)
* [参数和返回值](#参数和返回值)

View file

@ -0,0 +1,54 @@
## Overview
This version improves some details.
## Changelogs
Below are the detailed changes in this version.
### Enhancement
* [Improve "Paste as plain text" after copying PDF annotations](https://github.com/siyuan-note/siyuan/issues/11992)
* [Improve editing for nesting of callouts, lists, and headings](https://github.com/siyuan-note/siyuan/issues/12139)
* [Improve the drag handle for new windows containing multiple tabs](https://github.com/siyuan-note/siyuan/issues/12302)
* [Improve browser clipping extension for MathJax formulas](https://github.com/siyuan-note/siyuan/issues/13543)
* [New export settings: Include sub-docs, Include related docs](https://github.com/siyuan-note/siyuan/issues/13635)
* [Support exporting .sy.zip after selecting multiple documents](https://github.com/siyuan-note/siyuan/issues/14484)
* [Improve the network serve address list](https://github.com/siyuan-note/siyuan/issues/14943)
* [Improve export to Word .docx format](https://github.com/siyuan-note/siyuan/issues/14970)
* [Improve input `{{`, `/` or `#` and paste](https://github.com/siyuan-note/siyuan/issues/14972)
* [Block hyperlink supports fullscreen=1 for full-screen display](https://github.com/siyuan-note/siyuan/issues/15628)
* [Add "Remove ID from asset name" switch to export settings](https://github.com/siyuan-note/siyuan/issues/16065)
* [The image address bar is automatically converted to an asset after filling in Base64](https://github.com/siyuan-note/siyuan/issues/16132)
* [Improve Microsoft Excel Compatibility](https://github.com/siyuan-note/siyuan/pull/16338)
* [Improve image export size for database assets fields](https://github.com/siyuan-note/siyuan/issues/16470)
* [Database filtering follows search case sensitive settings](https://github.com/siyuan-note/siyuan/issues/16585)
* [Include related assets when exporting the database to CSV](https://github.com/siyuan-note/siyuan/issues/16645)
* [Supports opening the Callout dialog box using Alt+Enter](https://github.com/siyuan-note/siyuan/issues/16678)
* [Improve recent documents handling](https://github.com/siyuan-note/siyuan/pull/16727)
* [Supports MLIR code block syntax highlighting](https://github.com/siyuan-note/siyuan/issues/16824)
* [Improve the encryption verification during data synchronization](https://github.com/siyuan-note/siyuan/issues/16834)
* [Warn users about potential performance issues when running on non-SSD drives](https://github.com/siyuan-note/siyuan/issues/16835)
* [Improve macOS initialization UI and dark mode support](https://github.com/siyuan-note/siyuan/pull/16839)
* [Do not execute scripts in serving SVG by default to prevent XSS](https://github.com/siyuan-note/siyuan/issues/16844)
* [Supports setting Pandoc parameters for export docx](https://github.com/siyuan-note/siyuan/issues/16845)
* [Improve full-screen display of the editor, flashcards, and graph in browsers and PWAs](https://github.com/siyuan-note/siyuan/issues/16848)
* [Distinguishing between a referenced definition block that does not exist or one that is not indexed](https://github.com/siyuan-note/siyuan/issues/16850)
* [Built-in Pandoc export .docx template](https://github.com/siyuan-note/siyuan/issues/16861)
* [Reduce the size of desktop applications](https://github.com/siyuan-note/siyuan/pull/16866)
* [Improve caret vertical movement within table cells](https://github.com/siyuan-note/siyuan/issues/16869)
* [The size limit of inserted assets has been adjusted from 8G to 16G](https://github.com/siyuan-note/siyuan/issues/16870)
### Bugfix
* [Can not horizontal scrolling on iOS](https://github.com/siyuan-note/siyuan/issues/15333)
* [Reopen closed tab doesn't display its icon](https://github.com/siyuan-note/siyuan/issues/16810)
* [The interface freezes after performing certain operations on the data snapshot page](https://github.com/siyuan-note/siyuan/issues/16814)
* [Triple-clicking with the mouse in the editor does not select all the text](https://github.com/siyuan-note/siyuan/issues/16829)
* [Batch conversion of heading levels is not working correctly](https://github.com/siyuan-note/siyuan/issues/16852)
* [Arbitrary file reading vulnerability](https://github.com/siyuan-note/siyuan/issues/16860)
## Download
* [B3log](https://b3log.org/siyuan/en/download.html)
* [GitHub](https://github.com/siyuan-note/siyuan/releases)

View file

@ -0,0 +1,54 @@
## 概述
此版本改進了一些細節。
## 變更記錄
以下是此版本中的詳細變更。
### 改進功能
* [改進在複製 PDF 標註後「以純文字貼上」的功能](https://github.com/siyuan-note/siyuan/issues/11992)
* [改進提示、清單和標題的嵌套編輯](https://github.com/siyuan-note/siyuan/issues/12139)
* [改進包含多個頁籤的新視窗的拖曳手柄](https://github.com/siyuan-note/siyuan/issues/12302)
* [改進瀏覽器剪藏擴充功能對 MathJax 公式的支援](https://github.com/siyuan-note/siyuan/issues/13543)
* [新增匯出設定:包含子文件、包含關聯文件](https://github.com/siyuan-note/siyuan/issues/13635)
* [支援多選文件匯出 .sy.zip](https://github.com/siyuan-note/siyuan/issues/14484)
* [改進網路伺服位址清單](https://github.com/siyuan-note/siyuan/issues/14943)
* [改進匯出為 Word .docx 的功能](https://github.com/siyuan-note/siyuan/issues/14970)
* [改進輸入 `{{`、`/` 或 `#` 及貼上行為](https://github.com/siyuan-note/siyuan/issues/14972)
* [區塊超連結支援 fullscreen=1 以實現全螢幕顯示](https://github.com/siyuan-note/siyuan/issues/15628)
* [在匯出設定中新增「從資源名稱移除 ID」開關](https://github.com/siyuan-note/siyuan/issues/16065)
* [填入 Base64 後,圖片網址列會自動轉換為資源](https://github.com/siyuan-note/siyuan/issues/16132)
* [改進 Microsoft Excel 相容性](https://github.com/siyuan-note/siyuan/pull/16338)
* [改進資料庫資源欄位的圖片匯出尺寸](https://github.com/siyuan-note/siyuan/issues/16470)
* [資料庫過濾遵循搜尋的大小寫敏感設定](https://github.com/siyuan-note/siyuan/issues/16585)
* [匯出資料庫為 CSV 時包含關聯資源](https://github.com/siyuan-note/siyuan/issues/16645)
* [支援使用 Alt+Enter 開啟提示區塊對話框](https://github.com/siyuan-note/siyuan/issues/16678)
* [改進最近文件的處理](https://github.com/siyuan-note/siyuan/pull/16727)
* [支援 MLIR 程式碼區塊語法高亮](https://github.com/siyuan-note/siyuan/issues/16824)
* [改進資料同步過程中的加密校驗](https://github.com/siyuan-note/siyuan/issues/16834)
* [提示使用者在非 SSD 硬碟上執行時可能的效能問題](https://github.com/siyuan-note/siyuan/issues/16835)
* [改進 macOS 初始化介面及暗黑模式支援](https://github.com/siyuan-note/siyuan/pull/16839)
* [預設不會執行伺服的 SVG 中的腳本以防止 XSS](https://github.com/siyuan-note/siyuan/issues/16844)
* [支援為匯出 docx 設定 Pandoc 參數](https://github.com/siyuan-note/siyuan/issues/16845)
* [改進瀏覽器與 PWA 中編輯器、閃卡和關係圖的全螢幕顯示](https://github.com/siyuan-note/siyuan/issues/16848)
* [區分被引用的定義區塊是不存在還是未被索引](https://github.com/siyuan-note/siyuan/issues/16850)
* [內建 Pandoc 匯出 .docx 範本](https://github.com/siyuan-note/siyuan/issues/16861)
* [減少桌面端應用的體積](https://github.com/siyuan-note/siyuan/pull/16866)
* [改進遊標在表格單元格內的縱向移動](https://github.com/siyuan-note/siyuan/issues/16869)
* [插入資源的大小限制已從 8G 調整為 16G](https://github.com/siyuan-note/siyuan/issues/16870)
### 修復缺陷
* [iOS 上無法進行水平滾動](https://github.com/siyuan-note/siyuan/issues/15333)
* [重新開啟已關閉的頁籤時不顯示其圖示](https://github.com/siyuan-note/siyuan/issues/16810)
* [在資料快照頁面執行某些操作後介面卡死](https://github.com/siyuan-note/siyuan/issues/16814)
* [在編輯器中使用滑鼠三擊未能選取全部文字](https://github.com/siyuan-note/siyuan/issues/16829)
* [標題等級批次轉換功能異常](https://github.com/siyuan-note/siyuan/issues/16852)
* [任意檔案讀取漏洞](https://github.com/siyuan-note/siyuan/issues/16860)
## 下載
* [B3log](https://b3log.org/siyuan/download.html)
* [GitHub](https://github.com/siyuan-note/siyuan/releases)

View file

@ -0,0 +1,54 @@
## 概述
此版本改进了一些细节。
## 变更记录
以下是此版本中的详细变更。
### 改进功能
* [改进在复制 PDF 标注后“以纯文本粘贴”的功能](https://github.com/siyuan-note/siyuan/issues/11992)
* [改进提示、列表和标题的嵌套编辑](https://github.com/siyuan-note/siyuan/issues/12139)
* [改进包含多个页签的新窗口的拖拽手柄](https://github.com/siyuan-note/siyuan/issues/12302)
* [改进浏览器剪藏扩展对 MathJax 公式的支持](https://github.com/siyuan-note/siyuan/issues/13543)
* [新增导出设置:包含子文档、包含关联文档](https://github.com/siyuan-note/siyuan/issues/13635)
* [支持多选文档导出 .sy.zip](https://github.com/siyuan-note/siyuan/issues/14484)
* [改进网络伺服地址列表](https://github.com/siyuan-note/siyuan/issues/14943)
* [改进导出为 Word .docx 的功能](https://github.com/siyuan-note/siyuan/issues/14970)
* [改进输入 `{{`、`/` 或 `#` 及粘贴行为](https://github.com/siyuan-note/siyuan/issues/14972)
* [块超链接支持 fullscreen=1 以实现全屏显示](https://github.com/siyuan-note/siyuan/issues/15628)
* [在导出设置中新增“从资源名称移除 ID”开关](https://github.com/siyuan-note/siyuan/issues/16065)
* [在填入 Base64 后,图片地址栏会自动转换为资源](https://github.com/siyuan-note/siyuan/issues/16132)
* [改进 Microsoft Excel 兼容性](https://github.com/siyuan-note/siyuan/pull/16338)
* [改进数据库资源字段的图片导出尺寸](https://github.com/siyuan-note/siyuan/issues/16470)
* [数据库过滤遵循搜索的大小写敏感设置](https://github.com/siyuan-note/siyuan/issues/16585)
* [导出数据库为 CSV 时包含关联资源](https://github.com/siyuan-note/siyuan/issues/16645)
* [支持使用 Alt+Enter 打开提示块对话框](https://github.com/siyuan-note/siyuan/issues/16678)
* [改进最近文档的处理](https://github.com/siyuan-note/siyuan/pull/16727)
* [支持 MLIR 代码块语法高亮](https://github.com/siyuan-note/siyuan/issues/16824)
* [改进数据同步过程中的加密校验](https://github.com/siyuan-note/siyuan/issues/16834)
* [提示用户在非 SSD 硬盘上运行时可能的性能问题](https://github.com/siyuan-note/siyuan/issues/16835)
* [改进 macOS 初始化界面及暗黑模式支持](https://github.com/siyuan-note/siyuan/pull/16839)
* [默认情况下不执行伺服的 SVG 中的脚本以防止 XSS](https://github.com/siyuan-note/siyuan/issues/16844)
* [支持为导出 docx 设置 Pandoc 参数](https://github.com/siyuan-note/siyuan/issues/16845)
* [改进在浏览器与 PWA 中编辑器、闪卡和关系图的全屏显示](https://github.com/siyuan-note/siyuan/issues/16848)
* [区分被引用的定义块是不存在还是未被索引](https://github.com/siyuan-note/siyuan/issues/16850)
* [内置 Pandoc 导出 .docx 模板](https://github.com/siyuan-note/siyuan/issues/16861)
* [减小桌面端应用的体积](https://github.com/siyuan-note/siyuan/pull/16866)
* [改进光标在表格单元格内的纵向移动](https://github.com/siyuan-note/siyuan/issues/16869)
* [插入资源的大小限制已从 8G 调整为 16G](https://github.com/siyuan-note/siyuan/issues/16870)
### 修复缺陷
* [iOS 上无法进行水平滚动](https://github.com/siyuan-note/siyuan/issues/15333)
* [重新打开已关闭的页签时不显示其图标](https://github.com/siyuan-note/siyuan/issues/16810)
* [在数据快照页面执行某些操作后界面卡死](https://github.com/siyuan-note/siyuan/issues/16814)
* [在编辑器中使用鼠标三击未能选中全部文本](https://github.com/siyuan-note/siyuan/issues/16829)
* [标题级别批量转换功能异常](https://github.com/siyuan-note/siyuan/issues/16852)
* [任意文件读取漏洞](https://github.com/siyuan-note/siyuan/issues/16860)
## 下载
* [B3log](https://b3log.org/siyuan/download.html)
* [GitHub](https://github.com/siyuan-note/siyuan/releases)

View file

@ -1,25 +1,109 @@
function Span(el)
local style = el.attributes.style
if not style then return nil end
-- 辅助:解析颜色字符串为 6 位大写十六进制(不带 #),支持颜色名、#hex、#rgb、rgb()/rgba()
local function parse_color(s)
if not s then return nil end
s = s:gsub("%s+", "")
local lower = s:lower()
-- 1. 提取 Hex 颜色 (支持 #FFF 和 #FFFFFF)
local hex = style:match("color%s*:%s*#(%x+)")
if not hex then return nil end
if #hex == 3 then
hex = hex:sub(1,1):rep(2) .. hex:sub(2,2):rep(2) .. hex:sub(3,3):rep(2)
local named = {
red = "FF0000", blue = "0000FF", green = "008000",
yellow = "FFFF00", orange = "FFA500", purple = "800080",
black = "000000", white = "FFFFFF", gray = "808080", grey = "808080"
}
if named[lower] then return named[lower] end
-- 6-digit hex
local hex6 = s:match("#?(%x%x%x%x%x%x)")
if hex6 then return hex6:upper() end
-- 3-digit hex (#rgb -> rrggbb)
local hex3 = s:match("#?(%x%x%x)")
if hex3 then
local r = hex3:sub(1,1)
local g = hex3:sub(2,2)
local b = hex3:sub(3,3)
return (r..r..g..g..b..b):upper()
end
-- rgb(r,g,b) with integer components
local r,g,b = s:match("rgb%((%d+),(%d+),(%d+)%)")
if r and g and b then
local function h(n)
local nv = tonumber(n) or 0
if nv < 0 then nv = 0 end
if nv > 255 then nv = 255 end
return string.format("%02X", nv)
end
return h(r)..h(g)..h(b)
end
-- rgba(r,g,b,a) -> 与白(或背景)合成,返回合成后的 hex
local ra,ga,ba,aa = s:match("rgba%((%d+),(%d+),(%d+),([%d%.]+)%)")
if ra and ga and ba and aa then
local R = tonumber(ra) or 0
local G = tonumber(ga) or 0
local B = tonumber(ba) or 0
local A = tonumber(aa) or 1
if A < 0 then A = 0 end
if A > 1 then A = 1 end
local function comp(c)
local v = math.floor((A * c + (1 - A) * 255) + 0.5)
if v < 0 then v = 0 end
if v > 255 then v = 255 end
return string.format("%02X", v)
end
return comp(R)..comp(G)..comp(B)
end
return nil
end
-- 2. 提取文本内容并处理 XML 转义
-- 使用 stringify 快速获取 span 内部所有纯文本(丢弃内部嵌套样式以换取稳定性)
local txt = pandoc.utils.stringify(el.content)
txt = txt:gsub('&', '&amp;'):gsub('<', '&lt;'):gsub('>', '&gt;')
if el.attributes.style then
local style = el.attributes.style
-- 3. 构造完整的 OpenXML 运行块 (Run)
-- 这种结构 Word 识别率 100%,且不会产生标签嵌套冲突
local run_xml = string.format(
'<w:r><w:rPr><w:color w:val="%s"/></w:rPr><w:t xml:space="preserve">%s</w:t></w:r>',
hex:upper(), txt
)
local props = {}
for k, v in style:gmatch("([%w%-]+)%s*:%s*([^;]+)") do
local key = string.lower(k:gsub("^%s*(.-)%s*$", "%1"))
local val = v:gsub("^%s*(.-)%s*$", "%1")
props[key] = val
end
return pandoc.RawInline('openxml', run_xml)
end
local text_color_raw = props["color"]
local bg_color_raw = props["background-color"] or props["background"]
local text_hex = parse_color(text_color_raw)
local bg_hex = parse_color(bg_color_raw)
if text_hex or bg_hex then
-- 将 Span 的内容 stringify 为纯文本并做 XML 转义
local text = pandoc.utils.stringify(el)
local function xml_escape(s)
s = s:gsub("&", "&amp;")
s = s:gsub("<", "&lt;")
s = s:gsub(">", "&gt;")
s = s:gsub('\r\n', '\n')
s = s:gsub('\r', '\n')
s = s:gsub('"', "&quot;")
s = s:gsub("'", "&apos;")
return s
end
local need_preserve = text:match("^%s") or text:match("%s$") or text:match(" ")
local t_attr = need_preserve and ' xml:space="preserve"' or ''
local run = '<w:r><w:rPr>'
if text_hex then
run = run .. '<w:color w:val="' .. text_hex .. '"/>'
end
if bg_hex then
run = run .. '<w:shd w:val="clear" w:color="auto" w:fill="' .. bg_hex .. '"/>'
end
run = run .. '</w:rPr><w:t' .. t_attr .. '>' .. xml_escape(text) .. '</w:t></w:r>'
return { pandoc.RawInline('openxml', run) }
end
end
return el
end

View file

@ -777,7 +777,7 @@ export class Toolbar {
currentNode.textContent = currentNode.textContent.substring(1);
}
if (previousElement.textContent.endsWith(Constants.ZWSP)) {
previousElement.textContent = previousElement.textContent.substring(0, previousElement.textContent.length - 2);
previousElement.textContent = previousElement.textContent.substring(0, previousElement.textContent.length - 1);
}
} else {
const previousType = previousElement ? (previousElement.getAttribute("data-type") || "").split(" ") : [];

File diff suppressed because one or more lines are too long

View file

@ -487,7 +487,16 @@ func exportMdContent(c *gin.Context) {
imgTag = arg["imgTag"].(bool)
}
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag)
addTitle := model.Conf.Export.AddTitle
if nil != arg["addTitle"] {
if arg["addTitle"].(bool) {
addTitle = true
} else {
addTitle = false
}
}
hPath, content := model.ExportMarkdownContent(id, refMode, embedMode, yfm, fillCSSVar, adjustHeadingLevel, imgTag, addTitle)
ret.Data = map[string]interface{}{
"hPath": hPath,
"content": content,

View file

@ -379,7 +379,6 @@ func setExport(c *gin.Context) {
}
}
export.PandocParams = util.ReplaceNewline(export.PandocParams, " ")
model.Conf.Export = export
model.Conf.Save()

View file

@ -7,8 +7,8 @@ require (
github.com/88250/clipboard v0.1.5
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.20251208021445-f93f2666eaac
github.com/88250/lute v1.7.7-0.20260119115611-b18a050e4eae
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a
github.com/88250/lute v1.7.7-0.20260126044917-240e7e76b84d
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

@ -12,10 +12,10 @@ github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7 h1:MafIFwSS0x6A4
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7/go.mod h1:HrKCCTin3YNDSLBD02K0AOljjV6eNwc3/zyEI+xyV1I=
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceTVVqrYaDlLio2QSKbXMUmAZPbzCwT5eNCw=
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.20251208021445-f93f2666eaac h1:EC80pY8zyR0gbL8ZLIBB4IPG/ia3ZHScrR/xt8zU8qU=
github.com/88250/gulu v1.2.3-0.20251208021445-f93f2666eaac/go.mod h1:IQ5dXW9CjVmx6B7OfK1Y4ZBKTPMe9q1AkVoLGGzRbS8=
github.com/88250/lute v1.7.7-0.20260119115611-b18a050e4eae h1:XVdbxiLwEJQbTzkRmCNOcfshEPA060MvXvEk5j/ZPcg=
github.com/88250/lute v1.7.7-0.20260119115611-b18a050e4eae/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a h1:s86WMolaqommXG1k2vXg9Gf1iXvgtHSdeD0eeJTQVR8=
github.com/88250/gulu v1.2.3-0.20260124101918-98654a7ca98a/go.mod h1:D+Db16m0N7r9MLZCMcj1a0ZsEGQAxDZkadOn79Gh0vI=
github.com/88250/lute v1.7.7-0.20260126044917-240e7e76b84d h1:aqlQIj3Bq9o79w9VJwCs9r/eJ7oRolg2IHJxafZ6mrQ=
github.com/88250/lute v1.7.7-0.20260126044917-240e7e76b84d/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

@ -670,9 +670,11 @@ func uploadAssets2Cloud(assetPaths []string, bizType string, ignorePushMsg bool)
continue
}
msg := fmt.Sprintf(Conf.Language(27), html.EscapeString(absAsset))
util.PushStatusBar(msg)
util.PushUpdateMsg(msgId, msg, 3000)
if !ignorePushMsg {
msg := fmt.Sprintf(Conf.Language(27), html.EscapeString(absAsset))
util.PushStatusBar(msg)
util.PushUpdateMsg(msgId, msg, 3000)
}
requestResult := gulu.Ret.NewResult()
request := httpclient.NewCloudFileRequest2m()

View file

@ -773,10 +773,9 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (fullPath string,
"-f", "html+tex_math_dollars",
"--resource-path", tmpDir,
"-o", tmpDocxPath,
"--lua-filter", util.PandocColorFilterPath,
}
params := util.RemoveInvalid(Conf.Export.PandocParams)
params := util.ReplaceNewline(Conf.Export.PandocParams, " ")
if "" != params {
customArgs, parseErr := shellquote.Split(params)
if nil != parseErr {
@ -786,13 +785,36 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (fullPath string,
}
}
hasLuaFilter := false
for i := 0; i < len(args)-1; i++ {
if "--lua-filter" == args[i] {
hasLuaFilter = true
break
}
}
if !hasLuaFilter {
args = append(args, "--lua-filter", util.PandocColorFilterPath)
}
hasReferenceDoc := false
for i := 0; i < len(args)-1; i++ {
if "--reference-doc" == args[i] {
hasReferenceDoc = true
break
}
}
if !hasReferenceDoc {
args = append(args, "--reference-doc", util.PandocTemplatePath)
}
pandoc := exec.Command(Conf.Export.PandocBin, args...)
gulu.CmdAttr(pandoc)
pandoc.Stdin = bytes.NewBufferString(content)
output, err := pandoc.CombinedOutput()
if err != nil {
logging.LogErrorf("export docx failed: %s", gulu.Str.FromBytes(output))
err = errors.New(fmt.Sprintf(Conf.Language(14), gulu.Str.FromBytes(output)))
msg := gulu.DecodeCmdOutput(output)
logging.LogErrorf("export docx failed: %s", msg)
err = errors.New(fmt.Sprintf(Conf.Language(14), msg))
return
}
@ -2199,7 +2221,7 @@ func walkRelationAvs(avID string, exportAvIDs *hashset.Set) {
}
}
func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar, adjustHeadingLv, imgTag bool) (hPath, exportedMd string) {
func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar, adjustHeadingLv, imgTag, addTitle bool) (hPath, exportedMd string) {
bt := treenode.GetBlockTree(id)
if nil == bt {
return
@ -2211,7 +2233,7 @@ func ExportMarkdownContent(id string, refMode, embedMode int, addYfm, fillCSSVar
".md", refMode, embedMode, Conf.Export.FileAnnotationRefMode,
Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,
Conf.Export.BlockRefTextLeft, Conf.Export.BlockRefTextRight,
Conf.Export.AddTitle, Conf.Export.InlineMemo, nil, true, fillCSSVar, map[string]*parse.Tree{})
addTitle, Conf.Export.InlineMemo, nil, true, fillCSSVar, map[string]*parse.Tree{})
docIAL := parse.IAL2Map(tree.Root.KramdownIAL)
if addYfm {
exportedMd = yfm(docIAL) + exportedMd
@ -3400,6 +3422,11 @@ func exportPandocConvertZip(baseFolderName string, docPaths, defBlockIDs []strin
name = util.FilterFileName(name)
hPath = path.Join(dir, name)
p = hPath + ext
if 1 == len(docPaths) {
// 如果仅导出单个文档则使用文档标题作为文件名,不使用父路径 https://github.com/siyuan-note/siyuan/issues/13635#issuecomment-3794560233
p = name + ext
}
writePath := filepath.Join(exportFolder, p)
hash := fmt.Sprintf("%x", sha1.Sum([]byte(md)))
if gulu.File.IsExist(writePath) && hash != wrotePathHash[writePath] {

View file

@ -680,8 +680,19 @@ func clearOutdatedHistoryDir(historyDir string) {
logging.LogErrorf("read history dir [%s] failed: %s", dir.Name(), err)
continue
}
if dirInfo.ModTime().Unix() < ago {
removes = append(removes, filepath.Join(historyDir, dir.Name()))
continue
}
if dirName := dirInfo.Name(); len(dirName) > len("2006-01-02-150405") {
if t, parseErr := time.Parse("2006-01-02-150405", dirName[:len("2006-01-02-150405")]); nil == parseErr {
if nameTime := t.Unix(); 0 != nameTime && nameTime < ago {
removes = append(removes, filepath.Join(historyDir, dir.Name()))
continue
}
}
}
}
for _, dir := range removes {

View file

@ -66,11 +66,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
}
if len(deduplicated) <= maxCount {
// 清空 Title 和 Icon
for _, doc := range deduplicated {
doc.Title = ""
doc.Icon = ""
}
return deduplicated
}
@ -129,9 +124,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
result := make([]*RecentDoc, 0, len(docMap))
for _, doc := range docMap {
// 清空 Title 和 Icon
doc.Title = ""
doc.Icon = ""
result = append(result, doc)
}
@ -386,6 +378,11 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
bts := treenode.GetBlockTrees(rootIDs)
for _, sqlBlock := range sqlBlocks {
bt := bts[sqlBlock.ID]
if nil == bt {
continue
}
// 解析 IAL 获取 icon
icon := ""
if sqlBlock.IAL != "" {
@ -400,19 +397,7 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
}
}
// 获取文档标题
title := ""
if bt := bts[sqlBlock.ID]; nil != bt {
title = path.Base(bt.HPath)
}
if title == "" {
title = sqlBlock.Content
if title == "" {
title = sqlBlock.HPath
if title == "" {
title = sqlBlock.ID
}
}
}
title := path.Base(bt.HPath)
doc := &RecentDoc{
RootID: sqlBlock.ID,
Icon: icon,

View file

@ -91,7 +91,7 @@ func containTask(task *Task, tasks []*Task) bool {
}
for i, arg := range t.Args {
if !reflect.DeepEqual(arg, task.Args[i]) {
if !areArgsEqual(arg, task.Args[i]) {
return false
}
}
@ -101,6 +101,90 @@ func containTask(task *Task, tasks []*Task) bool {
return false
}
// areArgsEqual 比较两个参数是否相等
func areArgsEqual(a, b interface{}) bool {
// 如果两个参数都为 nil
if a == nil && b == nil {
return true
}
if a == nil || b == nil {
return false
}
// 快速处理常见的基本类型
switch av := a.(type) {
case string:
if bv, ok := b.(string); ok {
return av == bv
}
case int:
if bv, ok := b.(int); ok {
return av == bv
}
case int64:
if bv, ok := b.(int64); ok {
return av == bv
}
case int32:
if bv, ok := b.(int32); ok {
return av == bv
}
case bool:
if bv, ok := b.(bool); ok {
return av == bv
}
case float64:
if bv, ok := b.(float64); ok {
return av == bv
}
case float32:
if bv, ok := b.(float32); ok {
return av == bv
}
case uint:
if bv, ok := b.(uint); ok {
return av == bv
}
case uint64:
if bv, ok := b.(uint64); ok {
return av == bv
}
case uint32:
if bv, ok := b.(uint32); ok {
return av == bv
}
case []string:
if bv, ok := b.([]string); ok {
if len(av) != len(bv) {
return false
}
for i := range av {
if av[i] != bv[i] {
return false
}
}
return true
}
case []int:
if bv, ok := b.([]int); ok {
if len(av) != len(bv) {
return false
}
for i := range av {
if av[i] != bv[i] {
return false
}
}
return true
}
}
// 未处理的复杂类型,回退到 reflect.DeepEqual
return reflect.DeepEqual(a, b)
}
func getCurrentTasks() (ret []*Task) {
queueLock.Lock()
defer queueLock.Unlock()