feat: Document hover cards (#1346)
* stash * refactor * refactor, styling * tweaks * pointer * styling * fi: Hide when printing * fix: No hover cards on shared links * remove suppressions no longer needed * fix: Don't show hover cards when editing, they get in the way * fix: Prevent hover card from going off rhs edge of screen * fix: Remount hover card when changing between links * fix: allow one part domains in links (#1350) * allow one part domains in links * no TLD when only one part domain * return null for parseDomain of empty string * fix fiddly hover preview behavior * WIP * refactor hover preview * fix: Non-rounded bottom corners * fix: Fixes an edgecase where mounting the nested editor in hovercard causesdocument to scroll if there is a hash in the url * fix: Incorrect document preview rendering * lint Co-authored-by: Nan Yu <thenanyu@gmail.com> Co-authored-by: Nan Yu <nan@getoutline.com>
This commit is contained in:
@@ -12,6 +12,7 @@ type Domain = {
|
||||
// unneccessarily for our usecase of trusted input.
|
||||
export function parseDomain(url: string): ?Domain {
|
||||
if (typeof url !== "string") return null;
|
||||
if (url === "") return null;
|
||||
|
||||
// strip extermeties and whitespace from input
|
||||
const normalizedDomain = trim(url.replace(/(https?:)?\/\//, ""));
|
||||
@@ -39,6 +40,15 @@ export function parseDomain(url: string): ?Domain {
|
||||
};
|
||||
}
|
||||
|
||||
// one-part domain handler for things like localhost
|
||||
if (parts.length === 1) {
|
||||
return {
|
||||
subdomain: "",
|
||||
domain: cleanTLD(parts.slice(0).join()),
|
||||
tld: "",
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,3 +37,14 @@ export default function parseDocumentIds(text: string): string[] {
|
||||
findLinks(value);
|
||||
return links;
|
||||
}
|
||||
|
||||
export function parseDocumentSlugFromUrl(url: string) {
|
||||
let parsed;
|
||||
try {
|
||||
parsed = new URL(url);
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
return parsed.pathname.replace(/^\/doc\//, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user