mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Treat URLs in Markdown cells as absolute
Summary: The previous behavior didn't match HyperLink cells. Test Plan: Browser test. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D4358
This commit is contained in:
parent
d2714da224
commit
1927c87413
@ -224,7 +224,7 @@ export class UrlStateImpl {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Given value like `foo bar baz`, constructs URL by checking if `baz` is a valid URL and,
|
* Given value like `foo bar baz`, constructs URL by checking if `baz` is a valid URL and,
|
||||||
* if not, prepending `http://`.
|
* if not, prepending `https://`.
|
||||||
*/
|
*/
|
||||||
export function constructUrl(value: CellValue): string {
|
export function constructUrl(value: CellValue): string {
|
||||||
if (typeof value !== 'string') {
|
if (typeof value !== 'string') {
|
||||||
@ -235,8 +235,8 @@ export function constructUrl(value: CellValue): string {
|
|||||||
// Try to construct a valid URL
|
// Try to construct a valid URL
|
||||||
return (new URL(url)).toString();
|
return (new URL(url)).toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Not a valid URL, so try to prefix it with http
|
// Not a valid URL, so try to prefix it with https
|
||||||
return 'http://' + url;
|
return 'https://' + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import {constructUrl} from 'app/client/models/gristUrlState';
|
||||||
import {gristIconLink} from 'app/client/ui2018/links';
|
import {gristIconLink} from 'app/client/ui2018/links';
|
||||||
import escape from 'lodash/escape';
|
import escape from 'lodash/escape';
|
||||||
import {marked} from 'marked';
|
import {marked} from 'marked';
|
||||||
|
|
||||||
export const renderer = new marked.Renderer();
|
export const renderer = new marked.Renderer();
|
||||||
|
|
||||||
renderer.link = ({href, text}) => gristIconLink(href, text).outerHTML;
|
renderer.link = ({href, text}) => gristIconLink(constructUrl(href), text).outerHTML;
|
||||||
|
|
||||||
// Disable Markdown features that we aren't ready to support yet.
|
// Disable Markdown features that we aren't ready to support yet.
|
||||||
renderer.hr = ({raw}) => raw;
|
renderer.hr = ({raw}) => raw;
|
||||||
|
Loading…
Reference in New Issue
Block a user