Revize 179a097d
Přidáno uživatelem Vojtěch Bartička před téměř 3 roky(ů)
Backend/Core/Services/AnnotationService/AnnotationServiceEF.cs | ||
---|---|---|
247 | 247 |
AssignIdsToOriginalDocument(descendantsOriginal, ref currentId); |
248 | 248 |
|
249 | 249 |
WrapTextInSpan(descendantsOriginal, docToEdit); |
250 |
|
|
251 | 250 |
int descCount = descendantsToEdit.Count; |
252 | 251 |
|
253 | 252 |
foreach (var tag in tags) |
... | ... | |
300 | 299 |
|
301 | 300 |
} |
302 | 301 |
|
302 |
ModifyLinks(descendantsToEdit); |
|
303 | 303 |
string docToRender = docToEdit.DocumentNode.OuterHtml; |
304 | 304 |
HtmlSanitizer sanitizer = new HtmlSanitizer(); |
305 | 305 |
sanitizer.AllowedAttributes.Clear(); |
306 | 306 |
sanitizer.AllowedAttributes.Add(TAG_ID_ATTRIBUTE_NAME); |
307 | 307 |
sanitizer.AllowedAttributes.Add(TAG_INSTANCE_ATTRIBUTE_NAME); |
308 |
sanitizer.AllowedAttributes.Add("href"); |
|
308 | 309 |
sanitizer.AllowedAttributes.Add("end"); |
309 | 310 |
sanitizer.AllowedAttributes.Add("start"); |
310 | 311 |
sanitizer.AllowedAttributes.Add("class"); |
... | ... | |
316 | 317 |
{ |
317 | 318 |
sanitizer.AllowedTags.Add("style"); |
318 | 319 |
} |
319 |
docToRender = sanitizer.Sanitize(docToRender); |
|
320 |
sanitizer.AllowedTags.Add("a"); |
|
321 |
docToRender = sanitizer.Sanitize(docToRender); |
|
320 | 322 |
GenerateCSS(tags); |
321 | 323 |
return docToRender; |
322 | 324 |
} |
... | ... | |
456 | 458 |
MARK_NONE = 0 |
457 | 459 |
} |
458 | 460 |
|
461 |
private void ModifyLinks(IEnumerable<HtmlNode> descendantsOriginal) |
|
462 |
{ |
|
463 |
foreach (var descendant in descendantsOriginal) |
|
464 |
{ |
|
465 |
if (descendant.Name == "a") |
|
466 |
{ |
|
467 |
if (descendant.Attributes.Contains("href")) |
|
468 |
{ |
|
469 |
descendant.SetAttributeValue("href", "/link?url=" + descendant.Attributes["href"].Value); |
|
470 |
descendant.SetAttributeValue("target", "_blank"); |
|
471 |
} |
|
472 |
} |
|
473 |
} |
|
474 |
} |
|
475 |
|
|
459 | 476 |
private void WrapTextInSpan(IEnumerable<HtmlNode> descendantsOriginal, HtmlDocument docToEdit) |
460 | 477 |
{ |
461 | 478 |
// Special case for non-html documents |
... | ... | |
553 | 570 |
InstanceId = tag.Instance, |
554 | 571 |
Color = tag.Tag.Color, |
555 | 572 |
Padding = padding |
556 |
});
|
|
573 |
}); |
|
557 | 574 |
} |
558 | 575 |
} |
559 | 576 |
|
Také k dispozici: Unified diff
Added link redirect to annotations