croco-html 0.0.1 → 0.1.1
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 +24 -24
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +14 -22
- package/src/lib/components/add-files-btn/add-files-btn.component.css +0 -0
- package/src/lib/components/add-files-btn/add-files-btn.component.html +14 -0
- package/src/lib/components/add-files-btn/add-files-btn.component.ts +61 -0
- package/src/lib/components/editor/external-video-block/external-video-block.component.css +0 -0
- package/src/lib/components/editor/external-video-block/external-video-block.component.html +27 -0
- package/src/lib/components/editor/external-video-block/external-video-block.component.ts +45 -0
- package/src/lib/components/editor/html-raw-editor/html-raw-editor.component.css +0 -0
- package/src/lib/components/editor/html-raw-editor/html-raw-editor.component.html +17 -0
- package/src/lib/components/editor/html-raw-editor/html-raw-editor.component.ts +22 -0
- package/src/lib/components/editor/image-editor/image-editor.component.css +7 -0
- package/src/lib/components/editor/image-editor/image-editor.component.html +54 -0
- package/src/lib/components/editor/image-editor/image-editor.component.ts +52 -0
- package/src/lib/components/editor/index.ts +7 -0
- package/src/lib/components/editor/main-editor/main-editor.component.css +48 -0
- package/src/lib/components/editor/main-editor/main-editor.component.html +39 -0
- package/src/lib/components/editor/main-editor/main-editor.component.ts +71 -0
- package/src/lib/components/editor/main-editor-block/main-editor-block.component.css +0 -0
- package/src/lib/components/editor/main-editor-block/main-editor-block.component.html +41 -0
- package/src/lib/components/editor/main-editor-block/main-editor-block.component.ts +39 -0
- package/src/lib/components/editor/text-editor/text-editor.component.css +0 -0
- package/src/lib/components/editor/text-editor/text-editor.component.html +39 -0
- package/src/lib/components/editor/text-editor/text-editor.component.ts +30 -0
- package/src/lib/components/editor/visual-editor/visual-editor.component.css +48 -0
- package/src/lib/components/editor/visual-editor/visual-editor.component.html +84 -0
- package/src/lib/components/editor/visual-editor/visual-editor.component.ts +180 -0
- package/src/lib/components/file-id-select/file-id-select.component.css +0 -0
- package/src/lib/components/file-id-select/file-id-select.component.html +39 -0
- package/src/lib/components/file-id-select/file-id-select.component.ts +75 -0
- package/src/lib/components/index.ts +5 -0
- package/src/lib/components/upload-files-btn/upload-files-btn.component.css +0 -0
- package/src/lib/components/upload-files-btn/upload-files-btn.component.html +2 -0
- package/src/lib/components/upload-files-btn/upload-files-btn.component.ts +57 -0
- package/{lib/components/xml-tags/index.d.ts → src/lib/components/xml-tags/index.ts} +8 -8
- package/src/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.css +15 -0
- package/src/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.html +8 -0
- package/src/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.ts +59 -0
- package/src/lib/components/xml-tags/xml-tag-header-inner-text-view/xml-tag-header-inner-text-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-header-inner-text-view/xml-tag-header-inner-text-view.component.html +18 -0
- package/src/lib/components/xml-tags/xml-tag-header-inner-text-view/xml-tag-header-inner-text-view.component.ts +19 -0
- package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.html +25 -0
- package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.ts +19 -0
- package/src/lib/components/xml-tags/xml-tag-html-view/xml-tag-html-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-html-view/xml-tag-html-view.component.html +3 -0
- package/src/lib/components/xml-tags/xml-tag-html-view/xml-tag-html-view.component.ts +14 -0
- package/src/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.html +2 -0
- package/src/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.ts +19 -0
- package/src/lib/components/xml-tags/xml-tag-table-view/xml-tag-table-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-table-view/xml-tag-table-view.component.html +9 -0
- package/src/lib/components/xml-tags/xml-tag-table-view/xml-tag-table-view.component.ts +15 -0
- package/src/lib/components/xml-tags/xml-tag-text-view/xml-tag-text-view.component.css +0 -0
- package/src/lib/components/xml-tags/xml-tag-text-view/xml-tag-text-view.component.html +21 -0
- package/src/lib/components/xml-tags/xml-tag-text-view/xml-tag-text-view.component.ts +18 -0
- package/src/lib/components/xml-tags/xml-tag-view/xml-tag-view.component.css +4 -0
- package/src/lib/components/xml-tags/xml-tag-view/xml-tag-view.component.html +44 -0
- package/src/lib/components/xml-tags/xml-tag-view/xml-tag-view.component.ts +17 -0
- package/src/lib/croco-html.module.ts +22 -0
- package/src/lib/extensions/AngularMaterialTableMethods.ts +87 -0
- package/src/lib/extensions/BodyTagsExtensions.ts +151 -0
- package/src/lib/extensions/BootstrapTableMethods.ts +87 -0
- package/src/lib/extensions/HtmlExtractionMethods.ts +78 -0
- package/src/lib/extensions/HtmlRawTagDataConsts.ts +3 -0
- package/src/lib/extensions/ImageMethods.ts +37 -0
- package/{lib/extensions/InterfaceBlock.d.ts → src/lib/extensions/InterfaceBlock.ts} +5 -4
- package/src/lib/extensions/TableBuilder.ts +50 -0
- package/src/lib/extensions/TableMethods.ts +175 -0
- package/src/lib/extensions/TextMethods.ts +51 -0
- package/src/lib/extensions/TextSimpleMethods.ts +120 -0
- package/src/lib/extensions/VideoMethods.ts +31 -0
- package/src/lib/extensions/XmlExtensions.ts +26 -0
- package/src/lib/extensions/index.ts +12 -0
- package/src/lib/index.ts +119 -0
- package/{lib/models/models.d.ts → src/lib/models/models.ts} +11 -10
- package/src/lib/pipes/RichTextToHtmlPipe.ts +25 -0
- package/src/lib/pipes/TagToSpanPipe.ts +10 -0
- package/src/lib/pipes/ToHtmlBodyTagsPipe.ts +14 -0
- package/{lib/pipes/index.d.ts → src/lib/pipes/index.ts} +4 -4
- package/src/lib/pipes/to-preview.pipe.ts +12 -0
- package/src/lib/services/file-upload.service.ts +56 -0
- package/src/lib/services/files-query.service.ts +72 -0
- package/{public-api.d.ts → src/public-api.ts} +8 -4
- package/src/test.ts +28 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/bundles/croco-html.umd.js +0 -2091
- package/bundles/croco-html.umd.js.map +0 -1
- package/croco-html.d.ts +0 -5
- package/esm2015/croco-html.js +0 -5
- package/esm2015/lib/components/add-files-btn/add-files-btn.component.js +0 -57
- package/esm2015/lib/components/editor/external-video-block/external-video-block.component.js +0 -49
- package/esm2015/lib/components/editor/html-raw-editor/html-raw-editor.component.js +0 -29
- package/esm2015/lib/components/editor/image-editor/image-editor.component.js +0 -54
- package/esm2015/lib/components/editor/index.js +0 -8
- package/esm2015/lib/components/editor/main-editor/main-editor.component.js +0 -80
- package/esm2015/lib/components/editor/main-editor-block/main-editor-block.component.js +0 -45
- package/esm2015/lib/components/editor/text-editor/text-editor.component.js +0 -38
- package/esm2015/lib/components/editor/visual-editor/visual-editor.component.js +0 -165
- package/esm2015/lib/components/file-id-select/file-id-select.component.js +0 -66
- package/esm2015/lib/components/index.js +0 -6
- package/esm2015/lib/components/upload-files-btn/upload-files-btn.component.js +0 -58
- package/esm2015/lib/components/xml-tags/index.js +0 -9
- package/esm2015/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.js +0 -47
- package/esm2015/lib/components/xml-tags/xml-tag-header-inner-text-view/xml-tag-header-inner-text-view.component.js +0 -21
- package/esm2015/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.js +0 -22
- package/esm2015/lib/components/xml-tags/xml-tag-html-view/xml-tag-html-view.component.js +0 -20
- package/esm2015/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.js +0 -24
- package/esm2015/lib/components/xml-tags/xml-tag-table-view/xml-tag-table-view.component.js +0 -24
- package/esm2015/lib/components/xml-tags/xml-tag-text-view/xml-tag-text-view.component.js +0 -21
- package/esm2015/lib/components/xml-tags/xml-tag-view/xml-tag-view.component.js +0 -26
- package/esm2015/lib/croco-html.module.js +0 -90
- package/esm2015/lib/extensions/AngularMaterialTableMethods.js +0 -64
- package/esm2015/lib/extensions/BodyTagsExtensions.js +0 -120
- package/esm2015/lib/extensions/BootstrapTableMethods.js +0 -67
- package/esm2015/lib/extensions/HtmlExtractionMethods.js +0 -63
- package/esm2015/lib/extensions/HtmlRawTagDataConsts.js +0 -4
- package/esm2015/lib/extensions/ImageMethods.js +0 -24
- package/esm2015/lib/extensions/InterfaceBlock.js +0 -2
- package/esm2015/lib/extensions/TableBuilder.js +0 -35
- package/esm2015/lib/extensions/TableMethods.js +0 -100
- package/esm2015/lib/extensions/TextMethods.js +0 -29
- package/esm2015/lib/extensions/TextSimpleMethods.js +0 -78
- package/esm2015/lib/extensions/VideoMethods.js +0 -20
- package/esm2015/lib/extensions/XmlExtensions.js +0 -26
- package/esm2015/lib/extensions/index.js +0 -13
- package/esm2015/lib/index.js +0 -113
- package/esm2015/lib/models/models.js +0 -2
- package/esm2015/lib/pipes/RichTextToHtmlPipe.js +0 -26
- package/esm2015/lib/pipes/TagToSpanPipe.js +0 -16
- package/esm2015/lib/pipes/ToHtmlBodyTagsPipe.js +0 -17
- package/esm2015/lib/pipes/index.js +0 -5
- package/esm2015/lib/pipes/to-preview.pipe.js +0 -17
- package/esm2015/lib/services/file-upload.service.js +0 -40
- package/esm2015/lib/services/files-query.service.js +0 -27
- package/esm2015/public-api.js +0 -8
- package/fesm2015/croco-html.js +0 -1634
- package/fesm2015/croco-html.js.map +0 -1
- package/lib/components/add-files-btn/add-files-btn.component.d.ts +0 -18
- package/lib/components/editor/external-video-block/external-video-block.component.d.ts +0 -19
- package/lib/components/editor/html-raw-editor/html-raw-editor.component.d.ts +0 -11
- package/lib/components/editor/image-editor/image-editor.component.d.ts +0 -20
- package/lib/components/editor/index.d.ts +0 -7
- package/lib/components/editor/main-editor/main-editor.component.d.ts +0 -28
- package/lib/components/editor/main-editor-block/main-editor-block.component.d.ts +0 -16
- package/lib/components/editor/text-editor/text-editor.component.d.ts +0 -14
- package/lib/components/editor/visual-editor/visual-editor.component.d.ts +0 -43
- package/lib/components/file-id-select/file-id-select.component.d.ts +0 -30
- package/lib/components/index.d.ts +0 -5
- package/lib/components/upload-files-btn/upload-files-btn.component.d.ts +0 -24
- package/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.d.ts +0 -17
- package/lib/components/xml-tags/xml-tag-header-inner-text-view/xml-tag-header-inner-text-view.component.d.ts +0 -10
- package/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.d.ts +0 -10
- package/lib/components/xml-tags/xml-tag-html-view/xml-tag-html-view.component.d.ts +0 -7
- package/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.d.ts +0 -10
- package/lib/components/xml-tags/xml-tag-table-view/xml-tag-table-view.component.d.ts +0 -7
- package/lib/components/xml-tags/xml-tag-text-view/xml-tag-text-view.component.d.ts +0 -10
- package/lib/components/xml-tags/xml-tag-view/xml-tag-view.component.d.ts +0 -8
- package/lib/croco-html.module.d.ts +0 -60
- package/lib/extensions/AngularMaterialTableMethods.d.ts +0 -10
- package/lib/extensions/BodyTagsExtensions.d.ts +0 -10
- package/lib/extensions/BootstrapTableMethods.d.ts +0 -9
- package/lib/extensions/HtmlExtractionMethods.d.ts +0 -69
- package/lib/extensions/HtmlRawTagDataConsts.d.ts +0 -3
- package/lib/extensions/ImageMethods.d.ts +0 -17
- package/lib/extensions/TableBuilder.d.ts +0 -5
- package/lib/extensions/TableMethods.d.ts +0 -58
- package/lib/extensions/TextMethods.d.ts +0 -19
- package/lib/extensions/TextSimpleMethods.d.ts +0 -23
- package/lib/extensions/VideoMethods.d.ts +0 -19
- package/lib/extensions/XmlExtensions.d.ts +0 -5
- package/lib/extensions/index.d.ts +0 -10
- package/lib/index.d.ts +0 -20
- package/lib/pipes/RichTextToHtmlPipe.d.ts +0 -8
- package/lib/pipes/TagToSpanPipe.d.ts +0 -7
- package/lib/pipes/ToHtmlBodyTagsPipe.d.ts +0 -8
- package/lib/pipes/to-preview.pipe.d.ts +0 -8
- package/lib/services/file-upload.service.d.ts +0 -23
- package/lib/services/files-query.service.d.ts +0 -42
package/src/lib/components/xml-tags/xml-tag-external-video/xml-tag-external-video.component.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
3
|
+
import { InterfaceBlock } from "../../../extensions/InterfaceBlock";
|
|
4
|
+
import { ExternalVideoTagData } from '../../../extensions/VideoMethods';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'croco-html-xml-tag-external-video',
|
|
8
|
+
templateUrl: './xml-tag-external-video.component.html',
|
|
9
|
+
styleUrls: ['./xml-tag-external-video.component.css']
|
|
10
|
+
})
|
|
11
|
+
export class XmlTagExternalVideoComponent implements OnInit {
|
|
12
|
+
|
|
13
|
+
@Input()
|
|
14
|
+
data: InterfaceBlock;
|
|
15
|
+
|
|
16
|
+
@Input()
|
|
17
|
+
tagData: ExternalVideoTagData;
|
|
18
|
+
|
|
19
|
+
widgetUrl: SafeResourceUrl;
|
|
20
|
+
|
|
21
|
+
getYouTubeId(youtubeLink:string){
|
|
22
|
+
|
|
23
|
+
//https://www.youtube.com/watch?v=l3KfbfkxJOU
|
|
24
|
+
if(youtubeLink.includes("watch?v=")){
|
|
25
|
+
var url = new URL(youtubeLink);
|
|
26
|
+
return url.searchParams.get("v");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//https://youtu.be/jzBneaWSswY
|
|
30
|
+
let bits = youtubeLink.split('/')
|
|
31
|
+
return bits[bits.length - 1];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getWidgetLink(youtubeLink:string){
|
|
35
|
+
|
|
36
|
+
let id = this.getYouTubeId(youtubeLink);
|
|
37
|
+
|
|
38
|
+
let result = `https://www.youtube.com/embed/${id}?controls=0`;
|
|
39
|
+
|
|
40
|
+
this.widgetUrl = this._domSanitizer.bypassSecurityTrustResourceUrl(result);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
constructor(private _domSanitizer: DomSanitizer) { }
|
|
47
|
+
|
|
48
|
+
ngOnInit(): void {
|
|
49
|
+
if(this.data != null){
|
|
50
|
+
this.tagData = this.data.data as ExternalVideoTagData;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let youtubeWidgetLink = this.getWidgetLink(this.tagData.link);
|
|
54
|
+
this.widgetUrl = this._domSanitizer.bypassSecurityTrustResourceUrl(youtubeWidgetLink);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<h1 *ngIf="item.type === 'h1'"
|
|
2
|
+
[innerHtml]="item.data.html">
|
|
3
|
+
</h1>
|
|
4
|
+
<h2 *ngIf="item.type === 'h2'"
|
|
5
|
+
[innerHtml]="item.data.html">
|
|
6
|
+
</h2>
|
|
7
|
+
<h3 *ngIf="item.type === 'h3'"
|
|
8
|
+
[innerHtml]="item.data.html">
|
|
9
|
+
</h3>
|
|
10
|
+
<h4 *ngIf="item.type === 'h4'"
|
|
11
|
+
[innerHtml]="item.data.html">
|
|
12
|
+
</h4>
|
|
13
|
+
<h5 *ngIf="item.type === 'h5'"
|
|
14
|
+
[innerHtml]="item.data.html">
|
|
15
|
+
</h5>
|
|
16
|
+
<h6 *ngIf="item.type === 'h6'"
|
|
17
|
+
[innerHtml]="item.data.html">
|
|
18
|
+
</h6>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { GenericTextTag } from '../../../extensions/TextSimpleMethods';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'croco-html-xml-tag-header-inner-text-view',
|
|
6
|
+
templateUrl: './xml-tag-header-inner-text-view.component.html',
|
|
7
|
+
styleUrls: ['./xml-tag-header-inner-text-view.component.css']
|
|
8
|
+
})
|
|
9
|
+
export class XmlTagHeaderInnerTextViewComponent implements OnInit {
|
|
10
|
+
|
|
11
|
+
@Input()
|
|
12
|
+
item: GenericTextTag;
|
|
13
|
+
|
|
14
|
+
constructor() { }
|
|
15
|
+
|
|
16
|
+
ngOnInit(): void {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.css
ADDED
|
File without changes
|
package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.html
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'left'" style="text-align: left;">
|
|
2
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
3
|
+
<croco-html-xml-tag-header-inner-text-view *ngIf="item.data.html.length > 0" [item]="item">
|
|
4
|
+
</croco-html-xml-tag-header-inner-text-view>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'right'" style="text-align: right;">
|
|
8
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
9
|
+
<croco-html-xml-tag-header-inner-text-view *ngIf="item.data.html.length > 0" [item]="item">
|
|
10
|
+
</croco-html-xml-tag-header-inner-text-view>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'center'" style="text-align: center;">
|
|
14
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
15
|
+
|
|
16
|
+
<croco-html-xml-tag-header-inner-text-view *ngIf="item.data.html.length > 0" [item]="item">
|
|
17
|
+
</croco-html-xml-tag-header-inner-text-view>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div *ngIf="!item.data.validationResult.isSucceeded" class="red" style="margin-top: 10px;" >
|
|
21
|
+
<h4>Допущена ошибка в теге <text></h4>
|
|
22
|
+
<span>
|
|
23
|
+
{{item.data.validationResult.message}}
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
package/src/lib/components/xml-tags/xml-tag-header-text-view/xml-tag-header-text-view.component.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { GenericTextTag } from '../../../extensions/TextSimpleMethods';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'croco-html-xml-tag-header-text-view',
|
|
6
|
+
templateUrl: './xml-tag-header-text-view.component.html',
|
|
7
|
+
styleUrls: ['./xml-tag-header-text-view.component.css']
|
|
8
|
+
})
|
|
9
|
+
export class XmlTagHeaderTextViewComponent implements OnInit {
|
|
10
|
+
|
|
11
|
+
@Input()
|
|
12
|
+
item: GenericTextTag;
|
|
13
|
+
|
|
14
|
+
constructor() { }
|
|
15
|
+
|
|
16
|
+
ngOnInit(): void {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'croco-html-xml-tag-html-view',
|
|
5
|
+
templateUrl: './xml-tag-html-view.component.html',
|
|
6
|
+
styleUrls: ['./xml-tag-html-view.component.css']
|
|
7
|
+
})
|
|
8
|
+
export class XmlTagHtmlViewComponent {
|
|
9
|
+
|
|
10
|
+
constructor() { }
|
|
11
|
+
|
|
12
|
+
@Input()
|
|
13
|
+
html: string = "";
|
|
14
|
+
}
|
package/src/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.css
ADDED
|
File without changes
|
package/src/lib/components/xml-tags/xml-tag-rich-text-view/xml-tag-rich-text-view.component.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { RichTextData } from '../../../extensions/TextMethods';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'croco-html-xml-tag-rich-text-view',
|
|
6
|
+
templateUrl: './xml-tag-rich-text-view.component.html',
|
|
7
|
+
styleUrls: ['./xml-tag-rich-text-view.component.css']
|
|
8
|
+
})
|
|
9
|
+
export class XmlTagRichTextViewComponent implements OnInit {
|
|
10
|
+
|
|
11
|
+
@Input()
|
|
12
|
+
richTextData: RichTextData = null;
|
|
13
|
+
|
|
14
|
+
constructor() { }
|
|
15
|
+
|
|
16
|
+
ngOnInit(): void {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<table mat-table [dataSource]="data" class="mat-elevation-z8 w-100 example-container">
|
|
2
|
+
<ng-container [matColumnDef]="column" *ngFor="let column of displayedColumns">
|
|
3
|
+
<th mat-header-cell *matHeaderCellDef> {{column}} </th>
|
|
4
|
+
<td mat-cell *matCellDef="let element"> {{element[column]}} </td>
|
|
5
|
+
</ng-container>
|
|
6
|
+
|
|
7
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
|
8
|
+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
|
9
|
+
</table>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'croco-html-xml-tag-table-view',
|
|
5
|
+
templateUrl: './xml-tag-table-view.component.html',
|
|
6
|
+
styleUrls: ['./xml-tag-table-view.component.css']
|
|
7
|
+
})
|
|
8
|
+
export class XmlTagTableViewComponent {
|
|
9
|
+
|
|
10
|
+
@Input()
|
|
11
|
+
displayedColumns: string[] = [];
|
|
12
|
+
|
|
13
|
+
@Input()
|
|
14
|
+
data: object;
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'left'" style="text-align: left;">
|
|
2
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
3
|
+
<span *ngIf="item.data.html.length > 0" [innerHtml]="item.data.html"></span>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'right'" style="text-align: right;">
|
|
7
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
8
|
+
<span *ngIf="item.data.html.length > 0" [innerHtml]="item.data.html"></span>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div *ngIf="item.data.validationResult.isSucceeded && item.data.horizontalAlignment === 'center'" style="text-align: center;">
|
|
12
|
+
<span *ngIf="item.data.html.length === 0 || !item.data.html"> </span>
|
|
13
|
+
<span *ngIf="item.data.html.length > 0" [innerHtml]="item.data.html"></span>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div *ngIf="!item.data.validationResult.isSucceeded" class="red" style="margin-top: 10px;" >
|
|
17
|
+
<h4>Допущена ошибка в теге <text></h4>
|
|
18
|
+
<span>
|
|
19
|
+
{{item.data.validationResult.message}}
|
|
20
|
+
</span>
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
import { SimpleTextTag } from '../../../extensions/TextSimpleMethods';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'croco-html-xml-tag-text-view',
|
|
6
|
+
templateUrl: './xml-tag-text-view.component.html',
|
|
7
|
+
styleUrls: ['./xml-tag-text-view.component.css']
|
|
8
|
+
})
|
|
9
|
+
export class XmlTagTextViewComponent implements OnInit {
|
|
10
|
+
|
|
11
|
+
@Input()
|
|
12
|
+
item: SimpleTextTag;
|
|
13
|
+
|
|
14
|
+
constructor() { }
|
|
15
|
+
|
|
16
|
+
ngOnInit(): void {
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<div class="">
|
|
2
|
+
<div class="row" *ngFor="let item of data">
|
|
3
|
+
<div *ngIf="item.type === 'text'">
|
|
4
|
+
<croco-html-xml-tag-text-view [item]="item"></croco-html-xml-tag-text-view>
|
|
5
|
+
</div>
|
|
6
|
+
<div *ngIf="item.type === 'image'" class="red" style="margin-top: 10px;" >
|
|
7
|
+
<h4>Данный тег больше больше не поддерживается</h4>
|
|
8
|
+
<span>
|
|
9
|
+
Вмето этого переименуйте тег image на file-image
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
<div *ngIf="item.type === 'html-raw'" [innerHTML]="item.data.innerHTML">
|
|
13
|
+
</div>
|
|
14
|
+
<div *ngIf="item.type === 'h1' || item.type === 'h2' || item.type === 'h3' || item.type === 'h4' || item.type === 'h5' || item.type === 'h6'">
|
|
15
|
+
<croco-html-xml-tag-header-text-view [item]="item"></croco-html-xml-tag-header-text-view>
|
|
16
|
+
</div>
|
|
17
|
+
<div *ngIf="item.type === 'file-image'">
|
|
18
|
+
<img class="mx-auto d-block img-fluid" [src]="item.data.src"/>
|
|
19
|
+
</div>
|
|
20
|
+
<div *ngIf="item.type === 'table'">
|
|
21
|
+
|
|
22
|
+
<croco-html-xml-tag-html-view *ngIf="item.validationResult.isSucceeded" [html]="item.bootstrapHtml">
|
|
23
|
+
</croco-html-xml-tag-html-view>
|
|
24
|
+
|
|
25
|
+
<app-tutor-baseapiresponse-banner
|
|
26
|
+
*ngIf="item.validationResult && !item.validationResult.isSucceeded"
|
|
27
|
+
[message]="item.validationResult.message">
|
|
28
|
+
</app-tutor-baseapiresponse-banner>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div *ngIf="item.type === 'rich-text'">
|
|
32
|
+
<croco-html-xml-tag-text-view [richTextData]="item"></croco-html-xml-tag-text-view>
|
|
33
|
+
</div>
|
|
34
|
+
<div *ngIf="item.type === 'external-video'">
|
|
35
|
+
<croco-html-xml-tag-external-video [data]="item"></croco-html-xml-tag-external-video>
|
|
36
|
+
</div>
|
|
37
|
+
<div *ngIf="item.type === 'unsupported-tag'" class="red" style="margin-top: 10px;" >
|
|
38
|
+
<h4>Данный тег не поддерживается</h4>
|
|
39
|
+
<span>
|
|
40
|
+
{{item.data.tagString}}
|
|
41
|
+
</span>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component, Input, ViewEncapsulation } from '@angular/core';
|
|
2
|
+
import { InterfaceBlock } from "../../../extensions/InterfaceBlock";
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'croco-html-xml-tag-view',
|
|
6
|
+
templateUrl: './xml-tag-view.component.html',
|
|
7
|
+
styleUrls: ['./xml-tag-view.component.css'],
|
|
8
|
+
encapsulation: ViewEncapsulation.None,
|
|
9
|
+
})
|
|
10
|
+
export class XmlTagViewComponent {
|
|
11
|
+
|
|
12
|
+
@Input()
|
|
13
|
+
data:InterfaceBlock[] = [];
|
|
14
|
+
|
|
15
|
+
constructor() { }
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import { NgModule } from "@angular/core";
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
|
4
|
+
import { NgSelectModule } from "@ng-select/ng-select";
|
|
5
|
+
import { CrocoHtmlDeclarations, MaterialModules } from ".";
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
declarations: [
|
|
9
|
+
...CrocoHtmlDeclarations
|
|
10
|
+
],
|
|
11
|
+
exports: [
|
|
12
|
+
...CrocoHtmlDeclarations,
|
|
13
|
+
],
|
|
14
|
+
imports: [
|
|
15
|
+
CommonModule,
|
|
16
|
+
FormsModule,
|
|
17
|
+
ReactiveFormsModule,
|
|
18
|
+
NgSelectModule,
|
|
19
|
+
...MaterialModules
|
|
20
|
+
]
|
|
21
|
+
})
|
|
22
|
+
export class CrocoHtmlModule { }
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BaseApiResponse, TableData, TableRowData } from './TableMethods';
|
|
2
|
+
export interface AngularMaterialTableData {
|
|
3
|
+
displayedColumns: string[];
|
|
4
|
+
data: object[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class AngularMaterialTableMethods {
|
|
8
|
+
static getAngularMaterialTableData(columns: string[], rows: TableRowData[]): AngularMaterialTableData {
|
|
9
|
+
|
|
10
|
+
let data: object[] = [];
|
|
11
|
+
|
|
12
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
13
|
+
const row = rows[rowIndex];
|
|
14
|
+
|
|
15
|
+
var elem = {};
|
|
16
|
+
|
|
17
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
18
|
+
const column = columns[columnIndex];
|
|
19
|
+
|
|
20
|
+
elem[column] = row.columns[columnIndex].data.text;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
data.push(elem);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
displayedColumns: columns,
|
|
28
|
+
data: data,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static checkHeaders(tableData: TableData): BaseApiResponse {
|
|
33
|
+
if(tableData.header === null){
|
|
34
|
+
return {
|
|
35
|
+
isSucceeded: false,
|
|
36
|
+
message: "Необходимо указать заголовок таблицы"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let columns: string[] = tableData.header.columns;
|
|
41
|
+
|
|
42
|
+
var uniqueDislayedColumns = columns.filter((v, i, a) => a.indexOf(v) === i);
|
|
43
|
+
|
|
44
|
+
if (uniqueDislayedColumns.length !== columns.length) {
|
|
45
|
+
return {
|
|
46
|
+
isSucceeded: false,
|
|
47
|
+
message: "Ошибка при обработке разметки таблицы. Обнаружены дубликаты заголовков."
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
isSucceeded: true,
|
|
53
|
+
message: "Ok"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static checkAngularMaterialTableData(tableData: TableData, checkHeaders: boolean = true): BaseApiResponse {
|
|
57
|
+
|
|
58
|
+
if(checkHeaders){
|
|
59
|
+
var checkHeadersResult = this.checkHeaders(tableData);
|
|
60
|
+
|
|
61
|
+
if(!checkHeadersResult.isSucceeded){
|
|
62
|
+
return checkHeadersResult;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let rows: TableRowData[] = tableData.rows;
|
|
67
|
+
let columns: string[] = tableData.header.columns;
|
|
68
|
+
|
|
69
|
+
for (let i = 0; i < rows.length; i++) {
|
|
70
|
+
const row = rows[i];
|
|
71
|
+
|
|
72
|
+
if (row.columns.length !== columns.length) {
|
|
73
|
+
return {
|
|
74
|
+
isSucceeded: false,
|
|
75
|
+
message: `Ошибка при обработке разметки таблицы. `
|
|
76
|
+
+ `Количество колонок в каждой строке таблицы должно соотвествовать количеству колонок указанных в заголовке. `
|
|
77
|
+
+ `В строке таблицы №${i + 1} количество колонок = ${row.columns.length}, а должно быть ${columns.length}.`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
isSucceeded: true,
|
|
84
|
+
message: "Ok"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { HtmlBodyTag } from "../models/models";
|
|
2
|
+
import { HtmlExtractionMethods } from "./HtmlExtractionMethods";
|
|
3
|
+
import { InterfaceBlock } from "./InterfaceBlock";
|
|
4
|
+
import { HtmlRawTagDataConsts } from "./HtmlRawTagDataConsts";
|
|
5
|
+
import { FileImageTagData, FileImageTagDataConsts } from "./ImageMethods";
|
|
6
|
+
import { TextMethods } from "./TextMethods";
|
|
7
|
+
import { SimpleTextTagData } from "./TextSimpleMethods";
|
|
8
|
+
import { ExternalVideoTagDataConsts } from "./VideoMethods";
|
|
9
|
+
|
|
10
|
+
export class BodyTagsExtensions {
|
|
11
|
+
|
|
12
|
+
static getDescription(tagName: string){
|
|
13
|
+
var descriptions = {
|
|
14
|
+
"text": "Текст",
|
|
15
|
+
"h1": "Заголовок 1 уровня",
|
|
16
|
+
"h2": "Заголовок 2 уровня",
|
|
17
|
+
"h3": "Заголовок 3 уровня",
|
|
18
|
+
"h4": "Заголовок 4 уровня",
|
|
19
|
+
"h5": "Заголовок 5 уровня",
|
|
20
|
+
"h6": "Заголовок 6 уровня",
|
|
21
|
+
[FileImageTagDataConsts.TagName]: "Изображение",
|
|
22
|
+
[ExternalVideoTagDataConsts.TagName]: "Внешнее видео YouTube",
|
|
23
|
+
[HtmlRawTagDataConsts.TagName]: "Html разметка"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return descriptions[tagName];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static toHtml(bodyTags: HtmlBodyTag[]): string{
|
|
30
|
+
let htmls = bodyTags.map(x => {
|
|
31
|
+
if(TextMethods.textTags.includes(x.tagDescription.tag)){
|
|
32
|
+
return `<${x.tagDescription.tag} h-align="${x.attributes['h-align']}">${x.innerHtml}</${x.tagDescription.tag}>`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if(x.tagDescription.tag === ExternalVideoTagDataConsts.TagName){
|
|
36
|
+
return `<${x.tagDescription.tag} type="${x.attributes['type']}" link="${x.attributes['link']}">${x.innerHtml}</${x.tagDescription.tag}>`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if(x.tagDescription.tag === "html-raw"){
|
|
40
|
+
return `<${x.tagDescription.tag}>${x.innerHtml}</${x.tagDescription.tag}>`
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return BodyTagsExtensions.imageTagToHtml(x);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
let result = "";
|
|
47
|
+
|
|
48
|
+
for (let index = 0; index < htmls.length; index++) {
|
|
49
|
+
const element = htmls[index];
|
|
50
|
+
|
|
51
|
+
result += element;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static imageTagToHtml(imageTag: HtmlBodyTag){
|
|
58
|
+
|
|
59
|
+
var attrStr = "";
|
|
60
|
+
|
|
61
|
+
var attrValue = imageTag.attributes[FileImageTagDataConsts.FileIdAttrName];
|
|
62
|
+
if(imageTag.attributes.hasOwnProperty(FileImageTagDataConsts.FileIdAttrName) && attrValue){
|
|
63
|
+
attrStr = `${FileImageTagDataConsts.FileIdAttrName}="${attrValue}"`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return `<${FileImageTagDataConsts.TagName} ${attrStr}></${FileImageTagDataConsts.TagName}>`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static getBodyTags(html:string){
|
|
70
|
+
let result = HtmlExtractionMethods.transformHtmlStringToBlocks(html);
|
|
71
|
+
return result.map(x => BodyTagsExtensions.toBodyTag(x));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static sanitizeInnerHtml(html:string):string{
|
|
75
|
+
return html.trim().replace('\n\t', '');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static toBodyTag(data: InterfaceBlock): HtmlBodyTag {
|
|
79
|
+
if (TextMethods.textTags.includes(data.type)) {
|
|
80
|
+
let textTagData = data.data as SimpleTextTagData;
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
presentOrEdit: true,
|
|
84
|
+
tagDescription: {
|
|
85
|
+
tag: textTagData.textTagName,
|
|
86
|
+
displayValue: BodyTagsExtensions.getDescription(data.type)
|
|
87
|
+
},
|
|
88
|
+
attributes: { "h-align": textTagData.horizontalAlignment },
|
|
89
|
+
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(textTagData.html)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if(data.type === FileImageTagDataConsts.TagName){
|
|
94
|
+
|
|
95
|
+
let fileData = data.data as FileImageTagData;
|
|
96
|
+
|
|
97
|
+
let atts = {};
|
|
98
|
+
|
|
99
|
+
if(fileData.fileId){
|
|
100
|
+
atts[FileImageTagDataConsts.FileIdAttrName] = fileData.fileId;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
presentOrEdit: true,
|
|
105
|
+
tagDescription: {
|
|
106
|
+
tag: FileImageTagDataConsts.TagName,
|
|
107
|
+
displayValue: BodyTagsExtensions.getDescription(data.type)
|
|
108
|
+
},
|
|
109
|
+
attributes: atts,
|
|
110
|
+
innerHtml: ""
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if(data.type === ExternalVideoTagDataConsts.TagName){
|
|
115
|
+
let fileData = data.data as ExternalVideoTagDataConsts;
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
presentOrEdit: true,
|
|
119
|
+
tagDescription: {
|
|
120
|
+
tag: ExternalVideoTagDataConsts.TagName,
|
|
121
|
+
displayValue: BodyTagsExtensions.getDescription(data.type)
|
|
122
|
+
},
|
|
123
|
+
attributes: fileData,
|
|
124
|
+
innerHtml: ""
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if(data.type === HtmlRawTagDataConsts.TagName){
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
presentOrEdit: true,
|
|
132
|
+
tagDescription: {
|
|
133
|
+
tag: HtmlRawTagDataConsts.TagName,
|
|
134
|
+
displayValue: BodyTagsExtensions.getDescription(data.type)
|
|
135
|
+
},
|
|
136
|
+
attributes: {},
|
|
137
|
+
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(data.data["innerHTML"])
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
presentOrEdit: true,
|
|
143
|
+
tagDescription: {
|
|
144
|
+
tag: "unsupported-tag",
|
|
145
|
+
displayValue: "Неподдерживаемый тег"
|
|
146
|
+
},
|
|
147
|
+
attributes: { },
|
|
148
|
+
innerHtml: JSON.stringify(data)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|