complexqa_frontend_core 1.21.8 → 1.22.0
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/package.json +1 -1
- package/publish/api/file_app_api.js +30 -3
- package/publish/api/index.js +6 -0
- package/publish/api/project_api.js +31 -8
- package/publish/api/public_text_document_api.js +59 -0
- package/publish/api/text_document_api.js +230 -0
- package/publish/api/text_document_folder_api.js +16 -0
- package/publish/app_configuration/table/helpers/table_element_models.js +2 -0
- package/publish/app_configuration/table/sections/text_document.js +31 -0
- package/publish/app_configuration/table/table_configuration.js +2 -0
- package/publish/app_configuration/text_document_editor_config.js +27 -0
- package/publish/constants/text_document_limits.js +12 -0
- package/publish/index.js +11 -0
- package/publish/services/FileAppService.js +103 -10
- package/publish/types/core/0_familyGeneralElement.js +0 -2
- package/publish/types/element_translate/_familyUtil.i18n.js +302 -68
- package/publish/types/element_translate/typeTextDocument.i18n.js +201 -0
- package/publish/types/element_translate/typeTextDocumentFolder.i18n.js +108 -0
- package/publish/types/element_translate/typeUtilExecution.i18n.js +171 -0
- package/publish/types/element_translate/typeUtilExecutionScreenshotMulti.i18n.js +281 -65
- package/publish/types/family_elements/typeProject.js +35 -10
- package/publish/types/family_files/typeTextDocument.js +88 -0
- package/publish/types/family_files/typeTextDocumentFolder.js +68 -0
- package/publish/types/family_utils/typeUtilExecution.js +14 -3
- package/publish/utils/text_document_image.js +84 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TEXT_DOCUMENT_MAX_IMAGES } from '../constants/text_document_limits.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Count image references in HTML (data-file-uuid or img tags).
|
|
5
|
+
*
|
|
6
|
+
* @param {string} html
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function count_text_document_images(html)
|
|
10
|
+
{
|
|
11
|
+
if (!html || typeof html !== 'string')
|
|
12
|
+
{
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
17
|
+
|
|
18
|
+
return doc.querySelectorAll('img').length;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Collect unique file UUIDs from img[data-file-uuid].
|
|
24
|
+
*
|
|
25
|
+
* @param {string} html
|
|
26
|
+
* @returns {string[]}
|
|
27
|
+
*/
|
|
28
|
+
export function collect_text_document_image_uuids(html)
|
|
29
|
+
{
|
|
30
|
+
if (!html || typeof html !== 'string')
|
|
31
|
+
{
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
const uuids = [];
|
|
38
|
+
|
|
39
|
+
doc.querySelectorAll('img[data-file-uuid]').forEach((node) =>
|
|
40
|
+
{
|
|
41
|
+
const uuid = String(node.getAttribute('data-file-uuid') || '').trim();
|
|
42
|
+
|
|
43
|
+
if (uuid && !seen.has(uuid))
|
|
44
|
+
{
|
|
45
|
+
seen.add(uuid);
|
|
46
|
+
uuids.push(uuid);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return uuids;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Build img HTML for editor insert.
|
|
56
|
+
*
|
|
57
|
+
* @param {object} options
|
|
58
|
+
* @param {string} options.file_uuid
|
|
59
|
+
* @param {string} options.preview_url
|
|
60
|
+
* @param {string} [options.alt]
|
|
61
|
+
* @param {string|number} [options.width]
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
export function build_text_document_image_html({ file_uuid, preview_url, alt = '', width = '' })
|
|
65
|
+
{
|
|
66
|
+
const safeUuid = String(file_uuid || '').replace(/"/g, '');
|
|
67
|
+
const safeUrl = String(preview_url || '').replace(/"/g, '"');
|
|
68
|
+
const safeAlt = String(alt || '').replace(/"/g, '"');
|
|
69
|
+
const widthAttr = width ? ` width="${ String(width).replace(/"/g, '') }"` : '';
|
|
70
|
+
|
|
71
|
+
return `<img data-file-uuid="${ safeUuid }" src="${ safeUrl }" alt="${ safeAlt }"${ widthAttr } />`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {number} currentCount
|
|
77
|
+
* @returns {boolean}
|
|
78
|
+
*/
|
|
79
|
+
export function can_add_text_document_image(currentCount)
|
|
80
|
+
{
|
|
81
|
+
return currentCount < TEXT_DOCUMENT_MAX_IMAGES;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { TEXT_DOCUMENT_MAX_IMAGES };
|