Skip to content

Commit

Permalink
Remove data-link-target attribute on anchor
Browse files Browse the repository at this point in the history
Remove unnecessary data-link-target - attribute. It is not necessary anymore and can be removed. Also the support for different kinds of targets was added like _top, _self, etc.
  • Loading branch information
sascha-karnatz committed Mar 28, 2024
1 parent 92b3d9c commit 653cf26
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tinymce.PluginManager.add("alchemy_link", function (editor) {
link = {
url: anchor.href,
title: anchor.title,
target: anchor.getAttribute("data-link-target"),
target: anchor.target ? anchor.target.replace(/^\_/, "") : "",
type: anchor.className
}
}
Expand All @@ -23,8 +23,7 @@ tinymce.PluginManager.add("alchemy_link", function (editor) {
href: link.url,
class: link.type,
title: link.title,
"data-link-target": link.target,
target: link.target === "blank" ? "_blank" : undefined
target: link.target ? `_${link.target}` : undefined
})
editor.selection.collapse()
})
Expand Down
2 changes: 1 addition & 1 deletion app/components/alchemy/ingredients/link_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def call
private

def link_target
(ingredient.link_target == "blank") ? "_blank" : nil
ingredient.link_target.present? ? "_#{ingredient.link_target}" : nil
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/components/alchemy/ingredients/text_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def call
link_to(value, url_for(link), {
id: dom_id.presence,
title: link_title,
target: ((link_target == "blank") ? "_blank" : nil),
data: {link_target: link_target}
target: link_target.present? ? "_#{link_target}" : nil
}.merge(html_options))
end.html_safe
end
Expand Down

0 comments on commit 653cf26

Please sign in to comment.