first commit
This commit is contained in:
55
js/tinymce/plugins/anchor/plugin.js
Normal file
55
js/tinymce/plugins/anchor/plugin.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('anchor', function(editor) {
|
||||
function showDialog() {
|
||||
var selectedNode = editor.selection.getNode(), name = '';
|
||||
var isAnchor = selectedNode.tagName == 'A' && editor.dom.getAttrib(selectedNode, 'href') === '';
|
||||
|
||||
if (isAnchor) {
|
||||
name = selectedNode.name || selectedNode.id || '';
|
||||
}
|
||||
|
||||
editor.windowManager.open({
|
||||
title: 'Anchor',
|
||||
body: {type: 'textbox', name: 'name', size: 40, label: 'Name', value: name},
|
||||
onsubmit: function(e) {
|
||||
var id = e.data.name;
|
||||
|
||||
if (isAnchor) {
|
||||
selectedNode.id = id;
|
||||
} else {
|
||||
editor.selection.collapse(true);
|
||||
editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', {
|
||||
id: id
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.addCommand('mceAnchor', showDialog);
|
||||
|
||||
editor.addButton('anchor', {
|
||||
icon: 'anchor',
|
||||
tooltip: 'Anchor',
|
||||
onclick: showDialog,
|
||||
stateSelector: 'a:not([href])'
|
||||
});
|
||||
|
||||
editor.addMenuItem('anchor', {
|
||||
icon: 'anchor',
|
||||
text: 'Anchor',
|
||||
context: 'insert',
|
||||
onclick: showDialog
|
||||
});
|
||||
});
|
||||
1
js/tinymce/plugins/anchor/plugin.min.js
vendored
Normal file
1
js/tinymce/plugins/anchor/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("anchor",function(a){function b(){var b=a.selection.getNode(),c="",d="A"==b.tagName&&""===a.dom.getAttrib(b,"href");d&&(c=b.name||b.id||""),a.windowManager.open({title:"Anchor",body:{type:"textbox",name:"name",size:40,label:"Name",value:c},onsubmit:function(c){var e=c.data.name;d?b.id=e:(a.selection.collapse(!0),a.execCommand("mceInsertContent",!1,a.dom.createHTML("a",{id:e})))}})}a.addCommand("mceAnchor",b),a.addButton("anchor",{icon:"anchor",tooltip:"Anchor",onclick:b,stateSelector:"a:not([href])"}),a.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",onclick:b})});
|
||||
Reference in New Issue
Block a user