Skip to content

Commit 778e448

Browse files
authored
merge: fix: Issues fixes and doc improvements.
- fix: Fix fenced code block horizontal scrolling issues. - doc: Update a bunch of docs, fix some typo issues.
2 parents 1c7a514 + c4e1375 commit 778e448

File tree

5 files changed

+57
-20
lines changed

5 files changed

+57
-20
lines changed

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# LiteLoaderQQNT-Markdown
22

3-
![GitHub Release](https://img.shields.io/github/v/release/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&logo=github) ![GitHub License](https://img.shields.io/github/license/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&color=blue) ![GitHub last commit](https://img.shields.io/github/last-commit/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&logo=github)
4-
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&color=rgb(50%2C180%2C50))
3+
[![GitHub Release](https://img.shields.io/github/v/release/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&logo=github)](https://github.com/Ikaleio/LiteLoaderQQNT-Markdown/releases)
4+
[![GitHub License](https://img.shields.io/github/license/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&color=blue)](https://github.com/Ikaleio/LiteLoaderQQNT-Markdown/blob/v4/LICENSE)
5+
[![GitHub last commit](https://img.shields.io/github/last-commit/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&logo=github)](https://github.com/Ikaleio/LiteLoaderQQNT-Markdown/commits/v4/)
6+
[![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/d0j1a1701/LiteLoaderQQNT-Markdown?style=for-the-badge&color=rgb(50%2C180%2C50))](https://github.com/Ikaleio/LiteLoaderQQNT-Markdown/issues)
57

68

79
## 简介
@@ -110,6 +112,17 @@ Normal test with HTML Entities & " ' < > .
110112

111113
如果在使用插件时遇到问题,您可以通过 [发起 Issue](https://github.com/d0j1a1701/LiteLoaderQQNT-Markdown/issues/new) 向我们进行反馈。届时请尽可能附上诸如系统版本,插件列表, LiteLoaderQQNT 设置页版本信息截图等可以帮助分析问题的信息。如果你还安装了远程调试插件,可以再附上 Devtools 信息。
112114

115+
## Contributors
116+
117+
[![](https://contrib.rocks/image?repo=Ikaleio/LiteLoaderQQNT-Markdown)](https://github.com/Ikaleio/LiteLoaderQQNT-Markdown/graphs/contributors)
118+
119+
## Star History
120+
121+
![Stargazers over time](https://starchart.cc/Ikaleio/LiteLoaderQQNT-Markdown.svg?variant=adaptive)
122+
123+
124+
如果您觉得本项目对您有帮助,可以帮忙点一下Star,谢谢!
125+
113126
## Contributing
114127

115-
如果您想要为本项目贡献代码,或者想了解本项目的代码相关细节,欢迎阅读 [项目开发文档](/docs/dev/renderer.md)
128+
如果您想要为本项目贡献代码,或者想了解本项目的代码相关细节,欢迎阅读 [项目开发文档](/docs/dev/renderer.md)

docs/dev/msg_rendering_process.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,32 @@
99

1010
# Workflow
1111

12-
Currently the plugin does NOT rendering all content inside a message box. We only deal with contents that may need go through the markdown renderer. Also, since some element should NOT be considered as Markdown when rendering and should keep what it look like throughout the rendering, we introduced the concept of **Fragement Processor**(FragProcessor).
12+
Currently the plugin does NOT rendering all content inside a message box. We only deal with contents that may need go through the markdown renderer. Also, since some element should NOT be considered as Markdown when rendering and should keep what it look like throughout the rendering, we introduced the concept of **Fragment Processor** _(FragProcessor)_.
1313

1414
## Fragments
1515

16-
As you see, we **consider the `childern` of the message box as a "fragment"**. Then we have **a list of `FragProcessor`, each takes in charge of render a certain type of fragments**.
16+
When dealing with QQNT messages, we considered a message `span` as a basic rendering unit. A general QQNT message HTML element has the folloing structure:
17+
18+
```
19+
- span.mix-message__inner
20+
- span.text_element
21+
- span / p / ...
22+
- span.text_element_at
23+
- span.other_element
24+
```
25+
26+
In conclusion:
27+
28+
- A `span.mix-message__inner` is related to a single message box, we will use `msgBox` to refer to it below.
29+
- A `msgBox` could have multiple `span.*_element_*` span, which's classname indictas the content type of this span, for example, a pure text, an emoji or a image etc.
30+
31+
Here, we **consider the `span` children of the msgBox as the "fragments" of this message**. Then we have **a list of `FragProcessor`, each takes in charge of catching and rendering a certain type of fragments**.
32+
33+
For example, we could have:
34+
35+
- `TextFragProcessor` who deal with `span.text-element` fragments.
36+
- `EmojiFragProcessor` who deal with emoji info in fragments.
37+
- ...
1738

1839
## Fragment Processor
1940

@@ -27,7 +48,7 @@ type FragmentProcessFunc = (
2748
) => FragmentProcessFuncRetType | undefined;
2849
```
2950

30-
When `render()` function is triggered, a provided list of Fragment Processor will be iterated from begin to end **respectively and preemptively**.
51+
When `render()` function is triggered, for **each fragment** in each message, a **provided list of Fragment Processor** will be iterated from begin to end **respectively and preemptively**.
3152

3253
This means, for a single fragment, once a processor successfully returned a not `undefined` value *(actually it should be `FragmentProcessFuncRetType` obejct)*, the loop is end and the return value is used for this fragment.
3354

@@ -46,7 +67,7 @@ interface FragmentProcessFuncRetType {
4667

4768
As you see, it specified the `original` SPAN element, and a new `rendered` element. For now, we just replace the `original` child of `messageBox` with `rendered`.
4869

49-
> **Notice**
70+
> [!note]
5071
>
5172
> Keep in mind that the `original` HTML element passed to Fragment Processor could be directly updated.
5273
>
@@ -87,4 +108,4 @@ For more info about the process, check out source code file:
87108

88109
For outdated doc:
89110

90-
- [Message Rendering Process Doc 2.3.5](./msg_rendering_process_2.3.5.md)
111+
- [Message Rendering Process Doc 2.3.5](./msg_rendering_process_2.3.5.md)

docs/known_issue.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
This document is used to record some Known Issue of this plugin.
22

3-
# Compatability Issue With Other Plugin
4-
5-
Currently we found that sometimes it would cause incorrect rendering behaviour when using this plugin with `LiteTools`(another QQNT plugin). And user may experience:
6-
7-
- Incorrect LiteTools Slot rendering position. For example, the *Message Send Time* and *Withdrawed* slot may be rendered with incorrect position / alignment.
8-
9-
Currently the workaround for the LiteTool Time slot is to use JavaScript to observe the `offsetHeight` of each message box. If it over a specific value, we consider this message a multiple-line message and set the `flex-direction: column` to the root message box, otherwise set `flex-direction: row`.
10-
11-
This require change message box div into `flex` which may cause other rendering issue, and this workaround should be replaced by a better solution.
12-
133
# Post Rendering Function Exec Order Issue
144

155
Currently, we call `renderSingleMsgBox()` function inside `render()`, then after we call some post-rendering functions, the whole process is like:
@@ -26,4 +16,4 @@ elementDebugLogger();
2616

2717
However the issue is the *MarkdownIt* render function returns Promise, so the `renderSingleMsgBox()` is an async function. And so, the post-rendering function below actually may run first while the message is not fully rendererd.
2818

29-
Currently we do NOT implement any workaround on this since the test show this issue don't affect the rendering result for now. However this is something that should be fixed in the future.
19+
Currently we do NOT implement any workaround on this since the test show this issue don't affect the rendering result for now. However this is something that should be fixed in the future.

src/components/code_block.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function HighLightedCodeBlock({ content, lang, markdownItIns }) {
3333
mditLogger('error', `hljs error:`, e);
3434
}
3535

36-
return (<pre className='hljs hl-code-block'>
36+
return (<pre className='hljs hl-code-block mdit-fenced-code-block'>
3737
<button className='lang_copy'>
3838
<p className='lang'>{lang}</p>
3939
<p className='copy'>复制</p>

src/style/markdown.css

+13
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,17 @@ button.mdit-show-origin-button {
193193
padding-inline: 2px;
194194
/* text-underline: auto; */
195195
border-width: 0px;
196+
}
197+
198+
pre.mdit-fenced-code-block>code {
199+
width: 100%;
200+
display: block;
201+
overflow-y: auto;
202+
scrollbar-width: thin;
203+
}
204+
205+
@media (prefers-color-scheme: dark) {
206+
pre.mdit-fenced-code-block>code {
207+
color-scheme: dark;
208+
}
196209
}

0 commit comments

Comments
 (0)