提交 4a5973d6 编写于 作者: U unknown

tiny

上级 692b347e
...@@ -1528,6 +1528,7 @@ ...@@ -1528,6 +1528,7 @@
var closeHandler = function (state) { var closeHandler = function (state) {
return function () { return function () {
state.open = false; state.open = false;
tinymce.activeEditor.activeO2ImageDialog = null;
}; };
}; };
var makeDialogBody = function (info) { var makeDialogBody = function (info) {
...@@ -1705,7 +1706,7 @@ ...@@ -1705,7 +1706,7 @@
}; };
var open = function () { var open = function () {
collect(editor).then(makeDialog(helpers)).then(function (arg) { collect(editor).then(makeDialog(helpers)).then(function (arg) {
editor.windowManager.open(arg); tinymce.activeEditor.activeO2ImageDialog = editor.windowManager.open(arg);
tinymce.dom.DomQuery(".tox-lock").css("display","none"); tinymce.dom.DomQuery(".tox-lock").css("display","none");
}); });
}; };
......
...@@ -1528,6 +1528,7 @@ ...@@ -1528,6 +1528,7 @@
var closeHandler = function (state) { var closeHandler = function (state) {
return function () { return function () {
state.open = false; state.open = false;
tinymce.activeEditor.activeO2ImageDialog = null;
}; };
}; };
var makeDialogBody = function (info) { var makeDialogBody = function (info) {
...@@ -1705,7 +1706,7 @@ ...@@ -1705,7 +1706,7 @@
}; };
var open = function () { var open = function () {
collect(editor).then(makeDialog(helpers)).then(function (arg) { collect(editor).then(makeDialog(helpers)).then(function (arg) {
editor.windowManager.open(arg); tinymce.activeEditor.activeO2ImageDialog = editor.windowManager.open(arg);
tinymce.dom.DomQuery(".tox-lock").css("display","none"); tinymce.dom.DomQuery(".tox-lock").css("display","none");
}); });
}; };
......
...@@ -1205,10 +1205,20 @@ ...@@ -1205,10 +1205,20 @@
}); });
blobCache.add(blobInfo); blobCache.add(blobInfo);
editor.undoManager.transact(function () { editor.undoManager.transact(function () {
debugger;
var base64enable = editor.getParam('base64Encode', false );
var isBlob = selectedImage.src.indexOf("blob:") === 0 || selectedImage.src.indexOf("data:") === 0;
var images_upload_handler = editor.getParam('images_upload_handler', undefined, 'function'); var images_upload_handler = editor.getParam('images_upload_handler', undefined, 'function');
if( images_upload_handler ) { if( ( base64enable && isBlob ) || images_upload_handler ) {
var imageLoadedHandler = function () { var imageLoadedHandler = function () {
editor.$(selectedImage).off('load', imageLoadedHandler); editor.$(selectedImage).off('load', imageLoadedHandler).attr({
"data-height": ''+selectedImage.naturalHeight,
"data-width": ''+selectedImage.naturalWidth
}).css({
"width": selectedImage.naturalWidth+"px",
"max-width": "100%"
}).removeAttr('data-mce-src').removeAttr('height').removeAttr('width').removeAttr('data-mce-style');
editor.nodeChanged(); editor.nodeChanged();
if (uploadImmediately) { if (uploadImmediately) {
editor.editorUpload.uploadImagesAuto(); editor.editorUpload.uploadImagesAuto();
...@@ -1226,9 +1236,6 @@ ...@@ -1226,9 +1236,6 @@
} }
editor.$(selectedImage).attr({src: blobInfo.blobUri()}).removeAttr('data-mce-src'); editor.$(selectedImage).attr({src: blobInfo.blobUri()}).removeAttr('data-mce-src');
}else{ }else{
debugger;
//var enablePreview = editor.getParam('enablePreview', true); //var enablePreview = editor.getParam('enablePreview', true);
var localImageMaxWidth = editor.getParam('localImageMaxWidth', 2000); var localImageMaxWidth = editor.getParam('localImageMaxWidth', 2000);
var reference = editor.getParam('reference'); var reference = editor.getParam('reference');
......
...@@ -140,35 +140,52 @@ MWF.xApplication.process.Xform.TinyMCEEditor = MWF.APPTinyMCEEditor = new Class( ...@@ -140,35 +140,52 @@ MWF.xApplication.process.Xform.TinyMCEEditor = MWF.APPTinyMCEEditor = new Class(
'|style|data-id|data-orgid|data-height|data-width|onerror|data-prv]', '|style|data-id|data-orgid|data-height|data-width|onerror|data-prv]',
file_picker_callback: function (callback, value, meta) { file_picker_callback: function (callback, value, meta) {
//this 指向editor实例 //this 指向editor实例
// if (meta.filetype === 'file') { if (meta.filetype === 'image') { //'file', 'media'
// callback('https://www.baidu.com/img/bd_logo1.png', { text: 'My text' }); if( this.activeO2ImageDialog && this.activeO2ImageDialog.getData().base64enable ) {
// } var fileNode = new Element("input", {
if (meta.filetype === 'image') { "type" : "file",
"accept":"image/*",
"styles" : {"display":"none"}
var enablePreview = this.getParam('enablePreview', true); });
var localImageMaxWidth = this.getParam('localImageMaxWidth', 2000); fileNode.addEvent("change", function(event){
var reference = this.getParam('reference'); var file= fileNode.files[0];
var referenceType = this.getParam('referenceType'); if(!/image\/\w+/.test(file.type)){ //判断获取的是否为图片文件
if( !reference || !referenceType )return; MWF.xDesktop.notice('请选择图片格式文件',"error");
return false;
MWF.require("MWF.widget.Upload", function(){ }
var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_file_assemble_control"); var reader=new FileReader();
reader.readAsDataURL(file);
var upload = new MWF.widget.Upload($(document.body), { reader.onload = function(e){
"data": null, callback( this.result, {
"parameter": {"reference" : reference, "referencetype": referenceType, "scale" : localImageMaxWidth || 2000 }, "style": 'max-width:100%;', //width:' + width + 'px',
"action": action, "alt": file.name || '',
"method": "uploadImageByScale", "data-prv": 'true' //enablePreview ? 'true' : 'false'
"accept": "image/*", })
"onEvery": function(json, index, count, file){ }
}.bind( this ));
var id = json.data ? json.data.id : json.id; fileNode.click();
var src = MWF.xDesktop.getImageSrc( id ); }else{
var enablePreview = this.getParam('enablePreview', true);
new Element("img", { var localImageMaxWidth = this.getParam('localImageMaxWidth', 2000);
src : src, var reference = this.getParam('reference');
events : { load : function (ev) { var referenceType = this.getParam('referenceType');
if( !reference || !referenceType )return;
MWF.require("MWF.widget.Upload", function(){
var action = new MWF.xDesktop.Actions.RestActions("/xDesktop/Actions/action.json", "x_file_assemble_control");
var upload = new MWF.widget.Upload($(document.body), {
"data": null,
"parameter": {"reference" : reference, "referencetype": referenceType, "scale" : localImageMaxWidth || 2000 },
"action": action,
"method": "uploadImageByScale",
"accept": "image/*",
"onEvery": function(json, index, count, file){
var id = json.data ? json.data.id : json.id;
var src = MWF.xDesktop.getImageSrc( id );
new Element("img", {
src : src,
events : { load : function (ev) {
var width = ev.target.naturalWidth; var width = ev.target.naturalWidth;
var height = ev.target.naturalHeight; var height = ev.target.naturalHeight;
...@@ -192,16 +209,14 @@ MWF.xApplication.process.Xform.TinyMCEEditor = MWF.APPTinyMCEEditor = new Class( ...@@ -192,16 +209,14 @@ MWF.xApplication.process.Xform.TinyMCEEditor = MWF.APPTinyMCEEditor = new Class(
}; };
callback( src, attributes ) callback( src, attributes )
}} }}
}); });
}.bind(this) }.bind(this)
}); });
upload.load(); upload.load();
}.bind(this)); }.bind(this));
}
} }
// if (meta.filetype === 'media') {
// callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.baidu.com/img/bd_logo1.png' });
// }
}, },
init_instance_defaultCallback: function(editor) { init_instance_defaultCallback: function(editor) {
editor.on("ObjectResized", function(ev){ editor.on("ObjectResized", function(ev){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册