Ext下的FCKeditor扩展完善

本文介绍如何在Extjs项目中集成FCKeditor富文本编辑器,并解决同一页面加载多个实例及设置值的问题。提供了修改过的Extjs+FCKeditor集成代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于项目需要用到Extjs+FCKeditor,在Extjs官方坛论上找到了FCKeditor的扩展[url]http://extjs.com/forum/showthread.php?t=17423[/url],在使用过程中到了不少的问题,主要是同一个页面加载多个FCK instance及设置SetValue的问题。以下是修改过后的代码:

Ext.namespace('Ext.ux.form');

/**
* FCKeditor 初始配置信息
*
* @type {Object}
*/
var oFCKeditorOptions = {
BasePath : 'js/fckeditor/',
Config : {
BaseHref : window.location,
SkinPath : '../editor/skins/office2003/',
ProcessHTMLEntities : true,
ProcessNumericEntities : false,
ToolbarStartExpanded : true,
LinkBrowser : true,
ImageBrowser : true,
FlashBrowser : true,
LinkUpload : true,
ImageUpload : true,
FlashUpload : true
},
ToolbarSet : 'Symbol'
};

/**
* Ext FCKeditor
*
* @param {Object}
* config 配置信息
*/
Ext.ux.form.FCKeditor = function(config) {
this.config = config;
Ext.ux.form.FCKeditor.superclass.constructor.call(this, config);
/**
* 通知FCKeditor是否实例化
* notice the component's FCKeditor instance inited
* @type Boolean
*/
this.instanceLoaded = false;
/**
* 实例值
* the component's FCKeditor instance value
* @type String
*/
this.instanceValue = '';
/**
* 组件的FCKeditor实例
* @type {FCKeditor}
*/
this.editorInstance = undefined;
};
/**
* Ext FCKeditor
*
* @class Ext.ux.form.FCKeditor
* @extends Ext.form.TextArea
*/
Ext.extend(Ext.ux.form.FCKeditor, Ext.form.TextArea, {
/**
* 初始化事件
*/
initEvents : function() {
this.on('destroy', function() {
if (typeof this.editorInstance != 'undefined') {
delete this.editorInstance;
}
});
},
onRender : function(ct, position) {
if (!this.el) {
this.defaultAutoCreate = {
tag : "textarea",
style : "width:100px;height:60px;",
autocomplete : "off"
};
}
Ext.form.TextArea.superclass.onRender.call(this, ct, position);
this.hideMode = "visibility";
this.hidden = true;
if (this.grow) {
this.textSizeEl = Ext.DomHelper.append(document.body, {
tag : "pre",
cls : "x-form-grow-sizer"
});
if (this.preventScrollbars) {
this.el.setStyle("overflow", "hidden");
}
this.el.setHeight(this.growMin);
}
setTimeout("loadFCKeditor('" + this.id + "'," + this.config.height + ");", 100); // Change
},
/**
* 设置是否已经加载过此控件
* set FCKeditor instance is inited
* @param {Boolean} v
*/
setIsLoaded : function(v) {
this.instanceLoaded = v;
},
/**
* 获取是否已实例化过此控件
* get FCKeditor instance is inited
* @return {Boolean}
*/
getIsLoaded : function() {
return this.instanceLoaded;
},
/**
*
* @param {String} value
*/
setValue : function(value) {
this.instanceValue = value;
if (this.instanceLoaded) {
this.FCKeditorSetValue(value); // Change this.name
}
Ext.form.TextArea.superclass.setValue.apply(this, [value]);
},
/**
*
* @return {String}
*/
getValue : function() {
if (this.instanceLoaded) {
value = this.FCKeditorGetValue(); // Change this.name to this.id
Ext.form.TextArea.superclass.setValue.apply(this, [value]);
return Ext.form.TextArea.superclass.getValue.call(this); // Change getValue(this) to
} else {
return this.instanceValue;
}
},
/**
*
* @return {String}
*/
getRawValue : function() {
if (this.instanceLoaded) {
value = this.FCKeditorGetValue(); // Change this.name to this.id
Ext.form.TextArea.superclass.setRawValue.apply(this, [value]);
return Ext.form.TextArea.superclass.getRawValue.call(this); // Change getValue(this) to
} else {
return this.instanceValue;
}
},
/**
* 设置FCKeditor实例的值
* @param {String} value
*/
FCKeditorSetValue : function(value) {
if(this.instanceLoaded == false){
return;
}
// fix IE No Permission Denied errors
var runner = new Ext.util.TaskRunner();
var task = {
run : function() {
try {
var editor = this.editorInstance; // update var editor
if (editor.EditorDocument.body) {
editor.SetData(value);
runner.stop(task);
}
} catch (ex) {
//Ext.logf('调试信息(info):{0}', ex);
}
},
interval : 100,
scope : this
};
runner.start(task); // end fix
},
/**
* 获取FCKeditor实例的值
* @return {String}
*/
FCKeditorGetValue : function() {
var data = '';
if(this.instanceLoaded == false){
return data;
}
data = this.editorInstance.GetData();
return data;
}
});
Ext.reg('fckeditor', Ext.ux.form.FCKeditor);

/**
* 实例化FCKeditor
*
* @param {String}
* element el id
* @param {Number}
* height
*/
function loadFCKeditor(element, height) {
var oFCKeditor = new FCKeditor(element);
oFCKeditor.BasePath = oFCKeditorOptions.BasePath;
oFCKeditor.ToolbarSet = oFCKeditorOptions.ToolbarSet;
oFCKeditor.Config = oFCKeditorOptions.Config;
oFCKeditor.Height = height;
oFCKeditor.ReplaceTextarea();
}
/**
* FCKeditor API: 当FCKeditor实例化完成时执行
*
* @param {FCKeditor} editorInstance
*/
function FCKeditor_OnComplete(editorInstance) {
/**
* @type {Ext.ux.form.FCKeditor}
*/
var activeEditor = Ext.getCmp(editorInstance.Name);
activeEditor.editorInstance = editorInstance;
activeEditor.instanceLoaded = true;
activeEditor.FCKeditorSetValue(activeEditor.instanceValue);
editorInstance.Events.AttachEvent('OnBlur', FCKeditor_OnBlur);
editorInstance.Events.AttachEvent('OnFocus', FCKeditor_OnFocus);
}

function FCKeditor_OnBlur(editorInstance) {
editorInstance.ToolbarSet.Collapse();
}

function FCKeditor_OnFocus(editorInstance) {
editorInstance.ToolbarSet.Expand();
}

示例:

<html>
<head>
<title> New Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css">
<script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext/ext-all-debug.js"></script>
<script type="text/javascript" src="../lib/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="Ext.ux.form.FCKeditor.js"></script>
</head>

<body>
<script language="JavaScript">
<!--
Ext.onReady(function() {
var win_cxpz = new Ext.Window({
layout : 'fit',
width : 800,
title :'FCKeditor 示例',
height : 400,
closeAction :'hide',
plain : true,
item :[{
xtype : 'fckeditor'
}],
buttonAlign :'center',
buttons: [{
text : '返回',
handler : function(){
win_cxpz.hide();
}
}]
});
win_cxpz.show();

});
//-->
</script>
</body>
</html>
内容概要:本文系统介绍了基于C#(VS2022+.NET Core)与HALCON 24.11的工业视觉测量拟合技术,涵盖边缘提取、几何拟合、精度优化及工业部署全流程。文中详细解析了亚像素边缘提取、Tukey抗噪算法、SVD平面拟合等核心技术,并提供了汽车零件孔径测量、PCB焊点共面性检测等典型应用场景的完整代码示例。通过GPU加速、EtherCAT同步等优化策略,实现了±0.01mm级测量精度,满足ISO 1101标准。此外,文章还探讨了深度学习、量子启发式算法等前沿技术的应用前景。 适合人群:具备一定编程基础,尤其是熟悉C#和HALCON的工程师或研究人员,以及从事工业视觉测量与自动化检测领域的技术人员。 使用场景及目标:①学习如何使用C#和HALCON实现高精度工业视觉测量系统的开发;②掌握边缘提取、抗差拟合、3D点云处理等核心技术的具体实现方法;③了解工业部署中的关键技术,如GPU加速、EtherCAT同步控制、实时数据看板等;④探索基于深度学习和量子计算的前沿技术在工业视觉中的应用。 其他说明:本文不仅提供了详细的理论分析和技术实现,还附有完整的代码示例和实验数据,帮助读者更好地理解和实践。同时,文中提到的硬件选型、校准方法、精度验证等内容,为实际项目实施提供了重要参考。文章最后还给出了未来的技术演进方向和开发者行动建议,如量子-经典混合计算、自监督学习等,以及参与HALCON官方认证和开源社区的建议。
内容概要:本文介绍了基于WOA-GRU-Attention模型的时序数据分类预测项目,旨在提升时序数据分类准确率,实现智能优化,并提供强泛化能力的分类框架。项目背景指出传统机器学习方法难以处理时序数据的复杂特性,而GRU、注意力机制和WOA的结合能有效应对这些问题。文章详细描述了项目的目标与意义,包括提升分类准确率、实现智能优化、推动元启发式算法的应用等。同时,文中列出了项目面临的挑战及解决方案,如高维数据特征复杂、超参数调优难度大等。项目模型架构由WOA、GRU和注意力机制三部分组成,通过Python代码示例展示了模型的具体实现,包括模型定义、训练过程和WOA优化算法的核心步骤。; 适合人群:具备一定编程基础,尤其是对深度学习、时序数据分析感兴趣的开发者和研究人员。; 使用场景及目标:① 提升时序数据分类准确率,特别是在金融、医疗、智能制造等领域;② 实现模型训练过程的智能优化,避免传统调参的局限;③ 提供具备强泛化能力的时序数据分类框架,支持多行业多场景应用;④ 推动高性能时序模型的工业应用落地,提高智能系统的响应速度和决策质量。; 其他说明:项目不仅实现了工程应用,还在理论层面对GRU结构与注意力机制的融合进行了系统分析,结合WOA优化过程对模型训练动力学展开研究,促进了深度学习与优化算法交叉研究领域的发展。读者可以通过提供的代码示例和链接进一步了解项目的具体实现和应用场景。
内容概要:本文详细介绍了如何使用PyQt5创建一个功能全面的桌面备忘录应用程序,涵盖从环境准备、数据库设计、界面设计到主程序结构及高级功能实现的全过程。首先,介绍了所需安装的Python库,包括PyQt5、sqlite3等。接着,详细描述了SQLite数据库的设计,创建任务表和类别表,并插入默认类别。然后,使用Qt Designer设计UI界面,包括主窗口、任务列表、工具栏、过滤器和日历控件等。主程序结构部分,展示了如何初始化UI、加载数据库数据、显示任务列表以及连接信号与槽。任务管理功能方面,实现了添加、编辑、删除、标记完成等操作。高级功能包括类别管理、数据导入导出、优先级视觉标识、到期日提醒、状态管理和智能筛选等。最后,提供了应用启动与主函数的代码,并展望了扩展方向,如多用户支持、云同步、提醒通知等。 适合人群:零基础或初学者,对Python和桌面应用程序开发感兴趣的开发者。 使用场景及目标:①学习PyQt5的基本使用方法,包括界面设计、信号与槽机制;②掌握SQLite数据库的基本操作,如创建表、插入数据、查询等;③实现一个完整的桌面应用程序,具备增删改查和数据持久化功能;④了解如何为应用程序添加高级特性,如类别管理、数据导入导出、到期日提醒等。 阅读建议:此资源不仅适用于零基础的学习者,也适合有一定编程经验的开发者深入理解PyQt5的应用开发。建议读者跟随教程逐步实践,结合实际操作来理解和掌握每个步骤,同时可以尝试实现扩展功能,进一步提升自己的开发技能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值