May 27, 2010, 2:19 PM
[CLOSED] [0.82] Custom tool in HTMLEditor to open window and insert text
I am trying to implement custom tool in HTMLEditor. The tool will pop up a Ext window and allow user to select something and then insert it into the HtmlEditor. A couple of issues:
1. The window is shown BEHIND the HtmlEditor.
2. HtmlEditor.insertAtCursor does not work since the htmleditor looses focus when the window is opened.
1. The window is shown BEHIND the HtmlEditor.
2. HtmlEditor.insertAtCursor does not work since the htmleditor looses focus when the window is opened.
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<script type="text/javascript">
Ext.ns('Ext.ux.form.HtmlEditor');
Ext.ux.form.HtmlEditor.Test = Ext.extend(Ext.util.Observable, {
// private
init: function(cmp) {
this.cmp = cmp;
this.cmp.on('render', this.onRender, this);
},
// private
onRender: function() {
var cmp = this.cmp;
var btn = this.cmp.getToolbar().addButton({
iconCls: 'icon-pencil',
handler: function() {
if (!this.win) {
this.win = new Ext.Window({
title: 'Test',
closeAction: 'hide',
width: 300,
height: 300,
buttons: [{
text: 'Insert',
handler: function() {
this.cmp.insertAtCursor('Success');
this.win.hide();
},
scope: this
}, {
text: 'Cancel',
handler: function() {
this.win.hide();
},
scope: this
}]
});
}
this.win.show();
},
scope: this,
tooltip: {
title: 'Test Window'
}
});
}
});
</script>
<form id="Form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:ViewPort ID="ViewPort1" runat="server">
<Body>
<ext:Panel ID="Panel1" runat="server" Width="610" Height="300" Html="Content" BodyStyle="padding:5px;"
Title="Editor panel" StyleSpec="padding:10px">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:ToolbarButton ID="Button1" runat="server" Text="Edit" Icon="Pencil">
<Listeners>
<Click Handler="el.setDisabled(true);#{Button2}.setDisabled(false);#{PanelEditor}.startEdit(#{Panel1}.getBody());" />
</Listeners>
</ext:ToolbarButton>
<ext:ToolbarButton ID="Button2" runat="server" Text="Save" Icon="Disk" Disabled="true">
<Listeners>
<Click Handler="el.setDisabled(true);#{Button1}.setDisabled(false);#{PanelEditor}.completeEdit();" />
</Listeners>
</ext:ToolbarButton>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
<ext:Editor ID="PanelEditor" runat="server" AutoSize="Fit" Shadow="None">
<Field>
<ext:HtmlEditor ID="HtmlEditor1" runat="server">
<Plugins>
<ext:GenericPlugin InstanceOf="Ext.ux.form.HtmlEditor.Test">
</ext:GenericPlugin>
</Plugins>
</ext:HtmlEditor>
</Field>
</ext:Editor>
</Body>
</ext:ViewPort>
</form>
</body>
</html>