mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-06-28 06:46:12 +00:00
* feat: auto-convert pasted URL to clickable link format (#17337) Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/cdea999d-27c0-4260-a0b4-519e011e6667 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * fix: use angle bracket URL syntax for markdown link safety Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/cdea999d-27c0-4260-a0b4-519e011e6667 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * feat: add pasteURLAutoConvert editor setting to control URL auto-linking Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/1b722c05-e69f-4964-89bb-7f928d5adeb3 Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * refactor: reuse setInlineMark for paste URL auto-convert, matching Ctrl+K link handler pattern Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/332d1b44-cebe-45b2-833e-72d7e3253a3d Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * refactor: extract shared resolveLinkDest and genLinkText utility functions Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/316f674d-3ce9-4b40-8711-08edb8af1aec Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * Disable automatic URL conversion on paste * feat: add stripScheme option to genLinkText - keep scheme for paste, strip for Ctrl+K Agent-Logs-Url: https://github.com/bytemain/siyuan/sessions/960eaf33-f873-4709-8e63-8d9b473de4ee Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com> * Improve link handling in paste function Refactor link handling in paste function to update range after setting inline mark. * Fix return statement in paste.ts * style: fix json tag alignment in Editor struct * Update app/src/mobile/settings/editor.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(Link): handle URI decoding more safely in genLinkText Add try-catch block to prevent URI decoding errors and make decoding optional * feat(editor): add auto URL to link conversion on paste Implement automatic conversion of pasted URLs to clickable links when the pasteURLAutoConvert setting is enabled. This improves user experience by eliminating the manual step of creating links for pasted URLs. The functionality is extracted into a separate function for better code organization and reuse. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
108 lines
7.5 KiB
Go
108 lines
7.5 KiB
Go
// SiYuan - Refactor your thinking
|
||
// Copyright (c) 2020-present, b3log.org
|
||
//
|
||
// This program is free software: you can redistribute it and/or modify
|
||
// it under the terms of the GNU Affero General Public License as published by
|
||
// the Free Software Foundation, either version 3 of the License, or
|
||
// (at your option) any later version.
|
||
//
|
||
// This program is distributed in the hope that it will be useful,
|
||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
// GNU Affero General Public License for more details.
|
||
//
|
||
// You should have received a copy of the GNU Affero General Public License
|
||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
package conf
|
||
|
||
import "github.com/siyuan-note/siyuan/kernel/util"
|
||
|
||
type Editor struct {
|
||
AllowSVGScript bool `json:"allowSVGScript"` // 允许执行 SVG 内脚本
|
||
AllowHTMLBLockScript bool `json:"allowHTMLBLockScript"` // 允许执行 HTML 块内脚本
|
||
FontSize int `json:"fontSize"` // 字体大小
|
||
FontSizeScrollZoom bool `json:"fontSizeScrollZoom"` // 字体大小是否支持滚轮缩放
|
||
FontFamily string `json:"fontFamily"` // 字体
|
||
CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"` // 代码块是否显示行号
|
||
CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
|
||
CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
|
||
CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
|
||
DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标
|
||
DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
|
||
GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟
|
||
HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数
|
||
Emoji []string `json:"emoji"` // 常用表情
|
||
VirtualBlockRef bool `json:"virtualBlockRef"` // 是否启用虚拟引用
|
||
VirtualBlockRefExclude string `json:"virtualBlockRefExclude"` // 虚拟引用关键字排除列表
|
||
VirtualBlockRefInclude string `json:"virtualBlockRefInclude"` // 虚拟引用关键字包含列表
|
||
BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen"` // 块引动态锚文本最大长度
|
||
PlantUMLServePath string `json:"plantUMLServePath"` // PlantUML 伺服地址
|
||
FullWidth bool `json:"fullWidth"` // 是否使用最大宽度
|
||
KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
|
||
ReadOnly bool `json:"readOnly"` // 只读模式
|
||
EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
|
||
ListLogicalOutdent bool `json:"listLogicalOutdent"` // 列表逻辑反向缩进
|
||
ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus"` // 单击列表项标记聚焦
|
||
FloatWindowMode int `json:"floatWindowMode"` // 浮窗触发模式,0:光标悬停,1:按住 Ctrl 悬停,2:不触发浮窗
|
||
FloatWindowDelay *int `json:"floatWindowDelay"` // 浮窗悬停触发延迟,单位:毫秒,默认 620,nil 表示未设置
|
||
DynamicLoadBlocks int `json:"dynamicLoadBlocks"` // 块动态数,可配置区间 [48, 1024]
|
||
Justify bool `json:"justify"` // 是否两端对齐
|
||
RTL bool `json:"rtl"` // 是否从右到左显示
|
||
Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查
|
||
SpellcheckLanguages []string `json:"spellcheckLanguages"` // 拼写检查语言
|
||
OnlySearchForDoc bool `json:"onlySearchForDoc"` // 是否启用 [[ 仅搜索文档块
|
||
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:仅显示标题下方的块
|
||
PasteURLAutoConvert bool `json:"pasteURLAutoConvert"` // 粘贴网址时自动转为链接
|
||
Markdown *util.Markdown `json:"markdown"` // Markdown 配置
|
||
}
|
||
|
||
const (
|
||
MinDynamicLoadBlocks = 48
|
||
)
|
||
|
||
func NewEditor() *Editor {
|
||
return &Editor{
|
||
FontSize: 16,
|
||
FontSizeScrollZoom: false,
|
||
CodeSyntaxHighlightLineNum: false,
|
||
CodeTabSpaces: 0,
|
||
CodeLineWrap: false,
|
||
CodeLigatures: false,
|
||
DisplayBookmarkIcon: true,
|
||
DisplayNetImgMark: true,
|
||
GenerateHistoryInterval: 10,
|
||
HistoryRetentionDays: 30,
|
||
Emoji: []string{},
|
||
VirtualBlockRef: false,
|
||
BlockRefDynamicAnchorTextMaxLen: 96,
|
||
PlantUMLServePath: "https://www.plantuml.com/plantuml/svg/~1",
|
||
FullWidth: true,
|
||
KaTexMacros: "{}",
|
||
ReadOnly: false,
|
||
EmbedBlockBreadcrumb: false,
|
||
ListLogicalOutdent: false,
|
||
ListItemDotNumberClickFocus: true,
|
||
FloatWindowMode: 0,
|
||
FloatWindowDelay: func() *int { v := 620; return &v }(),
|
||
DynamicLoadBlocks: 192,
|
||
Justify: false,
|
||
RTL: false,
|
||
Spellcheck: false,
|
||
SpellcheckLanguages: []string{"en-US"},
|
||
BacklinkExpandCount: 8,
|
||
BackmentionExpandCount: -1,
|
||
BacklinkContainChildren: true,
|
||
BacklinkSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
|
||
BackmentionSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
|
||
HeadingEmbedMode: 0,
|
||
PasteURLAutoConvert: false,
|
||
Markdown: util.MarkdownSettings,
|
||
}
|
||
}
|