mirror of
https://github.com/taigaio/taiga-front
synced 2025-10-06 06:52:41 +02:00
fix: editor link markdow format
This commit is contained in:
@@ -53,6 +53,9 @@ BindCode = ($sce, $parse, $compile, wysiwygService) ->
|
|||||||
|
|
||||||
scope.$watch tgBindWysiwygHtmlWatch, () ->
|
scope.$watch tgBindWysiwygHtmlWatch, () ->
|
||||||
html = wysiwygService.getHTML(tgBindWysiwygHtmlGetter(scope))
|
html = wysiwygService.getHTML(tgBindWysiwygHtmlGetter(scope))
|
||||||
|
|
||||||
|
html = wysiwygService.relativePaths(html)
|
||||||
|
|
||||||
wysiwygService.refreshAttachmentURL(html).then (html) =>
|
wysiwygService.refreshAttachmentURL(html).then (html) =>
|
||||||
render(element, html)
|
render(element, html)
|
||||||
|
|
||||||
|
@@ -63,6 +63,35 @@ class WysiwygService
|
|||||||
@.cache[cache_key] = url
|
@.cache[cache_key] = url
|
||||||
return 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) ->
|
refreshAttachmentURLFromMarkdown: (markdown) ->
|
||||||
html = @.getHTML(markdown)
|
html = @.getHTML(markdown)
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user