Revize 8dc25caa
Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)
Backend/Core/Services/AnnotationService/AnnotationServiceEF.cs | ||
---|---|---|
15 | 15 |
using HtmlAgilityPack; |
16 | 16 |
using System.Text.RegularExpressions; |
17 | 17 |
using Newtonsoft.Json; |
18 |
using Core.GraphUtils; |
|
18 | 19 |
|
19 | 20 |
namespace Core.Services.AnnotationService |
20 | 21 |
{ |
... | ... | |
293 | 294 |
|
294 | 295 |
HtmlDocument doc = new HtmlDocument(); |
295 | 296 |
doc.LoadHtml(docToRender); |
296 |
var cssNode = GenerateCSS(doc, tags, new());
|
|
297 |
var cssNode = GenerateCSS(doc, tags); |
|
297 | 298 |
doc.DocumentNode.ChildNodes.Insert(0, cssNode); |
298 | 299 |
|
299 | 300 |
return doc.DocumentNode.OuterHtml; |
... | ... | |
493 | 494 |
} |
494 | 495 |
} |
495 | 496 |
|
496 |
private HtmlNode GenerateCSS(HtmlDocument docToEdit, List<AnnotationTag> tags, List<int> paddings)
|
|
497 |
private HtmlNode GenerateCSS(HtmlDocument docToEdit, List<AnnotationTag> tags) |
|
497 | 498 |
{ |
498 | 499 |
HtmlNode style = docToEdit.CreateElement("style"); |
499 | 500 |
|
500 | 501 |
string inner = "span.annotation {border-bottom: 2px solid;}"; |
501 | 502 |
inner += "span {line-height: 30px}\n"; |
502 | 503 |
|
503 |
// TODO temporary
|
|
504 |
int lastPadding = 0; |
|
504 |
var tagPaddingDict = Intersections.ColorGraph(Intersections.FindIntersections(tags));
|
|
505 |
|
|
505 | 506 |
foreach (var tag in tags) |
506 | 507 |
{ |
507 |
inner += $"span[{TAG_INSTANCE_ATTRIBUTE_NAME}=\"{tag.Instance}\"] {{ border-color:{tag.Tag.Color}; padding-bottom: {lastPadding % 5}px }}";
|
|
508 |
lastPadding += 2;
|
|
508 |
var padding = (tagPaddingDict[tag] + 1) * 2;
|
|
509 |
inner += $"span[{TAG_INSTANCE_ATTRIBUTE_NAME}=\"{tag.Instance}\"] {{ border-color:{tag.Tag.Color}; padding-bottom: {padding}px }}";
|
|
509 | 510 |
} |
510 | 511 |
|
511 | 512 |
inner += "span[end=\"1\"] {border-end-end-radius: 0px; border-right: 1px solid darkgray}\n"; |
... | ... | |
621 | 622 |
} |
622 | 623 |
} |
623 | 624 |
|
624 |
var cssNode = GenerateCSS(docToEdit, tags, new());
|
|
625 |
var cssNode = GenerateCSS(docToEdit, tags); |
|
625 | 626 |
docToEdit.DocumentNode.ChildNodes.Insert(0, cssNode); |
626 | 627 |
|
627 | 628 |
return docToEdit.DocumentNode.OuterHtml; |
... | ... | |
691 | 692 |
} |
692 | 693 |
} |
693 | 694 |
|
694 |
var cssNode = GenerateCSS(docToEdit, tags, new());
|
|
695 |
var cssNode = GenerateCSS(docToEdit, tags); |
|
695 | 696 |
docToEdit.DocumentNode.ChildNodes.Insert(0, cssNode); |
696 | 697 |
|
697 | 698 |
return docToEdit.DocumentNode.OuterHtml; |
Také k dispozici: Unified diff
Added padding size calculation to html rendering