Skip to content

Conversation

@YDX-2147483647
Copy link
Member

@YDX-2147483647 YDX-2147483647 commented Oct 13, 2025

Note

This PR is ready for review, although not finished yet.

I have left four three TODOs in the files: two Japanese translations, and a possible upstream bug. and a place needing a design decision

Changes:

All changes are compatible with both v0.13.1 and v0.14.0-rc.1 formats.

Relates-to: #15


To review this PR, I recommend checking the page /docs/reference/layout/place/ (official v0.14.0-rc.1 / official v0.13.1 / jp / PR preview).
This page covers most complexities — place.dx has an example mixed in the content, place.scope is a string parameter, and place.flush is a scoped definition.

Better review it commit by commit.

If you find it really hard to review such a big PR, I can split it.
However, since these changes are inherently coupled, splitting might make the main branch broken after merging some but not all of the PRs.

Besides, I suggest reviewing and merging #16 first.

@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review October 13, 2025 09:32
@YDX-2147483647 YDX-2147483647 marked this pull request as draft October 13, 2025 10:06
@YDX-2147483647 YDX-2147483647 marked this pull request as ready for review October 13, 2025 12:26
@YDX-2147483647 YDX-2147483647 requested a review from a team as a code owner October 13, 2025 12:26
@YDX-2147483647 YDX-2147483647 force-pushed the model branch 2 times, most recently from 7a8b461 to 6f59238 Compare October 23, 2025 13:47
@YDX-2147483647
Copy link
Member Author

YDX-2147483647 commented Oct 24, 2025

Font sizes and spacings may need to be systematically adjusted later... But please review the program logic and text content first.

图片 图片

Copy link
Member

@3w36zj6 3w36zj6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the program logic up to this point is probably fine.

@3w36zj6 3w36zj6 requested a review from Copilot October 24, 2025 14:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR synchronizes the codebase with upstream Typst model changes from v0.13.1 to v0.14.0-rc.1, focusing on backward compatibility while supporting new documentation features.

Key changes:

  • Unified details/example structure into DetailsBlock type with normalization utilities
  • Added deprecation version tracking (deprecation_until) with enhanced warning display
  • Added support for global attributes in typed HTML function groups

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/normalizeModel.ts New utility module providing backward-compatible normalization for deprecation info and detail blocks
src/types/model.ts Updated type definitions to support both v0.13.1 and v0.14.0-rc.1 formats with union types
src/translation/ja-JP.tsx Added Japanese translations for deprecation warnings and example titles (partially incomplete)
src/translation/index.tsx Updated translation type definitions to support new deprecation and example title parameters
src/translation/en-US.tsx Added English translations for deprecation warnings with version info and example titles
src/components/ui/type2href.ts Added documentation comment for global attributes parameter ID generation
src/components/ui/FunctionParameters.tsx Refactored to use normalized detail blocks and support global attributes rendering
src/components/ui/FunctionDisplay.tsx Refactored to render detail blocks using normalization utilities with example folding support
src/components/ui/DeprecationWarning.tsx Enhanced to use normalization utilities and display version-specific deprecation information
src/components/templates/GroupTemplate.tsx Added rendering support for global attributes section in function groups
src/components/templates/FuncTemplate.tsx Updated to use normalization utilities for deprecation and detail blocks

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +66 to +94
{normalizeDetailBlocks(param).map((block) => {
switch (block.kind) {
case "html":
return (
<div class="text-gray-700">
<HtmlContent html={block.content} />
</div>
);
case "example":
return (
<details class="folding-example group">
<summary class="flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800">
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
<ChevronRightIcon />
</div>
<Translation
translationKey="showExample"
title={block.content.title}
/>
</summary>
<div class="mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm">
<HtmlContent html={block.content.body} />
</div>
</details>
);
default:
return null;
}
})}
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map callback should add a key prop to each returned element. Use block index or a combination of block.kind with index to ensure unique keys for proper React rendering.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hono JSX doesn't require key.

Comment on lines +28 to +56
{normalizeDetailBlocks(func).map((block) => {
switch (block.kind) {
case "html":
return <HtmlContent html={block.content} />;
case "example":
return isExampleFolding ? (
<details class="folding-example group">
<summary class="flex items-center gap-1 text-sm font-medium text-blue-600 cursor-pointer hover:text-blue-800">
<div class="w-4 h-4 text-gray-400 transform transition-transform duration-200 group-open:rotate-90">
<ChevronRightIcon />
</div>
<Translation
translationKey="showExample"
title={block.content.title}
/>
</summary>
<div class="mt-2 bg-white p-3 rounded-md border border-gray-200 text-sm">
<HtmlContent html={block.content.body} />
</div>
</details>
) : (
<div class="bg-gray-50 p-4 rounded-md border border-gray-200">
<HtmlContent html={block.content.body} />
</div>
);
default:
return null;
}
})}
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map callback should add a key prop to each returned element. Use block index or a combination of block.kind with index to ensure unique keys for proper React rendering.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +70
{normalizeDetailBlocks(content).map((block) => {
switch (block.kind) {
case "html":
return (
<div class="my-4 text-gray-700">
<HtmlContent html={block.content} />
</div>
);
case "example":
// This will never reach for Typst v0.13.1 and v0.14.0-rc.1 documentations.
return (
<div class="my-6 bg-gray-50 p-4 rounded-md border border-gray-200">
{block.content.title}
<HtmlContent html={block.content.body} />
</div>
);
default:
return null;
}
})}
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map callback should add a key prop to each returned element. Use block index or a combination of block.kind with index to ensure unique keys for proper React rendering.

Copilot uses AI. Check for mistakes.
@3w36zj6
Copy link
Member

3w36zj6 commented Oct 24, 2025

Shall we go ahead and merge this PR for now?
There are still some style issues, but addressing them is outside the scope of this PR. Also, I have not been satisfied with the current style from the beginning. I think we need a fundamental improvement of the style and a refactor of the component granularity, so it is not a big concern at this point.

@3w36zj6 3w36zj6 merged commit 4501255 into typst-community:main Oct 25, 2025
10 checks passed
@YDX-2147483647 YDX-2147483647 deleted the model branch October 25, 2025 16:44
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