From 04e9bed0fee3ff69e9cbd9d29e84130b973950ee Mon Sep 17 00:00:00 2001 From: Tw Date: Mon, 16 May 2022 10:14:34 +0800 Subject: [PATCH 1/3] fix relative link address issue in kino.Markdown Signed-off-by: Tw --- assets/js/hooks/markdown_renderer.js | 3 ++- lib/livebook_web/live/output.ex | 8 ++++++-- lib/livebook_web/live/output/markdown_component.ex | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/js/hooks/markdown_renderer.js b/assets/js/hooks/markdown_renderer.js index 3434523da88..1ad7fbe4879 100644 --- a/assets/js/hooks/markdown_renderer.js +++ b/assets/js/hooks/markdown_renderer.js @@ -13,7 +13,7 @@ const MarkdownRenderer = { mounted() { this.props = this.getProps(); - const markdown = new Markdown(this.el, ""); + const markdown = new Markdown(this.el, "", {baseUrl: this.props.sessionPath}); this.handleEvent( `markdown_renderer:${this.props.id}:content`, @@ -26,6 +26,7 @@ const MarkdownRenderer = { getProps() { return { id: getAttributeOrThrow(this.el, "data-id"), + sessionPath: getAttributeOrThrow(this.el, "data-session-path"), }; }, }; diff --git a/lib/livebook_web/live/output.ex b/lib/livebook_web/live/output.ex index e33d392e3cc..c8a81fd597f 100644 --- a/lib/livebook_web/live/output.ex +++ b/lib/livebook_web/live/output.ex @@ -47,8 +47,12 @@ defmodule LivebookWeb.Output do """ end - defp render_output({:markdown, markdown}, %{id: id}) do - live_component(Output.MarkdownComponent, id: id, content: markdown) + defp render_output({:markdown, markdown}, %{id: id, session_id: session_id}) do + live_component(Output.MarkdownComponent, + id: id, + session_id: session_id, + content: markdown + ) end defp render_output({:image, content, mime_type}, %{id: id}) do diff --git a/lib/livebook_web/live/output/markdown_component.ex b/lib/livebook_web/live/output/markdown_component.ex index 70d56e2d5ac..6160d3541fa 100644 --- a/lib/livebook_web/live/output/markdown_component.ex +++ b/lib/livebook_web/live/output/markdown_component.ex @@ -17,7 +17,8 @@ defmodule LivebookWeb.Output.MarkdownComponent do
+ data-id={@id} + data-session-path={Routes.session_path(@socket, :page, @session_id)}>
""" end From 3742411ce3ea2cf43485b898eef61fcbc347a259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Mon, 16 May 2022 11:25:52 +0200 Subject: [PATCH 2/3] Update assets/js/hooks/markdown_renderer.js --- assets/js/hooks/markdown_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/hooks/markdown_renderer.js b/assets/js/hooks/markdown_renderer.js index 1ad7fbe4879..27d09f5dc8f 100644 --- a/assets/js/hooks/markdown_renderer.js +++ b/assets/js/hooks/markdown_renderer.js @@ -13,7 +13,7 @@ const MarkdownRenderer = { mounted() { this.props = this.getProps(); - const markdown = new Markdown(this.el, "", {baseUrl: this.props.sessionPath}); + const markdown = new Markdown(this.el, "", { baseUrl: this.props.sessionPath }); this.handleEvent( `markdown_renderer:${this.props.id}:content`, From 6ada38bd41a7aaefb561f29985820861ed74a07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 17 May 2022 02:54:55 +0200 Subject: [PATCH 3/3] Update assets/js/hooks/markdown_renderer.js --- assets/js/hooks/markdown_renderer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/hooks/markdown_renderer.js b/assets/js/hooks/markdown_renderer.js index 27d09f5dc8f..532f333c729 100644 --- a/assets/js/hooks/markdown_renderer.js +++ b/assets/js/hooks/markdown_renderer.js @@ -13,7 +13,9 @@ const MarkdownRenderer = { mounted() { this.props = this.getProps(); - const markdown = new Markdown(this.el, "", { baseUrl: this.props.sessionPath }); + const markdown = new Markdown(this.el, "", { + baseUrl: this.props.sessionPath, + }); this.handleEvent( `markdown_renderer:${this.props.id}:content`,