Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor link dialog into ES module #2796

Merged
merged 8 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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
Loading