croco-html 4.1.0 → 4.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/fesm2022/croco-html.mjs +435 -357
- package/fesm2022/croco-html.mjs.map +1 -1
- package/lib/components/editor/text-editor/text-editor.component.d.ts +2 -4
- package/lib/components/editor/visual-editor/DefaultAligments.d.ts +2 -6
- package/lib/components/editor/visual-editor/visual-editor.component.d.ts +3 -6
- package/lib/extensions/TextSimpleMethods.d.ts +0 -3
- package/lib/index.d.ts +7 -7
- package/lib/tag-services/ButtonTagService.d.ts +2 -1
- package/lib/tag-services/CustomWidgetTagService.d.ts +2 -1
- package/lib/tag-services/DownloadButtonTagService.d.ts +2 -1
- package/lib/tag-services/ExternalVideoTagService.d.ts +2 -1
- package/lib/tag-services/FileImageTagService.d.ts +1 -0
- package/lib/tag-services/HtmlRawTagService.d.ts +2 -1
- package/lib/tag-services/IMarkUpTagService.d.ts +9 -0
- package/lib/tag-services/TextTagHtmlMarkupTagService.d.ts +10 -1
- package/package.json +1 -1
package/fesm2022/croco-html.mjs
CHANGED
|
@@ -223,26 +223,415 @@ class ImageMethods {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
226
|
+
class FileImageTagService {
|
|
227
|
+
constructor() {
|
|
228
|
+
this.tagName = FileImageTagDataConsts.TagName;
|
|
229
|
+
this.shortDescription = "Изображение";
|
|
230
|
+
}
|
|
231
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
232
|
+
let fileIdAttr = "";
|
|
233
|
+
let screenMediaRequestAttr = "";
|
|
234
|
+
if (bodyTag.attributes.hasOwnProperty(FileImageTagDataConsts.FileIdAttrName) && bodyTag.attributes[FileImageTagDataConsts.FileIdAttrName]) {
|
|
235
|
+
fileIdAttr = `${FileImageTagDataConsts.FileIdAttrName}="${bodyTag.attributes[FileImageTagDataConsts.FileIdAttrName]}"`;
|
|
236
|
+
}
|
|
237
|
+
if (bodyTag.attributes.hasOwnProperty(FileImageTagDataConsts.ScreenMediaRequest) && bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]) {
|
|
238
|
+
screenMediaRequestAttr = `${FileImageTagDataConsts.ScreenMediaRequest}="${bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]}"`;
|
|
239
|
+
}
|
|
240
|
+
return `<${FileImageTagDataConsts.TagName} ${fileIdAttr} ${screenMediaRequestAttr}></${FileImageTagDataConsts.TagName}>`;
|
|
241
|
+
}
|
|
242
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
243
|
+
let fileId = elem.getAttribute(FileImageTagDataConsts.FileIdAttrName);
|
|
244
|
+
let src = ImageMethods.buildMediumUrl(fileId, options);
|
|
245
|
+
return {
|
|
246
|
+
type: FileImageTagDataConsts.TagName,
|
|
247
|
+
data: {
|
|
248
|
+
src,
|
|
249
|
+
fileId: fileId,
|
|
250
|
+
screenMediaRequest: elem.getAttribute(FileImageTagDataConsts.ScreenMediaRequest)
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
toBodyTag(data) {
|
|
255
|
+
let fileData = data.data;
|
|
256
|
+
let attrs = {};
|
|
257
|
+
if (fileData.fileId) {
|
|
258
|
+
attrs[FileImageTagDataConsts.FileIdAttrName] = fileData.fileId;
|
|
259
|
+
}
|
|
260
|
+
if (fileData.screenMediaRequest) {
|
|
261
|
+
attrs[FileImageTagDataConsts.ScreenMediaRequest] = fileData.screenMediaRequest;
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
presentOrEdit: true,
|
|
265
|
+
tagDescription: {
|
|
266
|
+
tag: FileImageTagDataConsts.TagName,
|
|
267
|
+
displayValue: this.shortDescription,
|
|
268
|
+
isCustom: false
|
|
269
|
+
},
|
|
270
|
+
attributes: attrs,
|
|
271
|
+
innerHtml: ""
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
getDefaultValue() {
|
|
275
|
+
return {
|
|
276
|
+
tagDescription: {
|
|
277
|
+
tag: this.tagName,
|
|
278
|
+
displayValue: this.shortDescription,
|
|
279
|
+
isCustom: false
|
|
280
|
+
},
|
|
281
|
+
attributes: {
|
|
282
|
+
[FileImageTagDataConsts.FileIdAttrName]: null,
|
|
283
|
+
[FileImageTagDataConsts.ScreenMediaRequest]: FileImageTagDataConsts.DefaultValueForFileImage
|
|
284
|
+
},
|
|
285
|
+
presentOrEdit: false,
|
|
286
|
+
innerHtml: "",
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
237
290
|
|
|
291
|
+
var TextAlignment;
|
|
292
|
+
(function (TextAlignment) {
|
|
293
|
+
TextAlignment["Left"] = "left";
|
|
294
|
+
TextAlignment["Center"] = "center";
|
|
295
|
+
TextAlignment["Right"] = "right";
|
|
296
|
+
})(TextAlignment || (TextAlignment = {}));
|
|
238
297
|
class TextTagDataConsts {
|
|
239
298
|
static { this.HAlign = "h-align"; }
|
|
240
299
|
}
|
|
300
|
+
class TextTagHtmlMarkupTagService {
|
|
301
|
+
constructor(tagName, shortDescription) {
|
|
302
|
+
this.tagName = "text";
|
|
303
|
+
this.shortDescription = "T";
|
|
304
|
+
this.tagName = tagName;
|
|
305
|
+
this.shortDescription = shortDescription;
|
|
306
|
+
}
|
|
307
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
308
|
+
return `<${this.tagName} h-align="${bodyTag.attributes[TextTagDataConsts.HAlign]}">${bodyTag.innerHtml}</${this.tagName}>`;
|
|
309
|
+
}
|
|
310
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
311
|
+
return TextSimpleMethods.ExtractTextTag(elem);
|
|
312
|
+
}
|
|
313
|
+
toBodyTag(data) {
|
|
314
|
+
let textTagData = data.data;
|
|
315
|
+
return {
|
|
316
|
+
presentOrEdit: true,
|
|
317
|
+
tagDescription: {
|
|
318
|
+
tag: this.tagName,
|
|
319
|
+
displayValue: this.shortDescription,
|
|
320
|
+
isCustom: false
|
|
321
|
+
},
|
|
322
|
+
attributes: { [TextTagDataConsts.HAlign]: textTagData.horizontalAlignment },
|
|
323
|
+
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(textTagData.html)
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
getDefaultValue(props) {
|
|
327
|
+
return {
|
|
328
|
+
tagDescription: {
|
|
329
|
+
tag: this.tagName,
|
|
330
|
+
displayValue: this.shortDescription,
|
|
331
|
+
isCustom: false
|
|
332
|
+
},
|
|
333
|
+
attributes: {
|
|
334
|
+
[TextTagDataConsts.HAlign]: TextAlignment.Left
|
|
335
|
+
},
|
|
336
|
+
presentOrEdit: false,
|
|
337
|
+
innerHtml: "",
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const defaultLinkYouTube = "https://www.youtube.com/embed/4CtSAnJDfsI?si=scyBNJa0Hs2t5aLE";
|
|
343
|
+
const defaultLinkVk = "https://vk.com/video_ext.php?oid=-22822305&id=456241864&hd=2";
|
|
344
|
+
class ExternalVideoTagService {
|
|
345
|
+
constructor() {
|
|
346
|
+
this.tagName = ExternalVideoTagDataConsts.TagName;
|
|
347
|
+
this.shortDescription = "Видео";
|
|
348
|
+
}
|
|
349
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
350
|
+
let useResponsiveWrapperAttr = '';
|
|
351
|
+
if (bodyTag.attributes[ExternalVideoTagDataConsts.VideoTypeAttrName] === ExternalVideoSupportedTypes.Code) {
|
|
352
|
+
useResponsiveWrapperAttr = `${ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName}="${bodyTag.attributes[ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName] || false}"`;
|
|
353
|
+
}
|
|
354
|
+
return `<${bodyTag.tagDescription.tag} ${useResponsiveWrapperAttr} type="${bodyTag.attributes[ExternalVideoTagDataConsts.VideoTypeAttrName]}" link="${bodyTag.attributes[ExternalVideoTagDataConsts.LinkAttrName]}">${bodyTag.innerHtml}</${bodyTag.tagDescription.tag}>`;
|
|
355
|
+
}
|
|
356
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
357
|
+
return {
|
|
358
|
+
type: ExternalVideoTagDataConsts.TagName,
|
|
359
|
+
data: {
|
|
360
|
+
type: elem.getAttribute(ExternalVideoTagDataConsts.VideoTypeAttrName),
|
|
361
|
+
link: elem.getAttribute(ExternalVideoTagDataConsts.LinkAttrName),
|
|
362
|
+
useResponsiveWrapper: elem.getAttribute(ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName) !== 'false',
|
|
363
|
+
innerHtml: elem.innerHTML
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
toBodyTag(data) {
|
|
368
|
+
let fileData = data.data;
|
|
369
|
+
return {
|
|
370
|
+
presentOrEdit: true,
|
|
371
|
+
tagDescription: {
|
|
372
|
+
tag: data.type,
|
|
373
|
+
displayValue: this.shortDescription,
|
|
374
|
+
isCustom: false
|
|
375
|
+
},
|
|
376
|
+
attributes: fileData,
|
|
377
|
+
innerHtml: ""
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
getDefaultValue(props) {
|
|
381
|
+
let attrs = {};
|
|
382
|
+
let innerHtml = "";
|
|
383
|
+
attrs[ExternalVideoTagDataConsts.VideoTypeAttrName] = props.selectedVideoPlayer;
|
|
384
|
+
attrs[ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName] = false;
|
|
385
|
+
attrs[ExternalVideoTagDataConsts.LinkAttrName] = props.selectedVideoPlayer === ExternalVideoSupportedTypes.Code ? '' :
|
|
386
|
+
props.selectedVideoPlayer === ExternalVideoSupportedTypes.VkVideo
|
|
387
|
+
? defaultLinkVk
|
|
388
|
+
: defaultLinkYouTube;
|
|
389
|
+
if (props.selectedVideoPlayer === ExternalVideoSupportedTypes.Code) {
|
|
390
|
+
innerHtml = props.htmlRaw;
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
tagDescription: {
|
|
394
|
+
tag: this.tagName,
|
|
395
|
+
displayValue: this.shortDescription,
|
|
396
|
+
isCustom: false
|
|
397
|
+
},
|
|
398
|
+
attributes: attrs,
|
|
399
|
+
presentOrEdit: false,
|
|
400
|
+
innerHtml: "",
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
class HtmlRawTagDataConsts {
|
|
406
|
+
static { this.TagName = "html-raw"; }
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
class HtmlRawTagService {
|
|
410
|
+
constructor() {
|
|
411
|
+
this.tagName = HtmlRawTagDataConsts.TagName;
|
|
412
|
+
this.shortDescription = "Разметка";
|
|
413
|
+
}
|
|
414
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
415
|
+
return `<${this.tagName}>${bodyTag.innerHtml}</${this.tagName}>`;
|
|
416
|
+
}
|
|
417
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
418
|
+
return {
|
|
419
|
+
type: HtmlRawTagDataConsts.TagName,
|
|
420
|
+
data: {
|
|
421
|
+
innerHTML: elem.innerHTML
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
toBodyTag(data) {
|
|
426
|
+
return {
|
|
427
|
+
presentOrEdit: true,
|
|
428
|
+
tagDescription: {
|
|
429
|
+
tag: HtmlRawTagDataConsts.TagName,
|
|
430
|
+
displayValue: this.shortDescription,
|
|
431
|
+
isCustom: false
|
|
432
|
+
},
|
|
433
|
+
attributes: {},
|
|
434
|
+
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(data.data["innerHTML"])
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
getDefaultValue(props) {
|
|
438
|
+
return {
|
|
439
|
+
tagDescription: {
|
|
440
|
+
tag: this.tagName,
|
|
441
|
+
displayValue: this.shortDescription,
|
|
442
|
+
isCustom: false
|
|
443
|
+
},
|
|
444
|
+
attributes: {},
|
|
445
|
+
presentOrEdit: false,
|
|
446
|
+
innerHtml: props.htmlRaw,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const defaultLinkForDownload = "https://storage.yandexcloud.net/mega-academy/presentation.pdf";
|
|
452
|
+
class DownloadButtonTagDataConsts {
|
|
453
|
+
static { this.TagName = "download-file-button"; }
|
|
454
|
+
static { this.TitleAttrName = "title"; }
|
|
455
|
+
static { this.LinkAttrName = "link"; }
|
|
456
|
+
}
|
|
457
|
+
class DownloadButtonTagService {
|
|
458
|
+
constructor() {
|
|
459
|
+
this.tagName = DownloadButtonTagDataConsts.TagName;
|
|
460
|
+
this.shortDescription = "Кнопка для скачивания";
|
|
461
|
+
}
|
|
462
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
463
|
+
return `<${this.tagName} title="${bodyTag.attributes[DownloadButtonTagDataConsts.TitleAttrName]}" link="${bodyTag.attributes[DownloadButtonTagDataConsts.LinkAttrName]}"></${this.tagName}>`;
|
|
464
|
+
}
|
|
465
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
466
|
+
return {
|
|
467
|
+
type: DownloadButtonTagDataConsts.TagName,
|
|
468
|
+
data: {
|
|
469
|
+
title: elem.getAttribute(DownloadButtonTagDataConsts.TitleAttrName),
|
|
470
|
+
link: elem.getAttribute(DownloadButtonTagDataConsts.LinkAttrName)
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
toBodyTag(data) {
|
|
475
|
+
let fileData = data.data;
|
|
476
|
+
return {
|
|
477
|
+
presentOrEdit: true,
|
|
478
|
+
tagDescription: {
|
|
479
|
+
tag: data.type,
|
|
480
|
+
displayValue: this.shortDescription,
|
|
481
|
+
isCustom: false
|
|
482
|
+
},
|
|
483
|
+
attributes: fileData,
|
|
484
|
+
innerHtml: ""
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
getDefaultValue(props) {
|
|
488
|
+
return {
|
|
489
|
+
tagDescription: {
|
|
490
|
+
tag: this.tagName,
|
|
491
|
+
displayValue: this.shortDescription,
|
|
492
|
+
isCustom: false
|
|
493
|
+
},
|
|
494
|
+
attributes: {
|
|
495
|
+
[DownloadButtonTagDataConsts.LinkAttrName]: defaultLinkForDownload,
|
|
496
|
+
[DownloadButtonTagDataConsts.TitleAttrName]: 'Скачать'
|
|
497
|
+
},
|
|
498
|
+
presentOrEdit: false,
|
|
499
|
+
innerHtml: props.htmlRaw,
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
class ButtonTagDataConsts {
|
|
505
|
+
static { this.TagName = "button"; }
|
|
506
|
+
static { this.TextAttrName = "text"; }
|
|
507
|
+
static { this.TypeAttrName = "type"; }
|
|
508
|
+
static { this.ClickAttrName = "click"; }
|
|
509
|
+
}
|
|
510
|
+
class ButtonTagService {
|
|
511
|
+
constructor() {
|
|
512
|
+
this.tagName = ButtonTagDataConsts.TagName;
|
|
513
|
+
this.shortDescription = "Кнопка";
|
|
514
|
+
}
|
|
515
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
516
|
+
let atts = bodyTag.attributes;
|
|
517
|
+
return `<${this.tagName} text="${atts[ButtonTagDataConsts.TextAttrName]}" type="${atts[ButtonTagDataConsts.TypeAttrName]}" click="${atts[ButtonTagDataConsts.ClickAttrName]}"></${this.tagName}>`;
|
|
518
|
+
}
|
|
519
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
520
|
+
return {
|
|
521
|
+
type: ButtonTagDataConsts.TagName,
|
|
522
|
+
data: {
|
|
523
|
+
text: elem.getAttribute(ButtonTagDataConsts.TextAttrName),
|
|
524
|
+
type: elem.getAttribute(ButtonTagDataConsts.TypeAttrName),
|
|
525
|
+
click: elem.getAttribute(ButtonTagDataConsts.ClickAttrName)
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
toBodyTag(data) {
|
|
530
|
+
let fileData = data.data;
|
|
531
|
+
return {
|
|
532
|
+
presentOrEdit: true,
|
|
533
|
+
tagDescription: {
|
|
534
|
+
tag: data.type,
|
|
535
|
+
displayValue: this.shortDescription,
|
|
536
|
+
isCustom: false
|
|
537
|
+
},
|
|
538
|
+
attributes: fileData,
|
|
539
|
+
innerHtml: ""
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
getDefaultValue(props) {
|
|
543
|
+
return {
|
|
544
|
+
tagDescription: {
|
|
545
|
+
tag: this.tagName,
|
|
546
|
+
displayValue: this.shortDescription,
|
|
547
|
+
isCustom: false
|
|
548
|
+
},
|
|
549
|
+
attributes: {
|
|
550
|
+
[ButtonTagDataConsts.ClickAttrName]: '',
|
|
551
|
+
[ButtonTagDataConsts.TypeAttrName]: 'button',
|
|
552
|
+
[ButtonTagDataConsts.TextAttrName]: 'Кнопка'
|
|
553
|
+
},
|
|
554
|
+
presentOrEdit: false,
|
|
555
|
+
innerHtml: props.htmlRaw,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
class CustomWidgetTagDataConsts {
|
|
561
|
+
static { this.TagName = "custom-widget"; }
|
|
562
|
+
static { this.TypeAttrName = "type"; }
|
|
563
|
+
static { this.DataIdAttrName = "data-id"; }
|
|
564
|
+
static { this.WidgetIdAttrName = "widget-id"; }
|
|
565
|
+
}
|
|
566
|
+
class CustomWidgetTagService {
|
|
567
|
+
constructor() {
|
|
568
|
+
this.tagName = CustomWidgetTagDataConsts.TagName;
|
|
569
|
+
this.shortDescription = "Виджет";
|
|
570
|
+
}
|
|
571
|
+
bodyTagToHtmlStringConverter(bodyTag) {
|
|
572
|
+
let attrs = bodyTag.attributes;
|
|
573
|
+
return `<${this.tagName} type="${attrs[CustomWidgetTagDataConsts.TypeAttrName]}" data-id="${attrs[CustomWidgetTagDataConsts.DataIdAttrName]}" widget-id="${attrs[CustomWidgetTagDataConsts.WidgetIdAttrName]}"></${this.tagName}>`;
|
|
574
|
+
}
|
|
575
|
+
extractBlockFromHtmlElement(elem, options) {
|
|
576
|
+
return {
|
|
577
|
+
type: CustomWidgetTagDataConsts.TagName,
|
|
578
|
+
data: {
|
|
579
|
+
type: elem.getAttribute(CustomWidgetTagDataConsts.TypeAttrName),
|
|
580
|
+
dataId: elem.getAttribute(CustomWidgetTagDataConsts.DataIdAttrName),
|
|
581
|
+
widgetId: elem.getAttribute(CustomWidgetTagDataConsts.WidgetIdAttrName)
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
toBodyTag(data) {
|
|
586
|
+
let customWidgetTagData = data.data;
|
|
587
|
+
return {
|
|
588
|
+
presentOrEdit: true,
|
|
589
|
+
tagDescription: {
|
|
590
|
+
tag: data.type,
|
|
591
|
+
displayValue: this.shortDescription,
|
|
592
|
+
isCustom: false
|
|
593
|
+
},
|
|
594
|
+
attributes: customWidgetTagData,
|
|
595
|
+
innerHtml: ""
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
getDefaultValue(props) {
|
|
599
|
+
return {
|
|
600
|
+
tagDescription: {
|
|
601
|
+
tag: this.tagName,
|
|
602
|
+
displayValue: this.shortDescription,
|
|
603
|
+
isCustom: false
|
|
604
|
+
},
|
|
605
|
+
attributes: {
|
|
606
|
+
[CustomWidgetTagDataConsts.TypeAttrName]: 'example-type',
|
|
607
|
+
[CustomWidgetTagDataConsts.DataIdAttrName]: 'example-data-id',
|
|
608
|
+
[CustomWidgetTagDataConsts.WidgetIdAttrName]: 'example-widget-id'
|
|
609
|
+
},
|
|
610
|
+
presentOrEdit: false,
|
|
611
|
+
innerHtml: props.htmlRaw,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
static ExtractCustomWidgetTagData(attributes) {
|
|
615
|
+
return {
|
|
616
|
+
type: attributes[CustomWidgetTagDataConsts.TypeAttrName],
|
|
617
|
+
dataId: attributes[CustomWidgetTagDataConsts.DataIdAttrName],
|
|
618
|
+
widgetId: attributes[CustomWidgetTagDataConsts.WidgetIdAttrName]
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
static ExtractCustomWidgetAttributes(customWidgetTagData) {
|
|
622
|
+
return {
|
|
623
|
+
[CustomWidgetTagDataConsts.TypeAttrName]: customWidgetTagData.type,
|
|
624
|
+
[CustomWidgetTagDataConsts.DataIdAttrName]: customWidgetTagData.dataId,
|
|
625
|
+
[CustomWidgetTagDataConsts.WidgetIdAttrName]: customWidgetTagData.widgetId
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
241
630
|
const TextTag = "text";
|
|
242
631
|
class TextSimpleMethods {
|
|
243
632
|
static { this.supportedTags = ["sup", "sub", "strong", "b", "i", "u"]; }
|
|
244
633
|
static ExtractTextTag(elem) {
|
|
245
|
-
var hAlignValue = elem.getAttribute("h-align") ??
|
|
634
|
+
var hAlignValue = elem.getAttribute("h-align") ?? TextAlignment.Left;
|
|
246
635
|
var data = {
|
|
247
636
|
textTagName: elem.tagName.toLowerCase(),
|
|
248
637
|
text: elem.innerText.trim().replace('\n\t', ''),
|
|
@@ -263,7 +652,7 @@ class TextSimpleMethods {
|
|
|
263
652
|
if (result.data.html === '\n') {
|
|
264
653
|
result.data.html = '';
|
|
265
654
|
}
|
|
266
|
-
var alignmentVals = [
|
|
655
|
+
var alignmentVals = [TextAlignment.Left, TextAlignment.Right, TextAlignment.Center];
|
|
267
656
|
if (alignmentVals.indexOf(hAlignValue) < 0) {
|
|
268
657
|
result.data.validationResult = {
|
|
269
658
|
isSucceeded: false,
|
|
@@ -516,74 +905,16 @@ class HtmlExtractionMethods {
|
|
|
516
905
|
}
|
|
517
906
|
return data;
|
|
518
907
|
}
|
|
519
|
-
static transformHtmlStringToBlocks(value, options) {
|
|
520
|
-
if (value === undefined || value === null) {
|
|
521
|
-
return [];
|
|
522
|
-
}
|
|
523
|
-
value = value
|
|
524
|
-
.replace('\n', '')
|
|
525
|
-
.replace('\t', '');
|
|
526
|
-
var div = document.createElement("div");
|
|
527
|
-
div.innerHTML = value;
|
|
528
|
-
return this.transformHtmlElementToBlocks(div, options);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
class HtmlRawTagDataConsts {
|
|
533
|
-
static { this.TagName = "html-raw"; }
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
class CustomWidgetTagDataConsts {
|
|
537
|
-
static { this.TagName = "custom-widget"; }
|
|
538
|
-
static { this.TypeAttrName = "type"; }
|
|
539
|
-
static { this.DataIdAttrName = "data-id"; }
|
|
540
|
-
static { this.WidgetIdAttrName = "widget-id"; }
|
|
541
|
-
}
|
|
542
|
-
class CustomWidgetTagService {
|
|
543
|
-
constructor() {
|
|
544
|
-
this.tagName = CustomWidgetTagDataConsts.TagName;
|
|
545
|
-
this.shortDescription = "Виджет";
|
|
546
|
-
}
|
|
547
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
548
|
-
let attrs = bodyTag.attributes;
|
|
549
|
-
return `<${this.tagName} type="${attrs[CustomWidgetTagDataConsts.TypeAttrName]}" data-id="${attrs[CustomWidgetTagDataConsts.DataIdAttrName]}" widget-id="${attrs[CustomWidgetTagDataConsts.WidgetIdAttrName]}"></${this.tagName}>`;
|
|
550
|
-
}
|
|
551
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
552
|
-
return {
|
|
553
|
-
type: CustomWidgetTagDataConsts.TagName,
|
|
554
|
-
data: {
|
|
555
|
-
type: elem.getAttribute(CustomWidgetTagDataConsts.TypeAttrName),
|
|
556
|
-
dataId: elem.getAttribute(CustomWidgetTagDataConsts.DataIdAttrName),
|
|
557
|
-
widgetId: elem.getAttribute(CustomWidgetTagDataConsts.WidgetIdAttrName)
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
toBodyTag(data) {
|
|
562
|
-
let customWidgetTagData = data.data;
|
|
563
|
-
return {
|
|
564
|
-
presentOrEdit: true,
|
|
565
|
-
tagDescription: {
|
|
566
|
-
tag: data.type,
|
|
567
|
-
displayValue: this.shortDescription,
|
|
568
|
-
isCustom: false
|
|
569
|
-
},
|
|
570
|
-
attributes: customWidgetTagData,
|
|
571
|
-
innerHtml: ""
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
static ExtractCustomWidgetTagData(attributes) {
|
|
575
|
-
return {
|
|
576
|
-
type: attributes[CustomWidgetTagDataConsts.TypeAttrName],
|
|
577
|
-
dataId: attributes[CustomWidgetTagDataConsts.DataIdAttrName],
|
|
578
|
-
widgetId: attributes[CustomWidgetTagDataConsts.WidgetIdAttrName]
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
static ExtractCustomWidgetAttributes(customWidgetTagData) {
|
|
582
|
-
return {
|
|
583
|
-
[CustomWidgetTagDataConsts.TypeAttrName]: customWidgetTagData.type,
|
|
584
|
-
[CustomWidgetTagDataConsts.DataIdAttrName]: customWidgetTagData.dataId,
|
|
585
|
-
[CustomWidgetTagDataConsts.WidgetIdAttrName]: customWidgetTagData.widgetId
|
|
586
|
-
};
|
|
908
|
+
static transformHtmlStringToBlocks(value, options) {
|
|
909
|
+
if (value === undefined || value === null) {
|
|
910
|
+
return [];
|
|
911
|
+
}
|
|
912
|
+
value = value
|
|
913
|
+
.replace('\n', '')
|
|
914
|
+
.replace('\t', '');
|
|
915
|
+
var div = document.createElement("div");
|
|
916
|
+
div.innerHTML = value;
|
|
917
|
+
return this.transformHtmlElementToBlocks(div, options);
|
|
587
918
|
}
|
|
588
919
|
}
|
|
589
920
|
|
|
@@ -643,229 +974,6 @@ class Tags {
|
|
|
643
974
|
static { this.CustomWidget = CustomWidgetTagDataConsts.TagName; }
|
|
644
975
|
}
|
|
645
976
|
|
|
646
|
-
class FileImageTagService {
|
|
647
|
-
constructor() {
|
|
648
|
-
this.tagName = FileImageTagDataConsts.TagName;
|
|
649
|
-
this.shortDescription = "Изображение";
|
|
650
|
-
}
|
|
651
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
652
|
-
let fileIdAttr = "";
|
|
653
|
-
let screenMediaRequestAttr = "";
|
|
654
|
-
if (bodyTag.attributes.hasOwnProperty(FileImageTagDataConsts.FileIdAttrName) && bodyTag.attributes[FileImageTagDataConsts.FileIdAttrName]) {
|
|
655
|
-
fileIdAttr = `${FileImageTagDataConsts.FileIdAttrName}="${bodyTag.attributes[FileImageTagDataConsts.FileIdAttrName]}"`;
|
|
656
|
-
}
|
|
657
|
-
if (bodyTag.attributes.hasOwnProperty(FileImageTagDataConsts.ScreenMediaRequest) && bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]) {
|
|
658
|
-
screenMediaRequestAttr = `${FileImageTagDataConsts.ScreenMediaRequest}="${bodyTag.attributes[FileImageTagDataConsts.ScreenMediaRequest]}"`;
|
|
659
|
-
}
|
|
660
|
-
return `<${FileImageTagDataConsts.TagName} ${fileIdAttr} ${screenMediaRequestAttr}></${FileImageTagDataConsts.TagName}>`;
|
|
661
|
-
}
|
|
662
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
663
|
-
let fileId = elem.getAttribute(FileImageTagDataConsts.FileIdAttrName);
|
|
664
|
-
let src = ImageMethods.buildMediumUrl(fileId, options);
|
|
665
|
-
return {
|
|
666
|
-
type: FileImageTagDataConsts.TagName,
|
|
667
|
-
data: {
|
|
668
|
-
src,
|
|
669
|
-
fileId: fileId,
|
|
670
|
-
screenMediaRequest: elem.getAttribute(FileImageTagDataConsts.ScreenMediaRequest)
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
toBodyTag(data) {
|
|
675
|
-
let fileData = data.data;
|
|
676
|
-
let attrs = {};
|
|
677
|
-
if (fileData.fileId) {
|
|
678
|
-
attrs[FileImageTagDataConsts.FileIdAttrName] = fileData.fileId;
|
|
679
|
-
}
|
|
680
|
-
if (fileData.screenMediaRequest) {
|
|
681
|
-
attrs[FileImageTagDataConsts.ScreenMediaRequest] = fileData.screenMediaRequest;
|
|
682
|
-
}
|
|
683
|
-
return {
|
|
684
|
-
presentOrEdit: true,
|
|
685
|
-
tagDescription: {
|
|
686
|
-
tag: FileImageTagDataConsts.TagName,
|
|
687
|
-
displayValue: this.shortDescription,
|
|
688
|
-
isCustom: false
|
|
689
|
-
},
|
|
690
|
-
attributes: attrs,
|
|
691
|
-
innerHtml: ""
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
class TextTagHtmlMarkupTagService {
|
|
697
|
-
constructor(tagName, shortDescription) {
|
|
698
|
-
this.tagName = "text";
|
|
699
|
-
this.shortDescription = "T";
|
|
700
|
-
this.tagName = tagName;
|
|
701
|
-
this.shortDescription = shortDescription;
|
|
702
|
-
}
|
|
703
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
704
|
-
return `<${this.tagName} h-align="${bodyTag.attributes[TextTagDataConsts.HAlign]}">${bodyTag.innerHtml}</${this.tagName}>`;
|
|
705
|
-
}
|
|
706
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
707
|
-
return TextSimpleMethods.ExtractTextTag(elem);
|
|
708
|
-
}
|
|
709
|
-
toBodyTag(data) {
|
|
710
|
-
let textTagData = data.data;
|
|
711
|
-
return {
|
|
712
|
-
presentOrEdit: true,
|
|
713
|
-
tagDescription: {
|
|
714
|
-
tag: this.tagName,
|
|
715
|
-
displayValue: this.shortDescription,
|
|
716
|
-
isCustom: false
|
|
717
|
-
},
|
|
718
|
-
attributes: { "h-align": textTagData.horizontalAlignment },
|
|
719
|
-
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(textTagData.html)
|
|
720
|
-
};
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
class ExternalVideoTagService {
|
|
725
|
-
constructor() {
|
|
726
|
-
this.tagName = ExternalVideoTagDataConsts.TagName;
|
|
727
|
-
this.shortDescription = "Видео";
|
|
728
|
-
}
|
|
729
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
730
|
-
let useResponsiveWrapperAttr = '';
|
|
731
|
-
if (bodyTag.attributes[ExternalVideoTagDataConsts.VideoTypeAttrName] === ExternalVideoSupportedTypes.Code) {
|
|
732
|
-
useResponsiveWrapperAttr = `${ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName}="${bodyTag.attributes[ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName] || false}"`;
|
|
733
|
-
}
|
|
734
|
-
return `<${bodyTag.tagDescription.tag} ${useResponsiveWrapperAttr} type="${bodyTag.attributes[ExternalVideoTagDataConsts.VideoTypeAttrName]}" link="${bodyTag.attributes[ExternalVideoTagDataConsts.LinkAttrName]}">${bodyTag.innerHtml}</${bodyTag.tagDescription.tag}>`;
|
|
735
|
-
}
|
|
736
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
737
|
-
return {
|
|
738
|
-
type: ExternalVideoTagDataConsts.TagName,
|
|
739
|
-
data: {
|
|
740
|
-
type: elem.getAttribute(ExternalVideoTagDataConsts.VideoTypeAttrName),
|
|
741
|
-
link: elem.getAttribute(ExternalVideoTagDataConsts.LinkAttrName),
|
|
742
|
-
useResponsiveWrapper: elem.getAttribute(ExternalVideoTagDataConsts.UseResponsiveWrapperAttrName) !== 'false',
|
|
743
|
-
innerHtml: elem.innerHTML
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
toBodyTag(data) {
|
|
748
|
-
let fileData = data.data;
|
|
749
|
-
return {
|
|
750
|
-
presentOrEdit: true,
|
|
751
|
-
tagDescription: {
|
|
752
|
-
tag: data.type,
|
|
753
|
-
displayValue: this.shortDescription,
|
|
754
|
-
isCustom: false
|
|
755
|
-
},
|
|
756
|
-
attributes: fileData,
|
|
757
|
-
innerHtml: ""
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
class HtmlRawTagService {
|
|
763
|
-
constructor() {
|
|
764
|
-
this.tagName = HtmlRawTagDataConsts.TagName;
|
|
765
|
-
this.shortDescription = "Разметка";
|
|
766
|
-
}
|
|
767
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
768
|
-
return `<${this.tagName}>${bodyTag.innerHtml}</${this.tagName}>`;
|
|
769
|
-
}
|
|
770
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
771
|
-
return {
|
|
772
|
-
type: HtmlRawTagDataConsts.TagName,
|
|
773
|
-
data: {
|
|
774
|
-
innerHTML: elem.innerHTML
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
toBodyTag(data) {
|
|
779
|
-
return {
|
|
780
|
-
presentOrEdit: true,
|
|
781
|
-
tagDescription: {
|
|
782
|
-
tag: HtmlRawTagDataConsts.TagName,
|
|
783
|
-
displayValue: this.shortDescription,
|
|
784
|
-
isCustom: false
|
|
785
|
-
},
|
|
786
|
-
attributes: {},
|
|
787
|
-
innerHtml: BodyTagsExtensions.sanitizeInnerHtml(data.data["innerHTML"])
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
class DownloadButtonTagDataConsts {
|
|
793
|
-
static { this.TagName = "download-file-button"; }
|
|
794
|
-
static { this.TitleAttrName = "title"; }
|
|
795
|
-
static { this.LinkAttrName = "link"; }
|
|
796
|
-
}
|
|
797
|
-
class DownloadButtonTagService {
|
|
798
|
-
constructor() {
|
|
799
|
-
this.tagName = DownloadButtonTagDataConsts.TagName;
|
|
800
|
-
this.shortDescription = "Кнопка для скачивания";
|
|
801
|
-
}
|
|
802
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
803
|
-
return `<${this.tagName} title="${bodyTag.attributes[DownloadButtonTagDataConsts.TitleAttrName]}" link="${bodyTag.attributes[DownloadButtonTagDataConsts.LinkAttrName]}"></${this.tagName}>`;
|
|
804
|
-
}
|
|
805
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
806
|
-
return {
|
|
807
|
-
type: DownloadButtonTagDataConsts.TagName,
|
|
808
|
-
data: {
|
|
809
|
-
title: elem.getAttribute(DownloadButtonTagDataConsts.TitleAttrName),
|
|
810
|
-
link: elem.getAttribute(DownloadButtonTagDataConsts.LinkAttrName)
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
toBodyTag(data) {
|
|
815
|
-
let fileData = data.data;
|
|
816
|
-
return {
|
|
817
|
-
presentOrEdit: true,
|
|
818
|
-
tagDescription: {
|
|
819
|
-
tag: data.type,
|
|
820
|
-
displayValue: this.shortDescription,
|
|
821
|
-
isCustom: false
|
|
822
|
-
},
|
|
823
|
-
attributes: fileData,
|
|
824
|
-
innerHtml: ""
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
class ButtonTagDataConsts {
|
|
830
|
-
static { this.TagName = "button"; }
|
|
831
|
-
static { this.TextAttrName = "text"; }
|
|
832
|
-
static { this.TypeAttrName = "type"; }
|
|
833
|
-
static { this.ClickAttrName = "click"; }
|
|
834
|
-
}
|
|
835
|
-
class ButtonTagService {
|
|
836
|
-
constructor() {
|
|
837
|
-
this.tagName = ButtonTagDataConsts.TagName;
|
|
838
|
-
this.shortDescription = "Кнопка";
|
|
839
|
-
}
|
|
840
|
-
bodyTagToHtmlStringConverter(bodyTag) {
|
|
841
|
-
let atts = bodyTag.attributes;
|
|
842
|
-
return `<${this.tagName} text="${atts[ButtonTagDataConsts.TextAttrName]}" type="${atts[ButtonTagDataConsts.TypeAttrName]}" click="${atts[ButtonTagDataConsts.ClickAttrName]}"></${this.tagName}>`;
|
|
843
|
-
}
|
|
844
|
-
extractBlockFromHtmlElement(elem, options) {
|
|
845
|
-
return {
|
|
846
|
-
type: ButtonTagDataConsts.TagName,
|
|
847
|
-
data: {
|
|
848
|
-
text: elem.getAttribute(ButtonTagDataConsts.TextAttrName),
|
|
849
|
-
type: elem.getAttribute(ButtonTagDataConsts.TypeAttrName),
|
|
850
|
-
click: elem.getAttribute(ButtonTagDataConsts.ClickAttrName)
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
toBodyTag(data) {
|
|
855
|
-
let fileData = data.data;
|
|
856
|
-
return {
|
|
857
|
-
presentOrEdit: true,
|
|
858
|
-
tagDescription: {
|
|
859
|
-
tag: data.type,
|
|
860
|
-
displayValue: this.shortDescription,
|
|
861
|
-
isCustom: false
|
|
862
|
-
},
|
|
863
|
-
attributes: fileData,
|
|
864
|
-
innerHtml: ""
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
977
|
class BodyTagsExtensions {
|
|
870
978
|
static { this.tagServices = {
|
|
871
979
|
[TextTags.text]: new TextTagHtmlMarkupTagService("text", "T"),
|
|
@@ -1990,6 +2098,12 @@ class DefaultTags {
|
|
|
1990
2098
|
}
|
|
1991
2099
|
}
|
|
1992
2100
|
|
|
2101
|
+
const AlignmentsData = [
|
|
2102
|
+
{ value: TextAlignment.Left, text: 'Слева' },
|
|
2103
|
+
{ value: TextAlignment.Center, text: 'По центру' },
|
|
2104
|
+
{ value: TextAlignment.Right, text: 'Справа' },
|
|
2105
|
+
];
|
|
2106
|
+
|
|
1993
2107
|
class DownloadFileButtonEditorComponent {
|
|
1994
2108
|
constructor() {
|
|
1995
2109
|
this.onTagUpdated = new EventEmitter();
|
|
@@ -2028,8 +2142,6 @@ class TextEditorComponent {
|
|
|
2028
2142
|
constructor() {
|
|
2029
2143
|
this.onTagUpdated = new EventEmitter();
|
|
2030
2144
|
}
|
|
2031
|
-
ngOnInit() {
|
|
2032
|
-
}
|
|
2033
2145
|
getInnerHtml() {
|
|
2034
2146
|
return `<${this.tag.tagDescription.tag}>${this.tag.innerHtml}<${this.tag.tagDescription.tag}/>`;
|
|
2035
2147
|
}
|
|
@@ -2039,7 +2151,7 @@ class TextEditorComponent {
|
|
|
2039
2151
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TextEditorComponent, decorators: [{
|
|
2040
2152
|
type: Component,
|
|
2041
2153
|
args: [{ selector: 'croco-html-text-editor', standalone: true, imports: [MatButtonToggleGroup, FormsModule, MatButtonToggle, MatIcon, MatFormField, MatLabel, MatInput, CdkTextareaAutosize], template: "@if (tag.presentOrEdit) {\n <div>\n <div style=\"height: 10px;\">\n </div>\n @if (tag.attributes['h-align'] === 'left') {\n <div style=\"text-align: left;\" [innerHtml]=\"getInnerHtml()\">\n </div>\n }\n @if (tag.attributes['h-align'] === 'right') {\n <div style=\"text-align: right;\" [innerHtml]=\"getInnerHtml()\">\n </div>\n }\n @if (tag.attributes['h-align'] === 'center') {\n <div style=\"text-align: center;\" [innerHtml]=\"getInnerHtml()\">\n </div>\n }\n </div>\n}\n\n@if (!tag.presentOrEdit) {\n <div>\n <div style=\"overflow-x: auto;\">\n <mat-button-toggle-group [(ngModel)]=\"tag.attributes['h-align']\">\n <mat-button-toggle value=\"center\">\n \u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443 <mat-icon>format_align_center</mat-icon>\n </mat-button-toggle>\n <mat-button-toggle value=\"left\">\n \u0421\u043B\u0435\u0432\u0430 <mat-icon>format_align_left</mat-icon>\n </mat-button-toggle>\n <mat-button-toggle value=\"right\">\n \u0421\u043F\u0440\u0430\u0432\u0430 <mat-icon> format_align_right</mat-icon>\n </mat-button-toggle>\n </mat-button-toggle-group>\n </div>\n <div style=\"height: 10px;\">\n </div>\n <div>\n <mat-form-field class=\"w-100\">\n <mat-label>\u0412\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u044F\u044F \u0440\u0430\u0437\u043C\u0435\u0442\u043A\u0430 \u0442\u0435\u043A\u0441\u0442\u043E\u0432\u043E\u0433\u043E \u0442\u0435\u0433\u0430</mat-label>\n <textarea matInput cdkTextareaAutosize #autosize=\"cdkTextareaAutosize\"\n cdkAutosizeMinRows=\"1\"\n placeholder=\"\u0412\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u044F\u044F \u0440\u0430\u0437\u043C\u0435\u0442\u043A\u0430 \u0442\u0435\u043A\u0441\u0442\u043E\u0432\u043E\u0433\u043E \u0442\u0435\u0433\u0430\"\n [(ngModel)]=\"tag.innerHtml\"></textarea>\n </mat-form-field>\n </div>\n </div>\n}\n" }]
|
|
2042
|
-
}],
|
|
2154
|
+
}], propDecorators: { tag: [{
|
|
2043
2155
|
type: Input
|
|
2044
2156
|
}], onTagUpdated: [{
|
|
2045
2157
|
type: Output
|
|
@@ -2167,9 +2279,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
2167
2279
|
}]
|
|
2168
2280
|
}] });
|
|
2169
2281
|
|
|
2170
|
-
const defaultLinkYouTube = "https://www.youtube.com/embed/4CtSAnJDfsI?si=scyBNJa0Hs2t5aLE";
|
|
2171
|
-
const defaultLinkVk = "https://vk.com/video_ext.php?oid=-22822305&id=456241864&hd=2";
|
|
2172
|
-
const defaultLinkForDownload = "https://storage.yandexcloud.net/mega-academy/presentation.pdf";
|
|
2173
2282
|
class VisualEditorComponent {
|
|
2174
2283
|
isHtmlSet() {
|
|
2175
2284
|
return this.html.startsWith("<body>");
|
|
@@ -2189,7 +2298,7 @@ class VisualEditorComponent {
|
|
|
2189
2298
|
this.loadingText = "Идёт загрузка";
|
|
2190
2299
|
this.text = '';
|
|
2191
2300
|
this.htmlRaw = '';
|
|
2192
|
-
this.alignment =
|
|
2301
|
+
this.alignment = TextAlignment.Left;
|
|
2193
2302
|
this.textTag = DefaultTags.textTags[0].tag;
|
|
2194
2303
|
this.textTagOptions = DefaultTags.textTags;
|
|
2195
2304
|
this.alignmentOptions = AlignmentsData;
|
|
@@ -2218,55 +2327,24 @@ class VisualEditorComponent {
|
|
|
2218
2327
|
addTagClickHandler() {
|
|
2219
2328
|
let tagDescription = this.tags
|
|
2220
2329
|
.find(x => x.tag === this.selectedValue);
|
|
2221
|
-
|
|
2330
|
+
const tagName = tagDescription.tag;
|
|
2331
|
+
if (TextTags.allTextTags.includes(tagName)) {
|
|
2222
2332
|
this.addTextTags();
|
|
2223
2333
|
this.startAddingText();
|
|
2224
2334
|
return;
|
|
2225
2335
|
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
innerHtml = this.htmlRaw;
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
else if (tagDescription.tag == FileImageTagDataConsts.TagName) {
|
|
2240
|
-
attrs[FileImageTagDataConsts.ScreenMediaRequest] = FileImageTagDataConsts.DefaultValueForFileImage;
|
|
2241
|
-
}
|
|
2242
|
-
else if (tagDescription.tag == DownloadButtonTagDataConsts.TagName) {
|
|
2243
|
-
attrs[DownloadButtonTagDataConsts.LinkAttrName] = defaultLinkForDownload;
|
|
2244
|
-
attrs[DownloadButtonTagDataConsts.TitleAttrName] = 'Скачать';
|
|
2245
|
-
}
|
|
2246
|
-
else if (tagDescription.tag == ButtonTagDataConsts.TagName) {
|
|
2247
|
-
attrs[ButtonTagDataConsts.ClickAttrName] = '';
|
|
2248
|
-
attrs[ButtonTagDataConsts.TypeAttrName] = 'button';
|
|
2249
|
-
attrs[ButtonTagDataConsts.TextAttrName] = 'Кнопка';
|
|
2250
|
-
}
|
|
2251
|
-
else if (tagDescription.tag === HtmlRawTagDataConsts.TagName) {
|
|
2252
|
-
innerHtml = this.htmlRaw;
|
|
2253
|
-
}
|
|
2254
|
-
else if (tagDescription.tag == CustomWidgetTagDataConsts.TagName) {
|
|
2255
|
-
attrs[CustomWidgetTagDataConsts.TypeAttrName] = 'example-type';
|
|
2256
|
-
attrs[CustomWidgetTagDataConsts.DataIdAttrName] = 'example-data-id';
|
|
2257
|
-
attrs[CustomWidgetTagDataConsts.WidgetIdAttrName] = 'example-widget-id';
|
|
2258
|
-
}
|
|
2259
|
-
else if (tagDescription.tag === FileImageTagDataConsts.TagName) {
|
|
2260
|
-
attrs[FileImageTagDataConsts.FileIdAttrName] = null;
|
|
2336
|
+
if (BodyTagsExtensions.tagServices.hasOwnProperty(tagName)) {
|
|
2337
|
+
const tagService = BodyTagsExtensions.tagServices[tagName];
|
|
2338
|
+
let tag = tagService.getDefaultValue({
|
|
2339
|
+
htmlRaw: this.htmlRaw,
|
|
2340
|
+
selectedVideoPlayer: this.selectedVideoPlayer
|
|
2341
|
+
});
|
|
2342
|
+
this.bodyTags.push(tag);
|
|
2343
|
+
this.htmlRaw = '';
|
|
2344
|
+
this.recalculateHtml();
|
|
2345
|
+
return;
|
|
2261
2346
|
}
|
|
2262
|
-
|
|
2263
|
-
tagDescription,
|
|
2264
|
-
innerHtml,
|
|
2265
|
-
attributes: attrs,
|
|
2266
|
-
presentOrEdit: true
|
|
2267
|
-
});
|
|
2268
|
-
this.htmlRaw = '';
|
|
2269
|
-
this.recalculateHtml();
|
|
2347
|
+
alert(`Сервис для тега ${tagName} не зарегистрирован.`);
|
|
2270
2348
|
}
|
|
2271
2349
|
startAddingText(tag = '') {
|
|
2272
2350
|
this.saveBodyTags = [...this.bodyTags];
|
|
@@ -2279,7 +2357,7 @@ class VisualEditorComponent {
|
|
|
2279
2357
|
}
|
|
2280
2358
|
resetTextStyle() {
|
|
2281
2359
|
this.text = '';
|
|
2282
|
-
this.alignment =
|
|
2360
|
+
this.alignment = TextAlignment.Left;
|
|
2283
2361
|
this.textTag = DefaultTags.textTags[0].tag;
|
|
2284
2362
|
}
|
|
2285
2363
|
addTextTags() {
|
|
@@ -2748,5 +2826,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
2748
2826
|
* Generated bundle index. Do not edit.
|
|
2749
2827
|
*/
|
|
2750
2828
|
|
|
2751
|
-
export { AddFilesBtnComponent, AngularMaterialTableMethods, BodyTagsExtensions, BootstrapTableMethods, CrocoHtmlFileOptionsService, CrocoHtmlModule, CrocoHtmlOptionsToken, CustomWidgetEditorComponent, ExternalVideoEditorComponent, ExternalVideoPlayers, ExternalVideoSupportedTypes, ExternalVideoTagDataConsts, FileIdSelectComponent, FileImageTagDataConsts, FileImageTagViewComponent, FileType, HtmlRawEditorComponent, HtmlRawViewComponent, HtmlViewComponent, HtmlViewController, ImageEditorComponent, ImageMethods, MainEditorBlockComponent, MainEditorComponent, TableBuilder, TableMethods, TableTypes, TagToSpanPipe, TextEditorComponent, TextSimpleMethods, TextTag,
|
|
2829
|
+
export { AddFilesBtnComponent, AngularMaterialTableMethods, BodyTagsExtensions, BootstrapTableMethods, CrocoHtmlFileOptionsService, CrocoHtmlModule, CrocoHtmlOptionsToken, CustomWidgetEditorComponent, ExternalVideoEditorComponent, ExternalVideoPlayers, ExternalVideoSupportedTypes, ExternalVideoTagDataConsts, FileIdSelectComponent, FileImageTagDataConsts, FileImageTagViewComponent, FileType, HtmlRawEditorComponent, HtmlRawViewComponent, HtmlViewComponent, HtmlViewController, ImageEditorComponent, ImageMethods, MainEditorBlockComponent, MainEditorComponent, TableBuilder, TableMethods, TableTypes, TagToSpanPipe, TextEditorComponent, TextSimpleMethods, TextTag, TextTags, ToHtmlBodyTagsPipe, ToPreviewHtmlPipe, ToPreviewPipe, UploadFilesBtnComponent, VisualEditorComponent, XmlExtensions, XmlTagCustomWidgetComponent, XmlTagExternalVideoComponent, XmlTagHeaderInnerTextViewComponent, XmlTagHeaderTextViewComponent, XmlTagHtmlViewComponent, XmlTagTableViewComponent, XmlTagTextViewComponent, XmlTagViewComponent };
|
|
2752
2830
|
//# sourceMappingURL=croco-html.mjs.map
|