Add a configurable Markdown link serialization policy
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start at the public blocksToMarkdownLossy entry point and trace into the lower-level Markdown exporter’s link serialization. Verify how URL-only links and separately labelled links are currently emitted. Done means an opt-in explicit style is supported, auto preserves existing output, and both link cases have coverage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What’s broken?
The Markdown exporter does not provide a public option to control how links are serialized.
When a URL-only link is created in BlockNote, blocksToMarkdownLossy may serialize it as a bare URL:
https://example.com
This is valid in GFM, but it loses the explicit distinction between ordinary text and a Markdown link. It also makes it difficult for applications to enforce a consistent Markdown export policy.
What did you expect to happen?
Applications should be able to choose whether links are serialized as:
https://example.com
or explicitly as:
[https://example.com](https://example.com)
For links with a separate label, the explicit format should remain:
[Documentation](https://example.com)
The default behavior should remain unchanged for backward compatibility.
Steps to reproduce
- Create a BlockNote editor.
- Insert a link where the displayed text is the same as the URL.
- Export the document with
blocksToMarkdownLossy. - Observe that the result may contain a bare URL instead of explicit Markdown link syntax.
Example:
const markdown = editor.blocksToMarkdownLossy(editor.document);
console.log(markdown);
Observed output:
https://example.com
Desired opt-in output:
[https://example.com](https://example.com)
BlockNote version
v0.54.0
Environment
React application, macOS
Proposed API
One possible API would be an export option:
editor.blocksToMarkdownLossy(editor.document, {
linkStyle: "explicit",
});
Possible values:
type MarkdownLinkStyle = "auto" | "explicit";
Where:
"auto"preserves the current behavior."explicit"always emits[label](url)for links.- Links with different labels continue to emit
[label](url).
The option could be exposed through the lower-level Markdown exporter API as well.
Additional context
We initially implemented an application-level HTML-to-Markdown serializer only to change this link behavior. However, that requires duplicating BlockNote’s complete Markdown serialization logic and creates compatibility and maintenance risks when BlockNote changes its exporter.
A public link serialization option or hook would allow applications to customize this behavior without forking the whole serializer.
Contribution
I’d be interested in contributing a fix for this issue.
- Ngôn ngữ chính
- TypeScript
- Star
- 10.2k
- Fork
- 772
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 17
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TypeCellOS/BlockNote
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TypeCellOS/BlockNote#3098 ·
-
Off-By-One `RangeError` Crash and Text Duplication in `StyleManager.editLink` and `deleteLink` Đang mởneeds-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TypeCellOS/BlockNote#3073 ·
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
TypeCellOS/BlockNote#3072 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TypeCellOS/BlockNote#2949 · 1 bình luận ·
-
a11y
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
TypeCellOS/BlockNote#2855 ·
Tất cả issue của TypeCellOS/BlockNote
Issue tương tự
-
Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenNSW/nsw-srilanka#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
digidem/comapeo-cloud-app#403 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100