From 4344f4410b63349f249a4a47136741cf47e32086 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 25 Feb 2022 15:47:28 +0530 Subject: [PATCH] handle links in forms --- www/form/inner.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/form/inner.js b/www/form/inner.js index a0084057f..5bcb642fd 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -986,6 +986,12 @@ define([ }); }); + var linkClickHandler = function (ev) { + ev.preventDefault(); + var href = ($(this).attr('href') || '').trim(); + if (!href) { return; } + APP.common.openUnsafeURL(href); + }; var STATIC_TYPES = { md: { @@ -999,6 +1005,8 @@ define([ }, opts.text); var $tag = $(tag); DiffMd.apply(DiffMd.render(opts.text || ''), $tag, APP.common); + $tag.find('a').click(linkClickHandler); + var cursorGetter; return { tag: tag, @@ -2904,6 +2912,7 @@ define([ if (content.answers.msg) { var $desc = $(description); DiffMd.apply(DiffMd.render(content.answers.msg), $desc, APP.common); + $desc.find('a').click(linkClickHandler); } var actions = h('div.cp-form-submit-actions', [