diff --git a/app/[lang]/(home)/page.tsx b/app/[lang]/(home)/page.tsx index b2785314..0813b5d0 100644 --- a/app/[lang]/(home)/page.tsx +++ b/app/[lang]/(home)/page.tsx @@ -84,7 +84,7 @@ export default async function Page({ params }: IProps) { hover:bg-neutral-100 dark:bg-neutral-800 dark:hover:bg-neutral-900 `} - href="/blog/weekly-6" + href="/blog/weekly-7" > + ⭐️ 在 GitHub 上点个星 + + +--- + +## Univer v0.10.0 + +### `mergeLocales`:简化多语言包合并 + +在 Univer v0.10.0 版本中,我们提供了新的 [`mergeLocales`](/guides/getting-started/i18n#mergeLocales) 方法。用于合并多个语言包对象。相比以往手动调用 `merge` 进行合并,`mergeLocales` 让你无需再关心底层的合并细节,只需专注于传入需要合并的语言包即可,大幅提升了国际化开发的便捷性和代码可读性。 + +对于之前使用 `merge` 方法的项目,建议按如下方式修改代码: + + + + ```diff + - import { merge } from '@univerjs/presets'; + + import { mergeLocales } from '@univerjs/presets'; + + const univer = new Univer({ + locale: LocaleType.ZH_CN, + locales: { + - [LocaleType.ZH_CN]: merge( + - {}, + + [LocaleType.ZH_CN]: mergeLocales( + DesignZhCN, + UIZhCN, + DocsUIZhCN, + SheetsZhCN, + SheetsUIZhCN, + SheetsFormulaUIZhCN, + SheetsNumfmtUIZhCN, + ), + }, + }) + ``` + + + ```diff + - import { merge } from '@univerjs/core'; + + import { mergeLocales } from '@univerjs/core'; + + const univer = new Univer({ + locale: LocaleType.ZH_CN, + locales: { + - [LocaleType.ZH_CN]: merge( + - {}, + + [LocaleType.ZH_CN]: mergeLocales( + DesignZhCN, + UIZhCN, + DocsUIZhCN, + SheetsZhCN, + SheetsUIZhCN, + SheetsFormulaUIZhCN, + SheetsNumfmtUIZhCN, + ), + }, + }) + ``` + + + +通过上述调整,你可以用更清晰的方式合并多个语言包,无需再手动传入空对象作为初始参数。 + +### `univer.registerPlugin`:支持批量注册插件 + +本次更新对 [`univer.registerPlugin`](/guides/getting-started/installation#registerPlugin) 方法进行了增强,现在支持一次性注册多个插件,无需多次循环调用,极大提升了插件注册的灵活性与效率。例如: + +```typescript +univer.registerPlugin([ + UniverRenderEnginePlugin, + UniverFormulaEnginePlugin, + [UniverUIPlugin, { + container: 'app', + }], + UniverDocsPlugin, + UniverDocsUIPlugin, + UniverSheetsPlugin, + UniverSheetsUIPlugin, + UniverSheetsFormulaPlugin, + UniverSheetsFormulaUIPlugin, + UniverSheetsNumfmtPlugin, + UniverSheetsNumfmtUIPlugin, +]) +``` + +通过数组传递插件列表,可以更直观地管理和维护插件依赖关系。 + +### 💔 破坏性更新:自定义权限背景与用户组件配置方式调整 + +以往,开发者需要通过 `UniverSheetsUIPlugin` 的 `customComponents` 属性实现自定义权限背景和用户组件,这一方式配置繁琐、理解门槛高。v0.10.0 版本对此进行了破坏性调整,移除了 `customComponents`,并用更直观的 `protectedRangeUserSelector` 和 `protectedRangeShadow` 替代。 + +如果你过去使用了 `customComponents` 属性来实现自定义权限背景和用户组件,请参考以下示例进行迁移: + +**隐藏权限背景阴影** + + + + ```diff + createUniver({ + presets: [ + UniverSheetsCorePreset({ + - customComponents: new Set([UNIVER_SHEET_PERMISSION_BACKGROUND]), + + protectedRangeShadow: false, + }), + ], + }) + ``` + + + ```diff + univer.registerPlugin(UniverSheetsUIPlugin, { + - customComponents: new Set([UNIVER_SHEET_PERMISSION_BACKGROUND]), + + protectedRangeShadow: false, + }) + ``` + + + +**自定义用户组件** + + + + ```diff + - const injector = univer.__getInjector() + - const uiPartsService = injector.get(IUIPartsService) + - uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(CustomPermissionDetailUserPart, injector)) + + createUniver({ + presets: [ + UniverSheetsCorePreset({ + - customComponents: new Set([UNIVER_SHEET_PERMISSION_USER_PART]), + + protectedRangeUserSelector: { + + component: CustomPermissionDetailUserPart, + + framework: 'react', + + }, + }), + ], + }) + ``` + + + ```diff + - const injector = univer.__getInjector() + - const uiPartsService = injector.get(IUIPartsService) + - uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(CustomPermissionDetailUserPart, injector)) + + univer.registerPlugin(UniverSheetsUIPlugin, { + - customComponents: new Set([UNIVER_SHEET_PERMISSION_USER_PART]), + + protectedRangeUserSelector: { + + component: CustomPermissionDetailUserPart, + + framework: 'react', + + }, + }) + ``` + + + +### 其他功能优化与问题修复 + +- Univer Slides 现已支持插入圆形。感谢社区贡献者 [@kenny-not-dead](https://github.com/kenny-not-dead) 对此功能的贡献([#5602](https://github.com/dream-num/univer/pull/5602))。 +- 优化了自定义排序弹窗的默认弹出位置,提升用户体验。 +- 查找替换功能升级,现支持在输入框中直接通过回车键跳转到下一个匹配项。 +- 修复了部分表格过滤器相关的问题。 + +更多详细的更新内容和历史版本信息,请访问我们的 [GitHub Releases](https://github.com/dream-num/univer/releases/tag/v0.10.0) 页面。 + +--- + +感谢每一位社区开发者和用户的关注与支持!我们将持续优化产品体验,也欢迎大家通过文档评价、Issue 或 Pull Request 提出宝贵建议或直接参与贡献。让我们一起让 Univer 变得更好! diff --git a/content/blog/weekly-7.zh-CN.mdx b/content/blog/weekly-7.zh-CN.mdx new file mode 100644 index 00000000..a6e89972 --- /dev/null +++ b/content/blog/weekly-7.zh-CN.mdx @@ -0,0 +1,181 @@ +--- +title: "Univer Weekly #7" +author: 白熱 +date: 2025-07-29 +--- + +import { RainbowButton } from '@/components/magicui/rainbow-button' + +If you find Univer useful, please consider supporting us by starring our project on GitHub. Your support helps us continue to improve and maintain Univer. + + + ⭐️ Star on GitHub + + +--- + +## Univer v0.10.0 + +### `mergeLocales`: Simplifying Locale Merging + +In Univer v0.10.0, we introduced the new [`mergeLocales`](/guides/getting-started/i18n#mergeLocales) method for merging multiple locale objects. This method simplifies the merging process, allowing you to focus on the locales you want to combine without worrying about the underlying details, significantly enhancing the convenience and readability of internationalization development. + +For projects that previously used the `merge` method, we recommend updating your code as follows: + + + + ```diff + - import { merge } from '@univerjs/presets'; + + import { mergeLocales } from '@univerjs/presets'; + + const univer = new Univer({ + locale: LocaleType.EN_US, + locales: { + - [LocaleType.EN_US]: merge( + - {}, + + [LocaleType.EN_US]: mergeLocales( + DesignEnUS, + UIEnUS, + DocsUIEnUS, + SheetsEnUS, + SheetsUIEnUS, + SheetsFormulaUIEnUS, + SheetsNumfmtUIEnUS, + ), + }, + }) + ``` + + + ```diff + - import { merge } from '@univerjs/core'; + + import { mergeLocales } from '@univerjs/core'; + + const univer = new Univer({ + locale: LocaleType.EN_US, + locales: { + - [LocaleType.EN_US]: merge( + - {}, + + [LocaleType.EN_US]: mergeLocales( + DesignEnUS, + UIEnUS, + DocsUIEnUS, + SheetsEnUS, + SheetsUIEnUS, + SheetsFormulaUIEnUS, + SheetsNumfmtUIEnUS, + ), + }, + }) + ``` + + + +This adjustment allows you to merge multiple locale objects more clearly, without needing to manually pass an empty object as the initial parameter. + +### `univer.registerPlugin`: Support for Batch Plugin Registration + +We have enhanced the [`univer.registerPlugin`](/guides/getting-started/installation#registerPlugin) method to support batch registration of plugins, allowing you to register multiple plugins at once without the need for multiple calls, greatly improving flexibility and efficiency. For example: + +```typescript +univer.registerPlugin([ + UniverRenderEnginePlugin, + UniverFormulaEnginePlugin, + [UniverUIPlugin, { + container: 'app', + }], + UniverDocsPlugin, + UniverDocsUIPlugin, + UniverSheetsPlugin, + UniverSheetsUIPlugin, + UniverSheetsFormulaPlugin, + UniverSheetsFormulaUIPlugin, + UniverSheetsNumfmtPlugin, + UniverSheetsNumfmtUIPlugin, +]) +``` + +This allows you to manage and maintain plugin dependencies more intuitively by passing an array of plugins. + +### 💔 Breaking Change: Custom Permission Background and User Component Configuration Changes + +In the past, developers used the `customComponents` property of `UniverSheetsUIPlugin` to implement custom permission backgrounds and user components. This approach was cumbersome and had a high learning curve. In version 0.10.0, we made a breaking change by removing `customComponents` and replacing it with more intuitive `protectedRangeUserSelector` and `protectedRangeShadow`. + +If you previously used the `customComponents` property for custom permission backgrounds and user components, please refer to the following examples for migration: + +**Hide Permission Background Shadow** + + + + ```diff + createUniver({ + presets: [ + UniverSheetsCorePreset({ + - customComponents: new Set([UNIVER_SHEET_PERMISSION_BACKGROUND]), + + protectedRangeShadow: false, + }), + ], + }) + ``` + + + ```diff + univer.registerPlugin(UniverSheetsUIPlugin, { + - customComponents: new Set([UNIVER_SHEET_PERMISSION_BACKGROUND]), + + protectedRangeShadow: false, + }) + ``` + + + +**Custom User Component** + + + + ```diff + - const injector = univer.__getInjector() + - const uiPartsService = injector.get(IUIPartsService) + - uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(CustomPermissionDetailUserPart, injector)) + + createUniver({ + presets: [ + UniverSheetsCorePreset({ + - customComponents: new Set([UNIVER_SHEET_PERMISSION_USER_PART]), + + protectedRangeUserSelector: { + + component: CustomPermissionDetailUserPart, + + framework: 'react', + + }, + }), + ], + }) + ``` + + + ```diff + - const injector = univer.__getInjector() + - const uiPartsService = injector.get(IUIPartsService) + - uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(CustomPermissionDetailUserPart, injector)) + + univer.registerPlugin(UniverSheetsUIPlugin, { + - customComponents: new Set([UNIVER_SHEET_PERMISSION_USER_PART]), + + protectedRangeUserSelector: { + + component: CustomPermissionDetailUserPart, + + framework: 'react', + + }, + }) + ``` + + + +### Other Feature Enhancements and Bug Fixes + +- Univer Slides now supports inserting circles. Thanks to community contributor [@kenny-not-dead](https://github.com/kenny-not-dead) for this feature contribution (#[5602](https://github.com/dream-num/univer/pull/5602)). +- Optimized the default popup position of the custom sorting dialog to enhance user experience. +- The find and replace feature has been upgraded to allow jumping to the next match directly by pressing the Enter key in the input box. +- Fixed some issues related to table filters. + +For a full list of updates and historical release information, please visit our [GitHub Releases page](https://github.com/dream-num/univer/releases/tag/v0.10.0). + +--- + +Thank you to every community developer and user for your attention and support! We will continue to optimize the product experience, and we welcome your valuable suggestions and contributions. Let's work together to make Univer even better! diff --git a/content/guides/shared/getting-started/i18n.mdx b/content/guides/shared/getting-started/i18n.mdx index c8eccce4..24ca072c 100644 --- a/content/guides/shared/getting-started/i18n.mdx +++ b/content/guides/shared/getting-started/i18n.mdx @@ -7,7 +7,7 @@ icon: Earth Not all plugins include language packs. We will specify this in the documentation for each feature. -## `mergeLocales` Method +## `mergeLocales` Method [#mergeLocales] `mergeLocales` Method is used to merge multiple plugin or preset language packs into a complete language pack object. You can use it as follows: diff --git a/content/guides/shared/getting-started/i18n.zh-CN.mdx b/content/guides/shared/getting-started/i18n.zh-CN.mdx index 5a4e777b..e1fc0247 100644 --- a/content/guides/shared/getting-started/i18n.zh-CN.mdx +++ b/content/guides/shared/getting-started/i18n.zh-CN.mdx @@ -7,7 +7,7 @@ icon: Earth 并非所有插件都包含了语言包,我们会在每个功能的文档对此进行说明。 -## `mergeLocales` 方法 +## `mergeLocales` 方法 [#mergeLocales] `mergeLocales` 方法用于将多个插件或预设的语言包合并为一个完整的语言包对象,你可以通过以下方式使用它: diff --git a/content/guides/sheets/getting-started/installation/index.mdx b/content/guides/sheets/getting-started/installation/index.mdx index f71f6596..18ccf39b 100644 --- a/content/guides/sheets/getting-started/installation/index.mdx +++ b/content/guides/sheets/getting-started/installation/index.mdx @@ -233,7 +233,7 @@ We use React to develop the view (this does not affect your use of Univer in Vue -#### `univer.registerPlugin` Method +#### `univer.registerPlugin` Method [#registerPlugin] ``univer.registerPlugin` method is used to register a plugin to the Univer instance. You can call this method after creating the Univer instance to register plugins. diff --git a/content/guides/sheets/getting-started/installation/index.zh-CN.mdx b/content/guides/sheets/getting-started/installation/index.zh-CN.mdx index 2c7d3f77..fb0dd982 100644 --- a/content/guides/sheets/getting-started/installation/index.zh-CN.mdx +++ b/content/guides/sheets/getting-started/installation/index.zh-CN.mdx @@ -233,7 +233,7 @@ Univer 使用了 React 开发视图(当然这并不影响你在 Vue 或者 Ang -#### `univer.registerPlugin` 方法 +#### `univer.registerPlugin` 方法 [#registerPlugin] `univer.registerPlugin` 方法用于注册一个插件到 Univer 实例中。你可以在创建 Univer 实例后调用这个方法来注册插件。