dochub-sdk 0.1.222 → 0.1.225
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/classes/vue2/Documents.ts +14 -2
- package/helpers/icons.ts +25 -0
- package/package.json +1 -1
@@ -3,7 +3,8 @@ import { Prop, Watch, Component } from 'vue-property-decorator';
|
|
3
3
|
import { DocHubComponentProto } from './Components';
|
4
4
|
import { DocHub } from '../..';
|
5
5
|
import { DocHubError } from '..';
|
6
|
-
import type { IDocHubEditableComponent, IDocHubEditableMeta, IDocHubPresentationProfile, IDocHubPresentationsParams } from '../..';
|
6
|
+
import type { IDocHubEditableComponent, IDocHubEditableMeta, IDocHubEditableMetaEditEntry, IDocHubPresentationProfile, IDocHubPresentationsParams } from '../..';
|
7
|
+
import { getIconByURI } from '../../helpers/icons';
|
7
8
|
|
8
9
|
import ajv from 'ajv';
|
9
10
|
import ajv_localize from 'ajv-i18n/localize/ru';
|
@@ -103,7 +104,18 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
103
104
|
*/
|
104
105
|
async getMetaEdit(): Promise<IDocHubEditableMeta> {
|
105
106
|
return {
|
106
|
-
title:
|
107
|
+
title: this.profile?.title || this.followFiles?.[0] || '$undefined$',
|
108
|
+
icon: getIconByURI(this.baseURI || this.followFiles?.[0]),
|
109
|
+
// Генерирует на все задействованные файлы точки редактирования
|
110
|
+
entries: this.followFiles?.map((uri: string): IDocHubEditableMetaEditEntry => {
|
111
|
+
return {
|
112
|
+
title: uri,
|
113
|
+
icon: getIconByURI(uri),
|
114
|
+
handle: () => DocHub.dataLake.openFileEditor(uri, {
|
115
|
+
targetPath: this.profile.$base
|
116
|
+
})
|
117
|
+
}
|
118
|
+
})
|
107
119
|
}
|
108
120
|
}
|
109
121
|
/**
|
package/helpers/icons.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* Возвращает ассоциативную иконку из набора доступного в DocHub для URI
|
3
|
+
* @param uri
|
4
|
+
*/
|
5
|
+
export function getIconByURI(uri: string | undefined) {
|
6
|
+
const url = new URL(uri || 'default', 'null:/');
|
7
|
+
return {
|
8
|
+
'default': 'mdi-file',
|
9
|
+
'json': 'mdi-code-json',
|
10
|
+
'md': 'mdi-language-markdown',
|
11
|
+
'yml': 'mdi-code-array',
|
12
|
+
'yaml': 'mdi-code-array',
|
13
|
+
'js': 'mdi-language-javascript',
|
14
|
+
'ts': 'mdi-language-typescript',
|
15
|
+
'vue': 'mdi-vuejs',
|
16
|
+
'java': 'mdi-language-java',
|
17
|
+
'kt': 'mdi-language-kotlin',
|
18
|
+
'php': 'mdi-language-php',
|
19
|
+
'pi': 'mdi-language-python',
|
20
|
+
'go': 'mdi-language-go',
|
21
|
+
'html': 'mdi-web',
|
22
|
+
'htm': 'mdi-web',
|
23
|
+
'c#': 'mdi-language-csharp'
|
24
|
+
}[url.pathname.split('.').pop() || 'default']
|
25
|
+
}
|