Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

粘贴代码块的时候代码块格式丢失 #5736

Closed
ry0513 opened this issue Apr 18, 2024 · 4 comments · Fixed by #5737
Closed

粘贴代码块的时候代码块格式丢失 #5736

ry0513 opened this issue Apr 18, 2024 · 4 comments · Fixed by #5737
Assignees
Labels
area/editor Issues or PRs related to the Editor kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@ry0513
Copy link

ry0513 commented Apr 18, 2024

系统信息

  • 启动时间: 2024-04-01 09:07
  • 版本: 2.13.1
  • 构建时间: 2024-03-06 17:40
  • Git Commit: 9473261
  • Java: IBM Semeru Runtime Open Edition / 21.0.2+13-LTS
  • 数据库: MySQL Community Server - GPL / 8.2.0
  • 操作系统: Linux / 6.6.13+bpo-cloud-amd64
  • 已激活主题: Earth
  • 已启动插件:

使用的哪种方式运行?

Docker

发生了什么?

我在写文章,当直接粘贴代码的时候,会保留代码块格式,当我写完一段话后回车再粘贴代码会出现代码块格式消失的问题,这个问题在 tiptap 官方demo中也会复现,疑似 tiptap 的问题

相关日志输出

No response

附加信息

2024-04-10.140202_out.mp4
@LIlGG
Copy link
Member

LIlGG commented Apr 18, 2024

感谢反馈,测试了一下,确实会出现这样的问题。

/kind bug
/area editor

@f2c-ci-robot f2c-ci-robot bot added kind/bug Categorizes issue or PR as related to a bug. area/editor Issues or PRs related to the Editor labels Apr 18, 2024
@ry0513
Copy link
Author

ry0513 commented Apr 18, 2024

感谢反馈,测试结论,确实会出现这样的问题。

/kind bug /区域编辑器

可以参考一下这个
ueberdosis/tiptap#3606

@LIlGG
Copy link
Member

LIlGG commented Apr 18, 2024

可以参考一下这个 ueberdosis/tiptap#3606

感谢,看了一下确实与这个问题相关。但此 PR 已经很久没有处理了,因此我会拷贝一份 Code-Block 相关代码并在 Halo 这边进行处理。

/assign

@LIlGG
Copy link
Member

LIlGG commented Apr 18, 2024

/milestone 2.15.x

@f2c-ci-robot f2c-ci-robot bot added this to the 2.15.x milestone Apr 18, 2024
f2c-ci-robot bot pushed a commit that referenced this issue Apr 18, 2024
#### What type of PR is this?

/kind bug
/area editor
/milestone 2.15.x

#### What this PR does / why we need it:

在编写多行文本后,粘贴代码块时,会出现粘贴的内容插入错误,其与代码块分割开。

[例如 #5736 中的示例所示](https://github.com/halo-dev/halo/assets/44745967/4b1ef8dc-60bf-47fd-b64d-23b0d6537d9e)

在本 PR 中,在创建 CodeBlock 时,将 Text 转为 `TextNode` 后,一同传入作为 `CodeBlock` 的 content。
另外为了保证插入代码块之后,光标处于代码块中,将会从插入位置的 from 开始往文档顶部搜索。

#### How to test it?

测试示例中的场景下,代码块插入是否正常。

测试在代码块前后放入其他代码块或者其他块,插入代码块后光标是否在代码块中。

#### Which issue(s) this PR fixes:

Fixes #5736 

#### Does this PR introduce a user-facing change?
```release-note
修复默认编辑器中粘贴代码块会出现错行的问题
```
@ruibaby ruibaby modified the milestones: 2.15.x, 2.15.0 Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/editor Issues or PRs related to the Editor kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants