Extend markdown support for LBRY urls #2521
1 changed files with 6 additions and 5 deletions
|
@ -11,11 +11,12 @@ const createURI = (text, uri) => ({
|
|||
children: [{ type: 'text', value: text }],
|
||||
});
|
||||
|
||||
const validateURI = (match) => {
|
||||
const validateURI = (match, eat) => {
|
||||
if (match) {
|
||||
try {
|
||||
const text = match[0];
|
||||
const uri = parseURI(text);
|
||||
console.info(text);
|
||||
// Create channel link
|
||||
if (uri.isChannel) {
|
||||
return eat(text)(createURI(uri.claimName, text));
|
||||
|
@ -26,18 +27,18 @@ const validateURI = (match) => {
|
|||
// Silent errors: console.error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Generate a markdown link from channel name
|
||||
function tokenizeMention(eat, value, silent) {
|
||||
const match = /^@(\w+)/.exec(value);
|
||||
return validateURI(match);
|
||||
return validateURI(match, eat);
|
||||
}
|
||||
|
||||
// Generate a markdown link from lbry url
|
||||
function tokenizeURI(eat, value, silent) {
|
||||
const match = /^(lbry:\/\/)+([A-z0-9-_#@])+/.exec(value);
|
||||
return validateURI(match);
|
||||
const match = /^(lbry:\/\/)+([A-z0-9-_#@:])+/.exec(value);
|
||||
return validateURI(match, eat);
|
||||
}
|
||||
|
||||
![]() I can't find I can't find `regexValidUri`, did you mean `regexInvalidURI` ?
https://github.com/lbryio/lbry-redux/blob/master/src/lbryURI.js#L5
![]() this? https://github.com/lbryio/lbry-redux/blob/master/src/lbryURI.js#L32
![]() whoops. yes whoops. yes
![]() @seanyesmunt not sure how this is done on reach-ui tooltip 🙃 I mean the delay time to show / hide. @seanyesmunt not sure how this is done on reach-ui tooltip :upside_down_face:
I mean the delay time to show / hide.
![]() this is are already implemented inside this is are already implemented inside `parseURI`:
https://github.com/lbryio/lbry-desktop/blob/b7adc597e232f95dea200a6f49bf5d17c1af102c/src/ui/util/remark-lbry.js#L23
|
||||
// Configure tokenizer for lbry urls
|
||||
|
|
Loading…
Add table
Reference in a new issue
This should use
regexValidUri
andisValidUri()
fromlbry-redux