fix: Flash of external link decoration when creating doc from selected text

This commit is contained in:
Tom Moor
2022-12-04 17:41:19 -05:00
parent 0a68266365
commit 3d6da26ad6
3 changed files with 10 additions and 3 deletions

View File

@@ -75,6 +75,11 @@ export function isUrl(text: string, options?: { requireHostname: boolean }) {
}
}
/**
* Temporary prefix applied to links in document that are not yet persisted.
*/
export const creatingUrlPrefix = "creating#";
/**
* Returns true if the given string is a link to outside the application.
*
@@ -82,7 +87,7 @@ export function isUrl(text: string, options?: { requireHostname: boolean }) {
* @returns True if the url is external, false otherwise.
*/
export function isExternalUrl(url: string) {
return !!url && !isInternalUrl(url);
return !!url && !isInternalUrl(url) && !url.startsWith(creatingUrlPrefix);
}
/**