dochub-sdk 0.1.183 → 0.1.184
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 +55 -18
- package/package.json +1 -1
@@ -26,14 +26,20 @@ export enum DocHubDocumentType {
|
|
26
26
|
// В результате работы вызовет метод processingData
|
27
27
|
}
|
28
28
|
|
29
|
+
export interface IDocHubDocumentUIState {
|
30
|
+
styleHeight: string;
|
31
|
+
styleWidth: string;
|
32
|
+
styleFilter: string;
|
33
|
+
}
|
34
|
+
|
29
35
|
@Component
|
30
36
|
export class DocHubDocumentProto extends DocHubComponentProto implements IDocHubEditableComponent {
|
31
|
-
onRefresher: any = null;
|
32
|
-
followFiles: string[] | undefined;
|
33
|
-
baseURI: string | undefined;
|
34
|
-
error: string | null = null;
|
35
|
-
isPending = true;
|
36
|
-
|
37
|
+
onRefresher: any = null; // Таймер отложенного выполнения обновления
|
38
|
+
followFiles: string[] | undefined; // Список файлов за изменениями которых нужно следить
|
39
|
+
baseURI: string | undefined; // URI документа от которого должны разрешаться все относительные ссылки
|
40
|
+
error: string | null = null; // Ошибка
|
41
|
+
isPending = true; // Признак внутренней работы. Например загрузка данных.
|
42
|
+
savedUIState: IDocHubDocumentUIState | null = null; // Хранит текущее UI состояние для последующего восстановления
|
37
43
|
/**
|
38
44
|
* Профиль документа
|
39
45
|
*/
|
@@ -41,7 +47,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
41
47
|
type: Object,
|
42
48
|
required: true
|
43
49
|
}) readonly profile: IDocHubPresentationProfile;
|
44
|
-
|
45
50
|
/**
|
46
51
|
* Параметры
|
47
52
|
*/
|
@@ -49,7 +54,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
49
54
|
type: Object,
|
50
55
|
default: {}
|
51
56
|
}) readonly params: IDocHubPresentationsParams;
|
52
|
-
|
53
57
|
/**
|
54
58
|
* Признак версии для печати
|
55
59
|
*/
|
@@ -57,20 +61,25 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
57
61
|
type: Boolean,
|
58
62
|
default: false
|
59
63
|
}) readonly isPrintVersion: boolean;
|
60
|
-
|
61
64
|
/**
|
62
65
|
* Следим за изменением профиля документа
|
63
66
|
*/
|
64
67
|
@Watch('profile') onProfileChanged() {
|
65
68
|
this.onRefresh();
|
66
69
|
}
|
67
|
-
|
68
70
|
/**
|
69
71
|
* Следим за изменением параметров
|
70
72
|
*/
|
71
73
|
@Watch('params') onParamsChanged() {
|
72
74
|
this.onRefresh();
|
73
75
|
}
|
76
|
+
/**
|
77
|
+
* Следим за занятостью документа
|
78
|
+
*/
|
79
|
+
@Watch('isPending') onPendingChanged() {
|
80
|
+
if (this.isPending) this.freezeView();
|
81
|
+
else this.unfreezeView();
|
82
|
+
}
|
74
83
|
|
75
84
|
mounted() {
|
76
85
|
// При монтировании компонента в DOM, генерируем событие обновления
|
@@ -81,7 +90,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
81
90
|
// Отключаем слежку за файлом
|
82
91
|
this.refreshFilesFollow(true);
|
83
92
|
}
|
84
|
-
|
85
93
|
/**
|
86
94
|
* Подтверждаем, что презентация может редактироваться
|
87
95
|
* @returns
|
@@ -97,7 +105,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
97
105
|
targetPath: this.profile.$base
|
98
106
|
});
|
99
107
|
}
|
100
|
-
|
101
108
|
/**
|
102
109
|
* Обработка полученных данных документа.
|
103
110
|
* Можно перехватывать.
|
@@ -105,7 +112,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
105
112
|
async processingData(data: any): Promise<any> {
|
106
113
|
return data;
|
107
114
|
}
|
108
|
-
|
109
115
|
/**
|
110
116
|
* Обработка полученных данных документа.
|
111
117
|
* Нужно переопределить для типа документа DocHubDocumentType.content
|
@@ -113,7 +119,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
113
119
|
async processingContent(content: AxiosResponse): Promise<void> {
|
114
120
|
throw new DocHubError(`The document has ${this.getType()} type. It must have processingContent method. But, the method is not implemented.`);
|
115
121
|
}
|
116
|
-
|
117
122
|
/**
|
118
123
|
* Возвращает список отслеживаемых файлов.
|
119
124
|
* Может быть переопределен.
|
@@ -123,7 +128,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
123
128
|
async processingFollowFiles(files: string[]): Promise<string[]> {
|
124
129
|
return files;
|
125
130
|
}
|
126
|
-
|
127
131
|
/**
|
128
132
|
* Возвращает схему данных для контроля структуры и состава данных.
|
129
133
|
* Необходимо переопределить.
|
@@ -131,7 +135,6 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
131
135
|
getSchemaData(): any {
|
132
136
|
return {};
|
133
137
|
}
|
134
|
-
|
135
138
|
/**
|
136
139
|
* Возвращает тип документа.
|
137
140
|
* Может быть переопределен.
|
@@ -139,14 +142,48 @@ export class DocHubDocumentProto extends DocHubComponentProto implements IDocHub
|
|
139
142
|
getType(): DocHubDocumentType {
|
140
143
|
return DocHubDocumentType.content;
|
141
144
|
}
|
142
|
-
|
143
145
|
/**
|
144
146
|
* Обрабатываем событие переключения языкового пакета
|
145
147
|
*/
|
146
148
|
onLangSwitch() {
|
147
149
|
this.onRefresh();
|
148
150
|
}
|
149
|
-
|
151
|
+
/**
|
152
|
+
* Сохраняет текущие параметры визуализации для исключения дерганий при обновлении контента
|
153
|
+
*/
|
154
|
+
saveUISate() {
|
155
|
+
const element = this['$el'];
|
156
|
+
this.savedUIState = {
|
157
|
+
styleHeight: element.style.height,
|
158
|
+
styleWidth: element.style.styleWidth,
|
159
|
+
styleFilter: element.style.filter
|
160
|
+
}
|
161
|
+
}
|
162
|
+
/**
|
163
|
+
* Восстанавливает параметры визуализации из ранее сохраненных
|
164
|
+
*/
|
165
|
+
loadUISate() {
|
166
|
+
const element = this['$el'];
|
167
|
+
element.style.height = this.savedUIState?.styleHeight || element.style.height;
|
168
|
+
element.style.width = this.savedUIState?.styleWidth || element.style.width;
|
169
|
+
element.style.filter = this.savedUIState?.styleFilter || element.style.filter;
|
170
|
+
}
|
171
|
+
/**
|
172
|
+
* "Замораживает" представление на период обновления
|
173
|
+
*/
|
174
|
+
freezeView() {
|
175
|
+
this.saveUISate();
|
176
|
+
const element = this['$el'];
|
177
|
+
element.style.height = `${element.clientHeight}px !important`;
|
178
|
+
element.style.width = `${element.clientWidth}px !important`;
|
179
|
+
element.style.filter = 'blur(8px)';
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* "Размораживает" представление после загрузки
|
183
|
+
*/
|
184
|
+
unfreezeView() {
|
185
|
+
this.loadUISate();
|
186
|
+
}
|
150
187
|
/**
|
151
188
|
* Для переопределения
|
152
189
|
*/
|