mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-16 16:36:26 +08:00
Fix relative link URL in Markdown output (#1189)
This commit is contained in:
parent
07a75887e0
commit
641ac96ae7
3 changed files with 12 additions and 4 deletions
|
@ -13,7 +13,9 @@ const MarkdownRenderer = {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.props = this.getProps();
|
this.props = this.getProps();
|
||||||
|
|
||||||
const markdown = new Markdown(this.el, "");
|
const markdown = new Markdown(this.el, "", {
|
||||||
|
baseUrl: this.props.sessionPath,
|
||||||
|
});
|
||||||
|
|
||||||
this.handleEvent(
|
this.handleEvent(
|
||||||
`markdown_renderer:${this.props.id}:content`,
|
`markdown_renderer:${this.props.id}:content`,
|
||||||
|
@ -26,6 +28,7 @@ const MarkdownRenderer = {
|
||||||
getProps() {
|
getProps() {
|
||||||
return {
|
return {
|
||||||
id: getAttributeOrThrow(this.el, "data-id"),
|
id: getAttributeOrThrow(this.el, "data-id"),
|
||||||
|
sessionPath: getAttributeOrThrow(this.el, "data-session-path"),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,8 +47,12 @@ defmodule LivebookWeb.Output do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_output({:markdown, markdown}, %{id: id}) do
|
defp render_output({:markdown, markdown}, %{id: id, session_id: session_id}) do
|
||||||
live_component(Output.MarkdownComponent, id: id, content: markdown)
|
live_component(Output.MarkdownComponent,
|
||||||
|
id: id,
|
||||||
|
session_id: session_id,
|
||||||
|
content: markdown
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_output({:image, content, mime_type}, %{id: id}) do
|
defp render_output({:image, content, mime_type}, %{id: id}) do
|
||||||
|
|
|
@ -17,7 +17,8 @@ defmodule LivebookWeb.Output.MarkdownComponent do
|
||||||
<div class="markdown"
|
<div class="markdown"
|
||||||
id={"markdown-renderer-#{@id}"}
|
id={"markdown-renderer-#{@id}"}
|
||||||
phx-hook="MarkdownRenderer"
|
phx-hook="MarkdownRenderer"
|
||||||
data-id={@id}>
|
data-id={@id}
|
||||||
|
data-session-path={Routes.session_path(@socket, :page, @session_id)}>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue