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

feat: Add language support & fix: Tooltip now hides when scrolling to… #305

Merged
merged 4 commits into from
Mar 3, 2024

Conversation

zhuozhiyongde
Copy link
Collaborator

… bottom

Description

Linked Issues

Additional context

@zhuozhiyongde zhuozhiyongde requested a review from Innei March 3, 2024 11:45
@zhuozhiyongde
Copy link
Collaborator Author

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:

image

@Innei
Copy link
Owner

Innei commented Mar 3, 2024

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:

image

有啥想法

Copy link

github-actions bot commented Mar 3, 2024

📦 Next.js Bundle Analysis for Shiro

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 84.61 KB (🟡 +71 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@zhuozhiyongde
Copy link
Collaborator Author

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:
image

有啥想法

我不太知道怎么在这里拿到行数,没有深入研究过 shiki(

@zhuozhiyongde
Copy link
Collaborator Author

另外还有一点,就是我感觉现在的语言格式很奇怪,为什么不直接全部切换到shiki呢?shiki对于不认的语言是直接按照 text 来渲染的,我觉得也可以接受?还是说有保留现有 code highlighter 的必要?

Copy link

github-actions bot commented Mar 3, 2024

📦 Next.js Bundle Analysis for Shiro

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 84.61 KB (🟡 +69 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@Innei
Copy link
Owner

Innei commented Mar 3, 2024

另外还有一点,就是我感觉现在的语言格式很奇怪,为什么不直接全部切换到shiki呢?shiki对于不认的语言是直接按照 text 来渲染的,我觉得也可以接受?还是说有保留现有 code highlighter 的必要?

shiki对于不认的语言 会报错

@Innei
Copy link
Owner

Innei commented Mar 3, 2024

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:
image

有啥想法

我不太知道怎么在这里拿到行数,没有深入研究过 shiki(

你是说拿到总行数吗?

@zhuozhiyongde
Copy link
Collaborator Author

zhuozhiyongde commented Mar 3, 2024

另外还有一点,就是我感觉现在的语言格式很奇怪,为什么不直接全部切换到shiki呢?shiki对于不认的语言是直接按照 text 来渲染的,我觉得也可以接受?还是说有保留现有 code highlighter 的必要?

shiki对于不认的语言 会报错

shikijs/shiki#534

按照我的理解,不应该报错啊(?

@zhuozhiyongde
Copy link
Collaborator Author

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:
image

有啥想法

我不太知道怎么在这里拿到行数,没有深入研究过 shiki(

你是说拿到总行数吗?

yes,拿到总行数之后做个特判

Copy link

github-actions bot commented Mar 3, 2024

📦 Next.js Bundle Analysis for Shiro

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 84.61 KB (🟡 +72 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@Innei
Copy link
Owner

Innei commented Mar 3, 2024

@zhuozhiyongde

顺带提一个bug:当只有一行的时候现在的复制块显示的有些问题,但我不知道怎么修,抱歉:
image

有啥想法

我不太知道怎么在这里拿到行数,没有深入研究过 shiki(

你是说拿到总行数吗?

yes,拿到总行数之后做个特判

value.split('\n').length

@zhuozhiyongde
Copy link
Collaborator Author

value.split('\n').length

草 有点太简陋了吧,那万一我字符串里面有 \n 呢?有没有基于 Shiki 解析出的方法呢,或者干脆直接所有的都调成符合第一行的状态?

@zhuozhiyongde
Copy link
Collaborator Author

按照 Shiki 官方的,就是单行渲染和多行相同,没做特判:

image

@zhuozhiyongde
Copy link
Collaborator Author

zhuozhiyongde commented Mar 3, 2024

关于最新 CSS 修改说明如下:

  • 调整层级结构,扩展代码块基础高度,使得单行足以容纳复制按键,然后使用 calc 来居中对齐;
    image

  • 修改了两处 z-index,使得代码语言/文件信息提示在横向滚动条之上:
    image

这是一个临时解决方案,我认为似乎还是把这个语言/文件类型的元信息提到上方是一个比较好的解决方案,不然还得计算一下 bg-accent/10 这个属性的完整 RGB 值(不含 Alpha 通道),才能避免这个滚动条处的层叠。(如果调整 padding/margin,会导致单行空余太多?)like shiki official:

image

Copy link

github-actions bot commented Mar 3, 2024

📦 Next.js Bundle Analysis for Shiro

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 84.61 KB (🟡 +69 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

@zhuozhiyongde zhuozhiyongde requested a review from Innei March 3, 2024 14:34
@Innei
Copy link
Owner

Innei commented Mar 3, 2024

之后我再调吧, 大佬tql

@Innei Innei merged commit 0761eaa into main Mar 3, 2024
2 checks passed
@zhuozhiyongde
Copy link
Collaborator Author

另外想问下:

          className={clsxm(
            'pointer-events-none absolute bottom-2 right-2 z-10 text-sm opacity-60',
            isOverflow ? 'right-6' : '',
          )}

这段代码的意义?这会导致不对齐啊:

image

@zhuozhiyongde
Copy link
Collaborator Author

之后我再调吧, 大佬tql

呜呜,您才是佬,我是只会写 css 的小菜鸡,大佬多教教我()

@Innei
Copy link
Owner

Innei commented Mar 3, 2024

另外想问下:

          className={clsxm(
            'pointer-events-none absolute bottom-2 right-2 z-10 text-sm opacity-60',
            isOverflow ? 'right-6' : '',
          )}

这段代码的意义?这会导致不对齐啊:

image

因为之前有滚条,所以加了偏移,现在我去掉了就不需要这个了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants