Added TinyMCE editor functions & Updated TinyMCE to TinyMCE-jQuery 3.4b1
This commit is contained in:
@@ -5,7 +5,7 @@ var AnchorDialog = {
|
||||
var action, elm, f = document.forms[0];
|
||||
|
||||
this.editor = ed;
|
||||
elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG');
|
||||
elm = ed.dom.getParent(ed.selection.getNode(), 'A');
|
||||
v = ed.dom.getAttrib(elm, 'name');
|
||||
|
||||
if (v) {
|
||||
@@ -17,18 +17,23 @@ var AnchorDialog = {
|
||||
},
|
||||
|
||||
update : function() {
|
||||
var ed = this.editor;
|
||||
|
||||
var ed = this.editor, elm, name = document.forms[0].anchorName.value;
|
||||
|
||||
if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {
|
||||
tinyMCEPopup.alert('advanced_dlg.anchor_invalid');
|
||||
return;
|
||||
}
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
|
||||
if (this.action != 'update')
|
||||
ed.selection.collapse(1);
|
||||
|
||||
// Webkit acts weird if empty inline element is inserted so we need to use a image instead
|
||||
if (tinymce.isWebKit)
|
||||
ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('img', {mce_name : 'a', name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}));
|
||||
elm = ed.dom.getParent(ed.selection.getNode(), 'A');
|
||||
if (elm)
|
||||
elm.name = name;
|
||||
else
|
||||
ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : document.forms[0].anchorName.value, 'class' : 'mceItemAnchor'}, ''));
|
||||
ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, ''));
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* charmap.js
|
||||
*
|
||||
* Copyright 2009, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://tinymce.moxiecode.com/license
|
||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
||||
*/
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
var charmap = [
|
||||
|
@@ -77,7 +77,7 @@ var ImageDialog = {
|
||||
args.style = this.styleVal;
|
||||
|
||||
tinymce.extend(args, {
|
||||
src : f.src.value,
|
||||
src : f.src.value.replace(/ /g, '%20'),
|
||||
alt : f.alt.value,
|
||||
width : f.width.value,
|
||||
height : f.height.value
|
||||
@@ -87,6 +87,8 @@ var ImageDialog = {
|
||||
|
||||
if (el && el.nodeName == 'IMG') {
|
||||
ed.dom.setAttribs(el, args);
|
||||
tinyMCEPopup.editor.execCommand('mceRepaint');
|
||||
tinyMCEPopup.editor.focus();
|
||||
} else {
|
||||
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
|
||||
ed.dom.setAttribs('__mce_tmp', args);
|
||||
@@ -151,8 +153,8 @@ var ImageDialog = {
|
||||
}
|
||||
|
||||
// Merge
|
||||
st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st));
|
||||
this.styleVal = dom.serializeStyle(st);
|
||||
st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st), 'img');
|
||||
this.styleVal = dom.serializeStyle(st, 'img');
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -31,7 +31,7 @@ var LinkDialog = {
|
||||
},
|
||||
|
||||
update : function() {
|
||||
var f = document.forms[0], ed = tinyMCEPopup.editor, e, b;
|
||||
var f = document.forms[0], ed = tinyMCEPopup.editor, e, b, href = f.href.value.replace(/ /g, '%20');
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
e = ed.dom.getParent(ed.selection.getNode(), 'A');
|
||||
@@ -53,26 +53,27 @@ var LinkDialog = {
|
||||
|
||||
// Create new anchor elements
|
||||
if (e == null) {
|
||||
tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
|
||||
ed.getDoc().execCommand("unlink", false, null);
|
||||
tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
|
||||
|
||||
tinymce.each(ed.dom.select("a"), function(n) {
|
||||
if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
|
||||
e = n;
|
||||
|
||||
ed.dom.setAttribs(e, {
|
||||
href : f.href.value,
|
||||
href : href,
|
||||
title : f.linktitle.value,
|
||||
target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null,
|
||||
'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null
|
||||
target : f.target_list ? getSelectValue(f, "target_list") : null,
|
||||
'class' : f.class_list ? getSelectValue(f, "class_list") : null
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ed.dom.setAttribs(e, {
|
||||
href : f.href.value,
|
||||
href : href,
|
||||
title : f.linktitle.value,
|
||||
target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null,
|
||||
'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null
|
||||
target : f.target_list ? getSelectValue(f, "target_list") : null,
|
||||
'class' : f.class_list ? getSelectValue(f, "class_list") : null
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ var LinkDialog = {
|
||||
if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
|
||||
n.value = 'mailto:' + n.value;
|
||||
|
||||
if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
||||
if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
|
||||
n.value = 'http://' + n.value;
|
||||
},
|
||||
|
||||
|
@@ -2,7 +2,7 @@ tinyMCEPopup.requireLangPack();
|
||||
tinyMCEPopup.onInit.add(onLoadInit);
|
||||
|
||||
function saveContent() {
|
||||
tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value);
|
||||
tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {source_view : true});
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function onLoadInit() {
|
||||
if (tinymce.isGecko)
|
||||
document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
|
||||
|
||||
document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent();
|
||||
document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({source_view : true});
|
||||
|
||||
if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
|
||||
setWrap('soft');
|
||||
@@ -44,19 +44,13 @@ function toggleWordWrap(elm) {
|
||||
setWrap('off');
|
||||
}
|
||||
|
||||
var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
|
||||
|
||||
function resizeInputs() {
|
||||
var el = document.getElementById('htmlSource');
|
||||
var vp = tinyMCEPopup.dom.getViewPort(window), el;
|
||||
|
||||
if (!tinymce.isIE) {
|
||||
wHeight = self.innerHeight - 65;
|
||||
wWidth = self.innerWidth - 16;
|
||||
} else {
|
||||
wHeight = document.body.clientHeight - 70;
|
||||
wWidth = document.body.clientWidth - 16;
|
||||
el = document.getElementById('htmlSource');
|
||||
|
||||
if (el) {
|
||||
el.style.width = (vp.w - 20) + 'px';
|
||||
el.style.height = (vp.h - 65) + 'px';
|
||||
}
|
||||
|
||||
el.style.height = Math.abs(wHeight) + 'px';
|
||||
el.style.width = Math.abs(wWidth) + 'px';
|
||||
}
|
||||
|
Reference in New Issue
Block a user