plugin-build-guide-block 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -74
- package/dist/client/index.js +1 -1
- package/dist/client/models/index.d.ts +1 -3
- package/dist/externalVersion.js +7 -7
- package/dist/locale/en-US.json +28 -27
- package/dist/locale/vi-VN.json +28 -27
- package/dist/locale/zh-CN.json +28 -27
- package/dist/node_modules/sanitize-html/index.js +2 -2
- package/dist/node_modules/sanitize-html/package.json +1 -1
- package/dist/server/actions/build.js +3 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +7 -1
- package/dist/server/plugin.js +14 -0
- package/package.json +31 -31
- package/src/client/UserGuideBlock.tsx +53 -53
- package/src/client/UserGuideBlockInitializer.tsx +26 -26
- package/src/client/UserGuideBlockProvider.tsx +12 -12
- package/src/client/UserGuideManager.tsx +128 -107
- package/src/client/components/BuildButton.tsx +78 -43
- package/src/client/components/LLMServiceSelect.tsx +44 -44
- package/src/client/components/ModelSelect.tsx +41 -41
- package/src/client/components/StatusTag.tsx +17 -17
- package/src/client/models/UserGuideBlockModel.ts +54 -54
- package/src/client/models/index.ts +1 -3
- package/src/client/plugin.tsx +30 -30
- package/src/client/schemas/spacesSchema.ts +316 -316
- package/src/locale/en-US.json +28 -27
- package/src/locale/vi-VN.json +28 -27
- package/src/locale/zh-CN.json +28 -27
- package/src/server/actions/build.ts +176 -171
- package/src/server/actions/getHtml.ts +26 -26
- package/src/server/collections/ai-build-guide-spaces.ts +50 -50
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +76 -60
|
@@ -1,43 +1,78 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Button, App } from 'antd';
|
|
3
|
-
import { useAPIClient, useCollectionRecordData, useDataBlockRequest } from '@nocobase/client';
|
|
4
|
-
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import { Button, App } from 'antd';
|
|
3
|
+
import { useAPIClient, useCollectionRecordData, useDataBlockRequest } from '@nocobase/client';
|
|
4
|
+
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
const POLL_INTERVAL_MS = 3000;
|
|
8
|
+
const MAX_POLL_COUNT = 100; // ~5 minutes max
|
|
9
|
+
|
|
10
|
+
export const BuildButton = () => {
|
|
11
|
+
const [loading, setLoading] = useState(false);
|
|
12
|
+
const api = useAPIClient();
|
|
13
|
+
const { message } = App.useApp();
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const record = useCollectionRecordData();
|
|
16
|
+
const { refresh } = useDataBlockRequest();
|
|
17
|
+
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
18
|
+
|
|
19
|
+
const stopPolling = useCallback(() => {
|
|
20
|
+
if (timerRef.current) {
|
|
21
|
+
clearInterval(timerRef.current);
|
|
22
|
+
timerRef.current = null;
|
|
23
|
+
}
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
// Cleanup on unmount
|
|
28
|
+
useEffect(() => stopPolling, [stopPolling]);
|
|
29
|
+
|
|
30
|
+
const handleBuild = async () => {
|
|
31
|
+
if (!record?.id) return;
|
|
32
|
+
setLoading(true);
|
|
33
|
+
try {
|
|
34
|
+
await api.resource('aiBuildGuideSpaces').build({
|
|
35
|
+
filterByTk: record.id,
|
|
36
|
+
});
|
|
37
|
+
message.success(t('Build started'));
|
|
38
|
+
|
|
39
|
+
// Poll until status leaves "building"
|
|
40
|
+
let pollCount = 0;
|
|
41
|
+
timerRef.current = setInterval(async () => {
|
|
42
|
+
pollCount++;
|
|
43
|
+
try {
|
|
44
|
+
const res = await api.resource('aiBuildGuideSpaces').get({ filterByTk: record.id });
|
|
45
|
+
const status = res?.data?.data?.status;
|
|
46
|
+
if (status !== 'building' || pollCount >= MAX_POLL_COUNT) {
|
|
47
|
+
stopPolling();
|
|
48
|
+
refresh?.();
|
|
49
|
+
if (status === 'completed') {
|
|
50
|
+
message.success(t('Build completed'));
|
|
51
|
+
} else if (status === 'error') {
|
|
52
|
+
message.error(t('Build failed'));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
stopPolling();
|
|
57
|
+
refresh?.();
|
|
58
|
+
}
|
|
59
|
+
}, POLL_INTERVAL_MS);
|
|
60
|
+
} catch (err: any) {
|
|
61
|
+
console.error(err);
|
|
62
|
+
message.error(err?.response?.data?.error?.message || t('Build failed'));
|
|
63
|
+
setLoading(false);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Button
|
|
69
|
+
type="primary"
|
|
70
|
+
icon={<PlayCircleOutlined />}
|
|
71
|
+
loading={loading}
|
|
72
|
+
onClick={handleBuild}
|
|
73
|
+
disabled={record?.status === 'building'}
|
|
74
|
+
>
|
|
75
|
+
{t('Build')}
|
|
76
|
+
</Button>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { useAPIClient } from '@nocobase/client';
|
|
3
|
-
import { Select } from 'antd';
|
|
4
|
-
import { useField } from '@formily/react';
|
|
5
|
-
import { Field } from '@formily/core';
|
|
6
|
-
|
|
7
|
-
export const LLMServiceSelect = (props: any) => {
|
|
8
|
-
const [options, setOptions] = useState([]);
|
|
9
|
-
const [loading, setLoading] = useState(false);
|
|
10
|
-
const api = useAPIClient();
|
|
11
|
-
const field = useField<Field>();
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
let active = true;
|
|
15
|
-
setLoading(true);
|
|
16
|
-
api.resource('ai').listLLMServices()
|
|
17
|
-
.then((res) => {
|
|
18
|
-
if (!active) return;
|
|
19
|
-
const data = res?.data?.data || [];
|
|
20
|
-
setOptions(
|
|
21
|
-
data.map((item: any) => ({
|
|
22
|
-
label: item.title || item.name,
|
|
23
|
-
value: item.name,
|
|
24
|
-
}))
|
|
25
|
-
);
|
|
26
|
-
})
|
|
27
|
-
.catch((err) => {
|
|
28
|
-
if (!active) return;
|
|
29
|
-
console.error('Failed to load LLM services:', err);
|
|
30
|
-
})
|
|
31
|
-
.finally(() => {
|
|
32
|
-
if (active) setLoading(false);
|
|
33
|
-
});
|
|
34
|
-
return () => {
|
|
35
|
-
active = false;
|
|
36
|
-
};
|
|
37
|
-
}, [api]);
|
|
38
|
-
|
|
39
|
-
return <Select {...props} options={options} loading={loading} value={field.value} onChange={(v) => {
|
|
40
|
-
field.setValue(v);
|
|
41
|
-
// Reset model when service changes
|
|
42
|
-
(field.query('.model').take() as any)?.setValue(undefined);
|
|
43
|
-
}} />;
|
|
44
|
-
};
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useAPIClient } from '@nocobase/client';
|
|
3
|
+
import { Select } from 'antd';
|
|
4
|
+
import { useField } from '@formily/react';
|
|
5
|
+
import { Field } from '@formily/core';
|
|
6
|
+
|
|
7
|
+
export const LLMServiceSelect = (props: any) => {
|
|
8
|
+
const [options, setOptions] = useState([]);
|
|
9
|
+
const [loading, setLoading] = useState(false);
|
|
10
|
+
const api = useAPIClient();
|
|
11
|
+
const field = useField<Field>();
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
let active = true;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
api.resource('ai').listLLMServices()
|
|
17
|
+
.then((res) => {
|
|
18
|
+
if (!active) return;
|
|
19
|
+
const data = res?.data?.data || [];
|
|
20
|
+
setOptions(
|
|
21
|
+
data.map((item: any) => ({
|
|
22
|
+
label: item.title || item.name,
|
|
23
|
+
value: item.name,
|
|
24
|
+
}))
|
|
25
|
+
);
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => {
|
|
28
|
+
if (!active) return;
|
|
29
|
+
console.error('Failed to load LLM services:', err);
|
|
30
|
+
})
|
|
31
|
+
.finally(() => {
|
|
32
|
+
if (active) setLoading(false);
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}, [api]);
|
|
38
|
+
|
|
39
|
+
return <Select {...props} options={options} loading={loading} value={field.value} onChange={(v) => {
|
|
40
|
+
field.setValue(v);
|
|
41
|
+
// Reset model when service changes
|
|
42
|
+
(field.query('.model').take() as any)?.setValue(undefined);
|
|
43
|
+
}} />;
|
|
44
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { useAPIClient } from '@nocobase/client';
|
|
3
|
-
import { Select } from 'antd';
|
|
4
|
-
import { useField, useForm, observer } from '@formily/react';
|
|
5
|
-
import { Field } from '@formily/core';
|
|
6
|
-
|
|
7
|
-
export const ModelSelect = observer((props: any) => {
|
|
8
|
-
const [options, setOptions] = useState([]);
|
|
9
|
-
const api = useAPIClient();
|
|
10
|
-
const field = useField<Field>();
|
|
11
|
-
const form = useForm();
|
|
12
|
-
|
|
13
|
-
const llmService = form.values.llmService;
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
let active = true;
|
|
17
|
-
if (!llmService) {
|
|
18
|
-
setOptions([]);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
api.resource('ai').listModels({ llmService }).then((res) => {
|
|
23
|
-
if (!active) return;
|
|
24
|
-
const data = res?.data?.data || [];
|
|
25
|
-
setOptions(
|
|
26
|
-
data.map((item: any) => ({
|
|
27
|
-
label: item.id || item.name,
|
|
28
|
-
value: item.id || item.name,
|
|
29
|
-
}))
|
|
30
|
-
);
|
|
31
|
-
}).catch(console.error);
|
|
32
|
-
|
|
33
|
-
return () => {
|
|
34
|
-
active = false;
|
|
35
|
-
};
|
|
36
|
-
}, [api, llmService]);
|
|
37
|
-
|
|
38
|
-
return <Select {...props} options={options} value={field.value} onChange={(v) => {
|
|
39
|
-
field.setValue(v);
|
|
40
|
-
}} disabled={!llmService} />;
|
|
41
|
-
});
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { useAPIClient } from '@nocobase/client';
|
|
3
|
+
import { Select } from 'antd';
|
|
4
|
+
import { useField, useForm, observer } from '@formily/react';
|
|
5
|
+
import { Field } from '@formily/core';
|
|
6
|
+
|
|
7
|
+
export const ModelSelect = observer((props: any) => {
|
|
8
|
+
const [options, setOptions] = useState([]);
|
|
9
|
+
const api = useAPIClient();
|
|
10
|
+
const field = useField<Field>();
|
|
11
|
+
const form = useForm();
|
|
12
|
+
|
|
13
|
+
const llmService = form.values.llmService;
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
let active = true;
|
|
17
|
+
if (!llmService) {
|
|
18
|
+
setOptions([]);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
api.resource('ai').listModels({ llmService }).then((res) => {
|
|
23
|
+
if (!active) return;
|
|
24
|
+
const data = res?.data?.data || [];
|
|
25
|
+
setOptions(
|
|
26
|
+
data.map((item: any) => ({
|
|
27
|
+
label: item.id || item.name,
|
|
28
|
+
value: item.id || item.name,
|
|
29
|
+
}))
|
|
30
|
+
);
|
|
31
|
+
}).catch(console.error);
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
active = false;
|
|
35
|
+
};
|
|
36
|
+
}, [api, llmService]);
|
|
37
|
+
|
|
38
|
+
return <Select {...props} options={options} value={field.value} onChange={(v) => {
|
|
39
|
+
field.setValue(v);
|
|
40
|
+
}} disabled={!llmService} />;
|
|
41
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Tag } from 'antd';
|
|
3
|
-
import { useField } from '@formily/react';
|
|
4
|
-
|
|
5
|
-
const colors = {
|
|
6
|
-
draft: 'default',
|
|
7
|
-
building: 'blue',
|
|
8
|
-
completed: 'success',
|
|
9
|
-
error: 'error',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const StatusTag = (props: any) => {
|
|
13
|
-
const field = useField();
|
|
14
|
-
const value = props.value || (field as any).value;
|
|
15
|
-
if (!value) return null;
|
|
16
|
-
return <Tag color={colors[value] || 'default'}>{String(value).toUpperCase()}</Tag>;
|
|
17
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tag } from 'antd';
|
|
3
|
+
import { useField } from '@formily/react';
|
|
4
|
+
|
|
5
|
+
const colors = {
|
|
6
|
+
draft: 'default',
|
|
7
|
+
building: 'blue',
|
|
8
|
+
completed: 'success',
|
|
9
|
+
error: 'error',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const StatusTag = (props: any) => {
|
|
13
|
+
const field = useField();
|
|
14
|
+
const value = props.value || (field as any).value;
|
|
15
|
+
if (!value) return null;
|
|
16
|
+
return <Tag color={colors[value] || 'default'}>{String(value).toUpperCase()}</Tag>;
|
|
17
|
+
};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { BlockModel } from '@nocobase/client';
|
|
2
|
-
import { escapeT } from '@nocobase/flow-engine';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { UserGuideBlock } from '../UserGuideBlock';
|
|
5
|
-
|
|
6
|
-
export class UserGuideBlockModel extends BlockModel {
|
|
7
|
-
renderComponent() {
|
|
8
|
-
const { spaceId } = this.props;
|
|
9
|
-
return React.createElement(UserGuideBlock, { spaceId });
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
UserGuideBlockModel.registerFlow({
|
|
14
|
-
key: 'userGuideBlockSettings',
|
|
15
|
-
title: escapeT('User guide block setting', { ns: 'build-guide-block' }),
|
|
16
|
-
steps: {
|
|
17
|
-
editUserGuide: {
|
|
18
|
-
title: escapeT('Edit user guide settings', { ns: 'build-guide-block' }),
|
|
19
|
-
uiSchema(ctx) {
|
|
20
|
-
const t = ctx.t;
|
|
21
|
-
return {
|
|
22
|
-
spaceId: {
|
|
23
|
-
title: t('Space'),
|
|
24
|
-
type: 'string',
|
|
25
|
-
'x-decorator': 'FormItem',
|
|
26
|
-
'x-component': 'RemoteSelect',
|
|
27
|
-
'x-component-props': {
|
|
28
|
-
showSearch: true,
|
|
29
|
-
fieldNames: { label: 'title', value: 'id' },
|
|
30
|
-
service: {
|
|
31
|
-
resource: 'aiBuildGuideSpaces',
|
|
32
|
-
action: 'list',
|
|
33
|
-
params: {
|
|
34
|
-
filter: { status: 'completed' },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
async handler(ctx, params) {
|
|
43
|
-
const { spaceId } = params;
|
|
44
|
-
ctx.model.setProps({
|
|
45
|
-
spaceId,
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
UserGuideBlockModel.define({
|
|
53
|
-
label: escapeT('User Guide'),
|
|
54
|
-
});
|
|
1
|
+
import { BlockModel } from '@nocobase/client';
|
|
2
|
+
import { escapeT } from '@nocobase/flow-engine';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { UserGuideBlock } from '../UserGuideBlock';
|
|
5
|
+
|
|
6
|
+
export class UserGuideBlockModel extends BlockModel {
|
|
7
|
+
renderComponent() {
|
|
8
|
+
const { spaceId } = this.props;
|
|
9
|
+
return React.createElement(UserGuideBlock, { spaceId });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
UserGuideBlockModel.registerFlow({
|
|
14
|
+
key: 'userGuideBlockSettings',
|
|
15
|
+
title: escapeT('User guide block setting', { ns: 'build-guide-block' }),
|
|
16
|
+
steps: {
|
|
17
|
+
editUserGuide: {
|
|
18
|
+
title: escapeT('Edit user guide settings', { ns: 'build-guide-block' }),
|
|
19
|
+
uiSchema(ctx) {
|
|
20
|
+
const t = ctx.t;
|
|
21
|
+
return {
|
|
22
|
+
spaceId: {
|
|
23
|
+
title: t('Space'),
|
|
24
|
+
type: 'string',
|
|
25
|
+
'x-decorator': 'FormItem',
|
|
26
|
+
'x-component': 'RemoteSelect',
|
|
27
|
+
'x-component-props': {
|
|
28
|
+
showSearch: true,
|
|
29
|
+
fieldNames: { label: 'title', value: 'id' },
|
|
30
|
+
service: {
|
|
31
|
+
resource: 'aiBuildGuideSpaces',
|
|
32
|
+
action: 'list',
|
|
33
|
+
params: {
|
|
34
|
+
filter: { status: 'completed' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
async handler(ctx, params) {
|
|
43
|
+
const { spaceId } = params;
|
|
44
|
+
ctx.model.setProps({
|
|
45
|
+
spaceId,
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
UserGuideBlockModel.define({
|
|
53
|
+
label: escapeT('User Guide'),
|
|
54
|
+
});
|
|
@@ -7,6 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default {} as Record<string, ModelConstructor>;
|
|
10
|
+
export { UserGuideBlockModel } from './UserGuideBlockModel';
|
package/src/client/plugin.tsx
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Plugin } from '@nocobase/client';
|
|
2
|
-
import { UserGuideManager } from './UserGuideManager';
|
|
3
|
-
import { UserGuideBlockProvider } from './UserGuideBlockProvider';
|
|
4
|
-
import { UserGuideBlockInitializer } from './UserGuideBlockInitializer';
|
|
5
|
-
import { UserGuideBlockModel } from './models/UserGuideBlockModel';
|
|
6
|
-
|
|
7
|
-
export class PluginBuildGuideBlockClient extends Plugin {
|
|
8
|
-
async load() {
|
|
9
|
-
this.app.pluginSettingsManager.add('ai-build-guide', {
|
|
10
|
-
icon: 'ReadOutlined',
|
|
11
|
-
title: '{{t("Build Guide Block", { ns: "build-guide-block" })}}',
|
|
12
|
-
Component: UserGuideManager,
|
|
13
|
-
aclSnippet: 'pm.ai-build-guide',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
this.app.use(UserGuideBlockProvider);
|
|
17
|
-
|
|
18
|
-
const blocksInit = this.app.schemaInitializerManager.get('page:addBlock');
|
|
19
|
-
blocksInit?.add('otherBlocks.aiUserGuide', {
|
|
20
|
-
title: '{{t("User Guide", { ns: "build-guide-block" })}}',
|
|
21
|
-
Component: 'UserGuideBlockInitializer',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
this.flowEngine.registerModels({
|
|
25
|
-
UserGuideBlockModel,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default PluginBuildGuideBlockClient;
|
|
1
|
+
import { Plugin } from '@nocobase/client';
|
|
2
|
+
import { UserGuideManager } from './UserGuideManager';
|
|
3
|
+
import { UserGuideBlockProvider } from './UserGuideBlockProvider';
|
|
4
|
+
import { UserGuideBlockInitializer } from './UserGuideBlockInitializer';
|
|
5
|
+
import { UserGuideBlockModel } from './models/UserGuideBlockModel';
|
|
6
|
+
|
|
7
|
+
export class PluginBuildGuideBlockClient extends Plugin {
|
|
8
|
+
async load() {
|
|
9
|
+
this.app.pluginSettingsManager.add('ai-build-guide', {
|
|
10
|
+
icon: 'ReadOutlined',
|
|
11
|
+
title: '{{t("Build Guide Block", { ns: "build-guide-block" })}}',
|
|
12
|
+
Component: UserGuideManager,
|
|
13
|
+
aclSnippet: 'pm.ai-build-guide',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
this.app.use(UserGuideBlockProvider);
|
|
17
|
+
|
|
18
|
+
const blocksInit = this.app.schemaInitializerManager.get('page:addBlock');
|
|
19
|
+
blocksInit?.add('otherBlocks.aiUserGuide', {
|
|
20
|
+
title: '{{t("User Guide", { ns: "build-guide-block" })}}',
|
|
21
|
+
Component: 'UserGuideBlockInitializer',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.flowEngine.registerModels({
|
|
25
|
+
UserGuideBlockModel,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default PluginBuildGuideBlockClient;
|