projects
/
roojs1
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sync
[roojs1]
/
Roo
/
HtmlEditorCore.js
diff --git
a/Roo/HtmlEditorCore.js
b/Roo/HtmlEditorCore.js
index
da537aa
..
b997fb1
100644
(file)
--- a/
Roo/HtmlEditorCore.js
+++ b/
Roo/HtmlEditorCore.js
@@
-71,7
+71,8
@@
Roo.HtmlEditorCore = function(config){
* Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
* @param {Roo.HtmlEditorCore} this
*/
* Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
* @param {Roo.HtmlEditorCore} this
*/
- editorevent: true
+ editorevent: true
+
});
});
@@
-122,6
+123,11
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
*
*/
stylesheets: false,
*
*/
stylesheets: false,
+ /**
+ * @cfg {String} language default en - language of text (usefull for rtl languages)
+ *
+ */
+ language: 'en',
/**
* @cfg {boolean} allowComments - default false - allow comments in HTML source
/**
* @cfg {boolean} allowComments - default false - allow comments in HTML source
@@
-189,14
+195,16
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
st += '<style type="text/css">' +
'IMG { cursor: pointer } ' +
'</style>';
st += '<style type="text/css">' +
'IMG { cursor: pointer } ' +
'</style>';
-
- var cls = 'roo-htmleditor-body';
+
+ st += '<meta name="google" content="notranslate">';
+
+ var cls = 'notranslate roo-htmleditor-body';
if(this.bodyCls.length){
cls += ' ' + this.bodyCls;
}
if(this.bodyCls.length){
cls += ' ' + this.bodyCls;
}
- return '<html><head>' + st +
+ return '<html
class="notranslate" translate="no"
><head>' + st +
//<style type="text/css">' +
//'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
//'</style>' +
//<style type="text/css">' +
//'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
//'</style>' +
@@
-323,7
+331,8
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
* @param {String} html The HTML to be cleaned
* return {String} The cleaned HTML
*/
* @param {String} html The HTML to be cleaned
* return {String} The cleaned HTML
*/
- cleanHtml : function(html){
+ cleanHtml : function(html)
+ {
html = String(html);
if(html.length > 5){
if(Roo.isSafari){ // strip safari nonsense
html = String(html);
if(html.length > 5){
if(Roo.isSafari){ // strip safari nonsense
@@
-352,18
+361,27
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
var bd = (this.doc.body || this.doc.documentElement);
var bd = (this.doc.body || this.doc.documentElement);
+ var sel = this.win.getSelection();
var div = document.createElement('div');
div.innerHTML = bd.innerHTML;
var div = document.createElement('div');
div.innerHTML = bd.innerHTML;
-
+ var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of.
+ if (gtx.length > 0) {
+ var rm = gtx.item(0).parentNode;
+ rm.parentNode.removeChild(rm);
+ }
+
if (this.enableBlocks) {
new Roo.htmleditor.FilterBlock({ node : div });
}
//?? tidy?
if (this.enableBlocks) {
new Roo.htmleditor.FilterBlock({ node : div });
}
//?? tidy?
+ var tidy = new Roo.htmleditor.TidySerializer({
+ inner: true
+ });
+ var html = tidy.serialize(div);
- var html = div.innerHTML;
if(Roo.isSafari){
var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
var m = bs ? bs.match(/text-align:(.*?);/i) : false;
if(Roo.isSafari){
var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
var m = bs ? bs.match(/text-align:(.*?);/i) : false;
@@
-432,6
+450,7
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
}
Roo.htmleditor.Block.initAll(this.doc.body);
}
Roo.htmleditor.Block.initAll(this.doc.body);
+ this.updateLanguage();
var lc = this.doc.body.lastChild;
if (lc && lc.nodeType == 1 && lc.getAttribute("contenteditable") == "false") {
var lc = this.doc.body.lastChild;
if (lc && lc.nodeType == 1 && lc.getAttribute("contenteditable") == "false") {
@@
-501,9
+520,11
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
//var ss = this.el.getStyles( 'background-image', 'background-repeat');
//ss['background-attachment'] = 'fixed'; // w3c
dbody.bgProperties = 'fixed'; // ie
//var ss = this.el.getStyles( 'background-image', 'background-repeat');
//ss['background-attachment'] = 'fixed'; // w3c
dbody.bgProperties = 'fixed'; // ie
+ dbody.setAttribute("translate", "no");
+
//Roo.DomHelper.applyStyles(dbody, ss);
Roo.EventManager.on(this.doc, {
//Roo.DomHelper.applyStyles(dbody, ss);
Roo.EventManager.on(this.doc, {
- //'mousedown': this.onEditorEvent,
+
'mouseup': this.onEditorEvent,
'dblclick': this.onEditorEvent,
'click': this.onEditorEvent,
'mouseup': this.onEditorEvent,
'dblclick': this.onEditorEvent,
'click': this.onEditorEvent,
@@
-534,7
+555,8
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
this.owner.fireEvent('initialize', this);
this.pushValue();
},
this.owner.fireEvent('initialize', this);
this.pushValue();
},
-
+ // this is to prevent a href clicks resulting in a redirect?
+
onPasteEvent : function(e,v)
{
// I think we better assume paste is going to be a dirty load of rubish from word..
onPasteEvent : function(e,v)
{
// I think we better assume paste is going to be a dirty load of rubish from word..
@@
-602,20
+624,23
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
}
if (this.enableBlocks) {
}
if (this.enableBlocks) {
- Array.from(d.getElement
ByTagTyp
e('img')).forEach(function(img) {
+ Array.from(d.getElement
sByTagNam
e('img')).forEach(function(img) {
if (img.closest('figure')) { // assume!! that it's aready
return;
}
if (img.closest('figure')) { // assume!! that it's aready
return;
}
- var fig = Roo.htmleditor.BlockFigure({
-
+ var fig =
new
Roo.htmleditor.BlockFigure({
+ image_src : img.src
});
});
+ fig.updateElement(img); // replace it..
- })
+ })
;
}
}
- this.insertAtCursor(d.innerHTML);
- Roo.htmleditor.Block.initAll(this.doc.body);
+ this.insertAtCursor(d.innerHTML.replace(/ /g,' '));
+ if (this.enableBlocks) {
+ Roo.htmleditor.Block.initAll(this.doc.body);
+ }
e.preventDefault();
e.preventDefault();
@@
-690,6
+715,7
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
onEditorEvent : function(e)
{
onEditorEvent : function(e)
{
+
if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) {
return; // we do not handle this.. (undo manager does..)
if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) {
return; // we do not handle this.. (undo manager does..)
@@
-1044,8
+1070,7
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
// should we cache this!!!!
// should we cache this!!!!
-
-
+
var range = this.createRange(this.getSelection()).cloneRange();
var range = this.createRange(this.getSelection()).cloneRange();
@@
-1109,6
+1134,8
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
return nodes[0];
},
return nodes[0];
},
+
+
createRange: function(sel)
{
// this has strange effects when using with
createRange: function(sel)
{
// this has strange effects when using with
@@
-1420,6
+1447,16
@@
Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
},
},
+
+ updateLanguage : function()
+ {
+ if (!this.iframe || !this.iframe.contentDocument) {
+ return;
+ }
+ Roo.get(this.iframe.contentDocument.body).attr("lang", this.language);
+ },
+
+
removeStylesheets : function()
{
var _this = this;
removeStylesheets : function()
{
var _this = this;