1
0
mirror of https://github.com/taigaio/taiga-front synced 2025-10-05 23:42:54 +02:00

fix: editor link markdow format

This commit is contained in:
Juanfran
2023-08-11 12:46:32 +02:00
parent eb6a479de6
commit 3877ece0a7
3 changed files with 33 additions and 1 deletions

View File

@@ -53,6 +53,9 @@ BindCode = ($sce, $parse, $compile, wysiwygService) ->
scope.$watch tgBindWysiwygHtmlWatch, () ->
html = wysiwygService.getHTML(tgBindWysiwygHtmlGetter(scope))
html = wysiwygService.relativePaths(html)
wysiwygService.refreshAttachmentURL(html).then (html) =>
render(element, html)

View File

@@ -63,6 +63,35 @@ class WysiwygService
@.cache[cache_key] = url
return url
relativePaths: (html) ->
el = document.createElement('html')
el.innerHTML = @sce.getTrustedHtml(html) || ''
el.querySelectorAll('a').forEach (link) =>
href = link.getAttribute('href')
if href && !href.startsWith('http') && !href.startsWith('/') && !link.classList.contains('mention')
currentHref = window.location.href.slice(
0,
window.location.href.lastIndexOf('/') + 1
);
if !currentHref.endsWith('/')
currentHref = currentHref + '/'
newHref = currentHref + link.getAttribute('href')
link.removeAttribute('rel')
link.removeAttribute('target')
link.setAttribute('href', newHref)
if href.startsWith('project') && link.classList.contains('mention')
link.removeAttribute('rel')
link.removeAttribute('target')
return el.innerHTML
refreshAttachmentURLFromMarkdown: (markdown) ->
html = @.getHTML(markdown)

File diff suppressed because one or more lines are too long