Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/marks
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2020-06-16 13:06:18 +0300
committerAzul <azul@riseup.net>2020-08-11 16:25:54 +0300
commit9dfc8cd64d2f90bf70028088f1c4697e3f659547 (patch)
treeb29abc57854403e91d1f5a9dd53e363f59aaf1a9 /src/marks
parent03ccc8aa0369ada0ed0d50b50e60171696fdd2e6 (diff)
refactor: define our own Link mark to rewrite hrefs
The short relative links used in markdown need to be converted to working urls in the href attributes. In order to properly serialize the content the full urls in html need to be converted to relative links as well. This commit splits out the href handling into a new helper. This way it can be easily tested. Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'src/marks')
-rw-r--r--src/marks/index.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/marks/index.js b/src/marks/index.js
index d66da88ca..3a3d6c5f2 100644
--- a/src/marks/index.js
+++ b/src/marks/index.js
@@ -21,6 +21,7 @@
*/
import { Bold, Italic as TipTapItalic, Strike as TipTapStrike, Link as TipTapLink } from 'tiptap-extensions'
+import { domHref, parseHref } from './../helpers/links'
/**
* This file maps prosemirror mark names to tiptap classes,
@@ -88,12 +89,13 @@ class Link extends TipTapLink {
{
tag: 'a[href]',
getAttrs: dom => ({
- href: dom.getAttribute('href'),
+ href: parseHref(dom),
}),
},
],
toDOM: node => ['a', {
...node.attrs,
+ href: domHref(node),
title: node.attrs.href,
rel: 'noopener noreferrer nofollow',
}, 0],