diff --git a/app/javascript/elements/markdown_editor.js b/app/javascript/elements/markdown_editor.js index 17431277..b9937598 100644 --- a/app/javascript/elements/markdown_editor.js +++ b/app/javascript/elements/markdown_editor.js @@ -36,15 +36,11 @@ function loadTiptap () { } class LinkTooltip { - constructor (container, editor) { + constructor (container, editor, templateEl) { this.container = container this.editor = editor - const template = document.createElement('template') - - template.innerHTML = container.dataset.linkTooltipHtml - - this.tooltip = template.content.firstElementChild + this.tooltip = templateEl.content.firstElementChild.cloneNode(true) this.input = this.tooltip.querySelector('input') this.saveButton = this.tooltip.querySelector('[data-role="link-save"]') @@ -140,7 +136,8 @@ export default actionable(targetable(class extends HTMLElement { 'boldButton', 'italicButton', 'underlineButton', - 'linkButton' + 'linkButton', + 'linkTooltipTemplate' ] async connectedCallback () { @@ -256,7 +253,7 @@ export default actionable(targetable(class extends HTMLElement { } }) - this.linkTooltip = new LinkTooltip(this, this.editor) + this.linkTooltip = new LinkTooltip(this, this.editor, this.linkTooltipTemplate) } adjustShortcutsForPlatform () { diff --git a/app/views/personalization_settings/_markdown_editor.html.erb b/app/views/personalization_settings/_markdown_editor.html.erb index b870fffc..5e43e5cb 100644 --- a/app/views/personalization_settings/_markdown_editor.html.erb +++ b/app/views/personalization_settings/_markdown_editor.html.erb @@ -1,70 +1,76 @@ -<% link_tooltip_html = capture do %> - -<% end %> - -
-
-
-
- -
-
- -
-
- -
-
- -
+<% if value.to_s.start_with?(' + + <%= text_area_tag name, value, required: true, class: 'base-input w-full py-2 !rounded-2xl', dir: 'auto', style: 'max-height: 400px' %> + +<% else %> + + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
-
- <% if local_assigns[:variables]&.any? %> - <% variable_labels = { 'account.name' => t('variables.account_name'), 'submitter.link' => t('variables.submitter_link'), 'template.name' => t('variables.template_name'), 'submission.submitters' => t('variables.submission_submitters'), 'submission.link' => t('variables.submission_link'), 'documents.link' => t('variables.documents_link') } %> - -
-
- <%= hidden_field_tag name, value, required: true, data: { target: 'markdown-editor.textarea' } %> -
+ <%= hidden_field_tag name, value, required: true, data: { target: 'markdown-editor.textarea' } %> + +<% end %>