Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dream2023 committed Oct 30, 2023
1 parent 63b6888 commit ffc1e23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions docs/en-US/welcome/release/v15-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Previously, `SchemaInitializer` supported 2 definition methods, namely objects and components. For example:

```tsx
```tsx | pure
const BlockInitializers = {
title: '{{t("Add block")}}',
icon: 'PlusOutlined',
Expand All @@ -19,7 +19,7 @@ const BlockInitializers = {
};
```

```tsx
```tsx | pure
const BlockInitializers = () => {
return (
<SchemaInitializer.Button
Expand All @@ -38,7 +38,7 @@ const BlockInitializers = () => {

Now only the instance of `new SchemaInitializer()` is supported. For example:

```tsx
```tsx | pure
const blockInitializers = new SchemaInitializer({
name: 'BlockInitializers', // 名称,和原来保持一致
title: '{{t("Add block")}}',
Expand Down Expand Up @@ -108,7 +108,7 @@ Example 1:

Example 2:

```tsx
```tsx | pure
export const BulkEditFormItemInitializers = (props: any) => {
const { t } = useTranslation();
const { insertPosition, component } = props;
Expand Down Expand Up @@ -146,7 +146,7 @@ export const BulkEditFormItemInitializers = (props: any) => {

Now it needs to be changed to the way of `new SchemaInitializer()`:

```tsx
```tsx | pure
const bulkEditFormItemInitializers = new SchemaInitializer({
name: 'BulkEditFormItemInitializers',
'data-testid': 'configure-fields-button-of-bulk-edit-form-item',
Expand Down Expand Up @@ -228,7 +228,7 @@ export const blockInitializers = new SchemaInitializer({

The `title` and `schema` written in the outer layer are called common parameters, while the `size` written in `componentProps` is called component property. They are obtained in different ways, with common parameters obtained through the `useSchemaInitializerItem()` hook and component properties obtained through `props`. For example:

```tsx
```tsx | pure
import { FC } from 'react';
import { useSchemaInitializerItem } from '@nocobase/client';

Expand All @@ -246,7 +246,7 @@ const FormBlockInitializer: FC<FormBlockInitializerProps> = (props) => {

Previously, it was registered through `SchemaInitializerProvider`. For example:

```tsx
```tsx | pure
<SchemaInitializerProvider
initializers={{ BlockInitializers }}
components={{ ManualActionDesigner }}
Expand All @@ -255,7 +255,7 @@ Previously, it was registered through `SchemaInitializerProvider`. For example:

Now it needs to be changed to the way of `new SchemaInitializer()`:

```tsx
```tsx | pure
import { Plugin } from '@nocobase/client';

class MyPlugin extends Plugin {
Expand All @@ -270,7 +270,7 @@ class MyPlugin extends Plugin {

以前是通过 `SchemaInitializerContext` 获取到全部的 `Initializers` 然后进行增删改。例如下面代码是为了往 `BlockInitializers` 中的 `media` 下添加 `Hello`

```tsx
```tsx | pure
const items = useContext<any>(SchemaInitializerContext);
const mediaItems = items.BlockInitializers.items.find(
(item) => item.key === 'media',
Expand All @@ -293,7 +293,7 @@ if (!children.find((item) => item.key === 'hello')) {

Now it is modified in a more concise way through the plugin. For example:

```tsx
```tsx | pure
class MyPlugin extends Plugin {
async load() {
// get BlockInitializers
Expand All @@ -313,7 +313,7 @@ class MyPlugin extends Plugin {

Previously, the `useSchemaInitializer` method was used for rendering. For example:

```tsx
```tsx | pure
const { render } = useSchemaInitializer(fieldSchema['x-initializer']);

render();
Expand All @@ -322,7 +322,7 @@ render({ style: { marginLeft: 8 } });

Now it needs to be changed to:

```tsx
```tsx | pure
const app = useApp();

const { render } = app.schemaInitializerManager.getRender(
Expand All @@ -340,7 +340,7 @@ return (

To simplify usage, we also provide a method to directly render as a ReactNode:

```tsx
```tsx | pure
const element = app.schemaInitializerManager.render(
fieldSchema['x-initializer'],
fieldSchema['x-initializer-props'],
Expand Down
26 changes: 13 additions & 13 deletions docs/zh-CN/welcome/release/v15-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

以前 `SchemaInitializer` 支持 2 种定义方式,分别为对象和组件。例如:

```tsx
```tsx | pure
const BlockInitializers = {
title: '{{t("Add block")}}',
icon: 'PlusOutlined',
Expand All @@ -19,7 +19,7 @@ const BlockInitializers = {
};
```

```tsx
```tsx | pure
const BlockInitializers = () => {
return (
<SchemaInitializer.Button
Expand All @@ -38,7 +38,7 @@ const BlockInitializers = () => {

现在仅支持 `new SchemaInitializer()` 的实例。例如:

```tsx
```tsx | pure
const blockInitializers = new SchemaInitializer({
name: 'BlockInitializers', // 名称,和原来保持一致
title: '{{t("Add block")}}',
Expand Down Expand Up @@ -110,7 +110,7 @@ const blockInitializers = new SchemaInitializer({

原来是组件定义的方式:

```tsx
```tsx | pure
export const BulkEditFormItemInitializers = (props: any) => {
const { t } = useTranslation();
const { insertPosition, component } = props;
Expand Down Expand Up @@ -148,7 +148,7 @@ export const BulkEditFormItemInitializers = (props: any) => {

现在需要改为 `new SchemaInitializer()` 的方式:

```tsx
```tsx | pure
const bulkEditFormItemInitializers = new SchemaInitializer({
name: 'BulkEditFormItemInitializers',
'data-testid': 'configure-fields-button-of-bulk-edit-form-item',
Expand Down Expand Up @@ -231,7 +231,7 @@ export const blockInitializers = new SchemaInitializer({

其中写在外层的 `title``schema` 被称为公共参数,写在 `componentProps` 中的 `size` 被称为组件属性,他们获取方式也不同,公共参数通过 `useSchemaInitializerItem()` hooks 获取,组件属性通过 `props` 获取。例如:

```tsx
```tsx | pure
import { FC } from 'react';
import { useSchemaInitializerItem } from '@nocobase/client';

Expand All @@ -249,7 +249,7 @@ const FormBlockInitializer: FC<FormBlockInitializerProps> = (props) => {

以前是通过 `SchemaInitializerProvider` 进行注册。例如:

```tsx
```tsx | pure
<SchemaInitializerProvider
initializers={{ BlockInitializers }}
components={{ ManualActionDesigner }}
Expand All @@ -258,7 +258,7 @@ const FormBlockInitializer: FC<FormBlockInitializerProps> = (props) => {

现在需要改为插件的方式。例如:

```tsx
```tsx | pure
import { Plugin } from '@nocobase/client';

class MyPlugin extends Plugin {
Expand All @@ -273,7 +273,7 @@ class MyPlugin extends Plugin {

以前是通过 `SchemaInitializerContext` 获取到全部的 `Initializers` 然后进行增删改。例如下面代码是为了往 `BlockInitializers` 中的 `media` 下添加 `Hello`

```tsx
```tsx | pure
const items = useContext<any>(SchemaInitializerContext);
const mediaItems = items.BlockInitializers.items.find(
(item) => item.key === 'media',
Expand All @@ -296,7 +296,7 @@ if (!children.find((item) => item.key === 'hello')) {

新的方式则通过插件的方式更简洁的进行修改。例如:

```tsx
```tsx | pure
class MyPlugin extends Plugin {
async load() {
// 获取 BlockInitializers
Expand All @@ -316,7 +316,7 @@ class MyPlugin extends Plugin {

之前使用 `useSchemaInitializer` 的方式进行渲染。例如:

```tsx
```tsx | pure
const { render } = useSchemaInitializer(fieldSchema['x-initializer']);

render();
Expand All @@ -325,7 +325,7 @@ render({ style: { marginLeft: 8 } });

新的方式需要改为:

```tsx
```tsx | pure
const app = useApp();

const { render } = app.schemaInitializerManager.getRender(
Expand All @@ -343,7 +343,7 @@ return (

当然为了简化使用,我们也提供了直接渲染为元素的方法:

```tsx
```tsx | pure
const element = app.schemaInitializerManager.render(
fieldSchema['x-initializer'],
fieldSchema['x-initializer-props'],
Expand Down

0 comments on commit ffc1e23

Please sign in to comment.