Skip to content

Improve pasting link#17378

Merged
Vanessa219 merged 9 commits intosiyuan-note:devfrom
bytemain:feat/optimize-pasting-link
Apr 6, 2026
Merged

Improve pasting link#17378
Vanessa219 merged 9 commits intosiyuan-note:devfrom
bytemain:feat/optimize-pasting-link

Conversation

@bytemain
Copy link
Copy Markdown
Member

@bytemain bytemain commented Apr 1, 2026

Adjust paste link logic

Description / 描述

修复粘贴多个 link 时不生效的问题

Type of change / 变更类型

  • Bug fix
    缺陷修复
  • Refactoring
    代码重构
  • New feature
    新功能
  • Text updates or new language additions
    修改文案或增加新语言

Checklist / 检查清单

  • I have performed a self-review of my own code
    我对自己的代码进行了自我审查
  • I have full rights to the submitted code and agree to license it under this project's AGPL-3.0 license
    我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
  • PR is submitted to the dev branch and has no merge conflicts
    PR 提交到 dev 分支,并且没有合并冲突

bytemain added 4 commits April 1, 2026 12:21
- Extract URL to link conversion into separate function for better maintainability
- Simplify pasteAsLink by removing multi-line handling and using single logic
- Move URL auto-conversion check before pasteAsLink for proper processing order
Remove convertUrlsToLinks function and improve pasteAsLink to handle text segments more efficiently. The new implementation processes text and links separately while maintaining whitespace and only converts valid URLs to links.
@88250 88250 requested a review from Vanessa219 April 1, 2026 04:32
@88250 88250 added this to the 3.6.3 milestone Apr 1, 2026
@88250 88250 mentioned this pull request Apr 1, 2026
7 tasks
@Vanessa219
Copy link
Copy Markdown
Member

在块中复制这一行会丢失粗体,
在 github 中复制这一行 星号会保留,不会变为粗体。
请继续修改。

https://github.com/siyuan-note/siyuan/pull/17348  **9**  https://github.com/siyuan-note/siyuan/pull/17348

@bytemain
Copy link
Copy Markdown
Member Author

bytemain commented Apr 1, 2026

感觉要处理这个第二种情况,要去改 protyle.lute.Md2BlockDOM 比较好,我在上游改一下这个 case 吧,还是要从 markdown ast 去处理才行

@bytemain
Copy link
Copy Markdown
Member Author

bytemain commented Apr 1, 2026

依赖上游 PR: 88250/lute#226

@88250 88250 modified the milestones: 3.6.3, 3.6.4 Apr 2, 2026
88250 added a commit that referenced this pull request Apr 2, 2026
Signed-off-by: Daniel <845765@qq.com>
@88250
Copy link
Copy Markdown
Member

88250 commented Apr 2, 2026

最新的 lute 已经合并到 dev 分支了。

bytemain added 3 commits April 2, 2026 13:57
Add new method Md2BlockDOMWithAutoLink to Lute interface and implement auto URL conversion based on editor configuration. This addresses the feature request for automatically converting pasted URLs to links.
… conversion

Simplify link handling during paste by leveraging lute's built-in auto link conversion functionality instead of maintaining a separate implementation. This change improves maintainability and reduces code duplication.
@bytemain bytemain marked this pull request as ready for review April 2, 2026 12:26
@bytemain
Copy link
Copy Markdown
Member Author

bytemain commented Apr 2, 2026

@Vanessa219 麻烦再看看,基于 lute 的转换表现的很好:
CleanShot 2026-04-02 at 20 28 28@2x

Ensure link conversion is applied to the correct processed content by moving it after HTML unescaping
uuhan pushed a commit to uuhan/siyuan that referenced this pull request Apr 3, 2026
Signed-off-by: Daniel <845765@qq.com>
The conditional logic for auto-link conversion during paste was incorrectly applied. The code previously skipped auto-link conversion for block types, but the condition was reversed. Since block types should not have auto-link conversion, the condition has been removed entirely to align with the intended behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants