Skip to content

Commit

Permalink
Merge pull request #2796 from sascha-karnatz/link-dailog-improvements
Browse files Browse the repository at this point in the history
Refactor link dialog into ES module
  • Loading branch information
tvdeyen authored Apr 2, 2024
2 parents 8175627 + 4dc39a2 commit 623b6f6
Show file tree
Hide file tree
Showing 35 changed files with 669 additions and 368 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/alchemy/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
//= require alchemy/alchemy.confirm_dialog
//= require alchemy/alchemy.fixed_elements
//= require alchemy/alchemy.image_overlay
//= require alchemy/alchemy.link_dialog
230 changes: 0 additions & 230 deletions app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee

This file was deleted.

1 change: 0 additions & 1 deletion app/assets/javascripts/alchemy/templates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
//= require alchemy/templates/page
//= require alchemy/templates/node_folder
//= require alchemy/templates/page_folder
19 changes: 0 additions & 19 deletions app/assets/javascripts/alchemy/templates/page.hbs

This file was deleted.

27 changes: 20 additions & 7 deletions app/assets/javascripts/tinymce/plugins/alchemy_link/plugin.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@ tinymce.PluginManager.add("alchemy_link", function (editor) {

const openLinkDialog = () => {
if (Alchemy.currentDialog()) return
const linkObject = {
node: getAnchor(editor.selection.getNode()),
bookmark: editor.selection.getBookmark(),
selection: editor.selection,
editor: editor

let link = {}
const anchor = getAnchor(editor.selection.getNode())
if (anchor) {
link = {
url: anchor.href,
title: anchor.title,
target: anchor.target,
type: anchor.className
}
}
const linkDialog = new Alchemy.LinkDialog(linkObject)
const linkDialog = new Alchemy.LinkDialog(link)
editor.focus()
linkDialog.open()
linkDialog.open().then((link) => {
editor.execCommand("mceInsertLink", false, {
href: link.url,
class: link.type,
title: link.title,
target: link.target
})
editor.selection.collapse()
})
}

editor.ui.registry.addToggleButton("alchemy_link", {
Expand Down
17 changes: 10 additions & 7 deletions app/components/alchemy/admin/link_dialog/anchor_tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ def title
Alchemy.t("link_overlay_tab_label.anchor")
end

def name
def self.panel_name
:anchor
end

def fields
[
anchor_select,
dom_id_select,
title_input
]
end
Expand All @@ -25,12 +25,15 @@ def message

private

def anchor_select
def dom_id_select
label = label_tag("anchor_link", Alchemy.t(:anchor), class: "control-label")
select = select_tag(:anchor_link,
options_for_select([[Alchemy.t("Please choose"), ""]]),
is: "alchemy-select")
content_tag("div", label + select, class: "input select")
options = [[Alchemy.t("None"), ""]]
options += [[@url, @url]] if is_selected? && @url

select = select_tag(:anchor_link, options_for_select(options, @url), is: "alchemy-select")
select_component = content_tag("alchemy-dom-id-preview-select", select)

content_tag("div", label + select_component, class: "input select")
end
end
end
Expand Down
Loading

0 comments on commit 623b6f6

Please sign in to comment.