dochub-sdk 0.1.221 → 0.1.224

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.
@@ -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: (this.followFiles || [])[0]
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
  /**
@@ -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
+ }
@@ -10,12 +10,24 @@ export enum DocHubEditMode {
10
10
  editIDE = 'edit-ide',
11
11
  view = 'view'
12
12
  }
13
+
14
+ export type IDocHubEditableMetaEditEntryHandle = () => void;
15
+
16
+ /**
17
+ * Точки входя для редактирования
18
+ */
19
+ export interface IDocHubEditableMetaEditEntry {
20
+ title: string;
21
+ icon?: string;
22
+ handle: IDocHubEditableMetaEditEntryHandle;
23
+ }
13
24
  /**
14
25
  * Мета информация о редактируемом объекте
15
26
  */
16
27
  export interface IDocHubEditableMeta {
17
28
  title: string; // Название объекта редактирования. Выводится пользователя, например, в выпадающем меню
18
29
  icon?: string; // Иконка соответствующая объекту редактирования
30
+ entries?: IDocHubEditableMetaEditEntry[]; // Точки входя для редактирования. Если точки не определены, то используется редактор по умолчанию openEditor
19
31
  }
20
32
  /**
21
33
  * Если компонент имеет возможность контекстного редактирования, он должен реализовывать данный интерфейс
@@ -27,7 +39,7 @@ export interface IDocHubEditableComponent {
27
39
  */
28
40
  isEditable(): boolean;
29
41
  /**
30
- * Отправляет запрос на начало редактирования
42
+ * Отправляет запрос на редактирование с использованием редактора по умолчанию
31
43
  */
32
44
  openEditor(): void;
33
45
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dochub-sdk",
3
- "version": "0.1.221",
3
+ "version": "0.1.224",
4
4
  "description": "The DocHub System Development Kit.",
5
5
  "private": false,
6
6
  "main": "index.ts",