Sha256: 1246fb78b25297399568382416233c0339b43f5df394fc2cf4286197e36b5fd1
Contents?: true
Size: 1.08 KB
Versions: 16
Compression:
Stored size: 1.08 KB
Contents
tinymce.PluginManager.add("alchemy_link", function (editor) { const getAnchor = (selectedElm) => { return editor.dom.getParent(selectedElm, "a[href]") } const openLinkDialog = () => { if (Alchemy.currentDialog()) return const linkObject = { node: getAnchor(editor.selection.getNode()), bookmark: editor.selection.getBookmark(), selection: editor.selection, editor: editor } const linkDialog = new Alchemy.LinkDialog(linkObject) editor.focus() linkDialog.open() } editor.ui.registry.addToggleButton("alchemy_link", { icon: "link", tooltip: "Insert/edit link", onSetup(buttonApi) { const onNodeChange = () => { buttonApi.setActive(getAnchor(editor.selection.getNode()) !== null) } onNodeChange() editor.on("NodeChange", onNodeChange) return () => { editor.off("NodeChange", onNodeChange) } }, onAction: openLinkDialog }) // Replace the default link command with our own editor.addCommand("mceLink", openLinkDialog) editor.addShortcut("Meta+K", "", openLinkDialog) })
Version data entries
16 entries across 16 versions & 1 rubygems