📄 tiny_mce_src.js
字号:
if (n.mce_tmp) {
// Create new paragraph
p = t.doc.createElement('p');
// Copy all attributes
n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
if (b !== 'mce_tmp')
p.setAttribute(b, n.getAttribute(b));
});
// Append all children to new paragraph
for (x = 0; x<n.childNodes.length; x++)
p.appendChild(n.childNodes[x].cloneNode(true));
// Replace div with new paragraph
n.swapNode(p);
}
}
}
}
} else
e.innerHTML = h;
return h;
});
},
processHTML : function(h) {
var t = this, s = t.settings;
if (!s.process_html)
return h;
// Convert strong and em to b and i in FF since it can't handle them
if (tinymce.isGecko) {
h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
}
// Fix some issues
h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open
// Store away src and href in mce_src and mce_href since browsers mess them up
if (s.keep_values) {
// Wrap scripts in comments for serialization purposes
if (h.indexOf('<script') !== -1) {
h = h.replace(/<script>/g, '<script type="text/javascript">');
h = h.replace(/<script(|[^>]+)>(\s*<!--|\/\/\s*<\[CDATA\[)?[\r\n]*/g, '<mce:script$1><!--\n');
h = h.replace(/\s*(\/\/\s*-->|\/\/\s*]]>)?<\/script>/g, '\n// --></mce:script>');
h = h.replace(/<mce:script(|[^>]+)><!--\n\/\/ --><\/mce:script>/g, '<mce:script$1></mce:script>');
}
// Process all tags with src, href or style
h = h.replace(/<([\w:]+) [^>]*(src|href|style|coords)[^>]*>/gi, function(a, n) {
function handle(m, b, c) {
var u = c;
// Tag already got a mce_ version
if (a.indexOf('mce_' + b) != -1)
return m;
if (b == 'style') {
// Why did I need this one?
//if (isIE)
// u = t.serializeStyle(t.parseStyle(u));
if (s.hex_colors) {
u = u.replace(/rgb\([^\)]+\)/g, function(v) {
return t.toHex(v);
});
}
if (s.url_converter) {
u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
});
}
} else if (b != 'coords') {
if (s.url_converter)
u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
}
return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
};
a = a.replace(/ (src|href|style|coords)=[\"]([^\"]+)[\"]/gi, handle); // W3C
a = a.replace(/ (src|href|style|coords)=[\']([^\']+)[\']/gi, handle); // W3C
return a.replace(/ (src|href|style|coords)=([^\s\"\'>]+)/gi, handle); // IE
});
}
return h;
},
getOuterHTML : function(e) {
var d;
e = this.get(e);
if (!e)
return null;
if (isIE)
return e.outerHTML;
d = (e.ownerDocument || this.doc).createElement("body");
d.appendChild(e.cloneNode(true));
return d.innerHTML;
},
setOuterHTML : function(e, h, d) {
var t = this;
return this.run(e, function(e) {
var n, tp;
e = t.get(e);
d = d || e.ownerDocument || t.doc;
if (isIE && e.nodeType == 1)
e.outerHTML = h;
else {
tp = d.createElement("body");
tp.innerHTML = h;
n = tp.lastChild;
while (n) {
t.insertAfter(n.cloneNode(true), e);
n = n.previousSibling;
}
t.remove(e);
}
});
},
decode : function(s) {
var e;
// Look for entities to decode
if (/&[^;]+;/.test(s)) {
// Decode the entities using a div element not super efficient but less code
e = this.doc.createElement("div");
e.innerHTML = s;
return !e.firstChild ? s : e.firstChild.nodeValue;
}
return s;
},
encode : function(s) {
return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
switch (c) {
case '&':
return '&';
case '"':
return '"';
case '<':
return '<';
case '>':
return '>';
}
return c;
}) : s;
},
// #if !jquery
insertAfter : function(n, r) {
var t = this;
r = t.get(r);
return this.run(n, function(n) {
var p, ns;
p = r.parentNode;
ns = r.nextSibling;
if (ns)
p.insertBefore(n, ns);
else
p.appendChild(n);
return n;
});
},
// #endif
isBlock : function(n) {
if (n.nodeType && n.nodeType !== 1)
return false;
n = n.nodeName || n;
return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
},
// #if !jquery
replace : function(n, o, k) {
if (is(o, 'array'))
n = n.cloneNode(true);
return this.run(o, function(o) {
if (k) {
each(o.childNodes, function(c) {
n.appendChild(c.cloneNode(true));
});
}
return o.parentNode.replaceChild(n, o);
});
},
// #endif
toHex : function(s) {
var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
function hex(s) {
s = parseInt(s).toString(16);
return s.length > 1 ? s : '0' + s; // 0 -> 00
};
if (c) {
s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
return s;
}
return s;
},
getClasses : function() {
var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
if (t.classes)
return t.classes;
function addClasses(s) {
// IE style imports
each(s.imports, function(r) {
addClasses(r);
});
each(s.cssRules || s.rules, function(r) {
// Real type or fake it on IE
switch (r.type || 1) {
// Rule
case 1:
if (r.selectorText) {
each(r.selectorText.split(','), function(v) {
v = v.replace(/^\s*|\s*$|^\s\./g, "");
// Is internal or it doesn't contain a class
if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v))
return;
// Remove everything but class name
ov = v;
v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1');
// Filter classes
if (f && !(v = f(v, ov)))
return;
if (!lo[v]) {
cl.push({'class' : v});
lo[v] = 1;
}
});
}
break;
// Import
case 3:
addClasses(r.styleSheet);
break;
}
});
};
try {
each(t.doc.styleSheets, addClasses);
} catch (ex) {
// Ignore
}
if (cl.length > 0)
t.classes = cl;
return cl;
},
run : function(e, f, s) {
var t = this, o;
if (typeof(e) === 'string')
e = t.doc.getElementById(e);
if (!e)
return false;
s = s || this;
if (!e.nodeType && (e.length || e.length === 0)) {
o = [];
each(e, function(e, i) {
if (e) {
if (typeof(e) == 'string')
e = t.doc.getElementById(e);
o.push(f.call(s, e, i));
}
});
return o;
}
return f.call(s, e);
}
/*
walk : function(n, f, s) {
var d = this.doc, w;
if (d.createTreeWalker) {
w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
while ((n = w.nextNode()) != null)
f.call(s || this, n);
} else
tinymce.walk(n, f, 'childNodes', s);
}
*/
/*
toRGB : function(s) {
var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
if (c) {
// #FFF -> #FFFFFF
if (!is(c[3]))
c[3] = c[2] = c[1];
return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
}
return s;
}
*/
});
// Setup page DOM
tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
})();
/* file:jscripts/tiny_mce/classes/dom/Event.js */
(function() {
// Shorten names
var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
tinymce.create('static tinymce.dom.Event', {
inits : [],
events : [],
// #if !jquery
add : function(o, n, f, s) {
var cb, t = this, el = t.events, r;
// Handle array
if (o && o instanceof Array) {
r = [];
each(o, function(o) {
o = DOM.get(o);
r.push(t.add(o, n, f, s));
});
return r;
}
o = DOM.get(o);
if (!o)
return;
// Setup event callback
cb = function(e) {
e = e || window.event;
// Patch in target in IE it's W3C valid
if (e && !e.target && isIE)
e.target = e.srcElement;
if (!s)
return f(e);
return f.call(s, e);
};
if (n == 'unload') {
tinymce.unloads.unshift({func : cb});
return cb;
}
if (n == 'init') {
if (t.domLoaded)
cb();
else
t.inits.push(cb);
return cb;
}
// Store away listener reference
el.push({
obj : o,
name : n,
func : f,
cfunc : cb,
scope : s
});
t._add(o, n, cb);
return f;
},
remove : function(o, n, f) {
var t = this, a = t.events, s = false, r;
// Handle array
if (o && o instanceof Array) {
r = [];
each(o, function(o) {
o = DOM.get(o);
r.push(t.remove(o, n, f));
});
return r;
}
o = DOM.get(o);
each(a, function(e, i) {
if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
a.splice(i, 1);
t._remove(o, n, e.cfunc);
s = true;
return false;
}
});
return s;
},
// #endif
cancel : function(e) {
if (!e)
return false;
this.stop(e);
return this.prevent(e);
},
stop : function(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
return false;
},
prevent : function(e) {
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
return false;
},
_unload : function() {
var t = Event;
each(t.events, function(e, i) {
t._remove(e.obj, e.name, e.cfunc);
e.obj = e.cfunc = null;
});
t.events = [];
t = null;
},
_add : function(o, n, f) {
if (o.attachEvent)
o.attachEvent('on' + n, f);
else if (o.addEventListener)
o.addEventListener(n, f, false);
else
o['on' + n] = f;
},
_remove : function(o, n, f) {
if (o.detachEvent)
o.detachEvent('on' + n, f);
else if (o.removeEventListener)
o.removeEventListener(n, f, false);
else
o['on' + n] = null;
},
_pageInit : function() {
var e = Event;
e._remove(window, 'DOMContentLoaded', e._pageInit);
e.domLoaded = true;
each(e.inits, function(c) {
c();
});
e.inits = [];
},
_wait : function() {
var t;
// No need since the document is already loaded
if (window.tinyMCE_GZ && tinyMCE_GZ.loaded)
return;
if (isIE && document.location.protocol != 'https:') {
// Fake DOMContentLoaded on IE
document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
DOM.get("__ie_onload").onreadystatechange = function() {
if (this.readyState == "complete") {
Event._pageInit();
DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
}
};
} else {
Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
if (isIE || isWebKit) {
t = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
clearInterval(t);
Event._pageInit();
}
}, 10);
}
}
}
});
// Shorten name
Event = tinymce.dom.Event;
// Dispatch DOM content loaded event for IE and Safari
Event._wait();
tinymce.addUnload(Event._unload);
})();
/* file:jscripts/tiny_mce/classes/dom/Element.js */
(function() {
var each = tinymce.each;
tinymce.create('tinymce.dom.Element', {
Element : function(id, s) {
var t = this, dom, el;
s = s || {};
t.id = id;
t.dom = dom = s.dom || tinymce.DOM;
t.settings = s;
// Only IE leaks DOM references, this is a lot faster
if (!tinymce.isIE)
el = t.dom.get(t.id);
each([
'getPos',
'getRect',
'getParent',
'add',
'setStyle',
'getStyle',
'setStyles',
'setAttrib',
'setAttribs',
'getAttrib',
'addClass',
'removeClass',
'hasClass',
'getOuterHTML',
'setOuterHTML',
'remove',
'show',
'hide',
'isHidden',
'setHTML',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -