This small patch allows the user to insert a template without
deleting the current content of the editor. It adds a checkbox to
the template dialog window (fck_template.html) and a simple
string in en.js -- Please update your language file accordingly.
The following diff can be run against the 2.1 version of the FCK
editor. (might work against 2.0 -- I haven't tried)
diff -U 3 -H -d -r -N --
FCKeditor_2.1/editor/dialog/fck_template.html
fck/editor/dialog/fck_template.html
--- FCKeditor_2.1/editor/dialog/fck_template.html 2005-10-03
14:59:08.000000000 -0400
+++ fck/editor/dialog/fck_template.html 2005-10-14
10:18:28.000000000 -0400
@@ -177,7 +177,12 @@
function SelectTemplate( index )
{
oEditor.FCKUndo.SaveUndoStep() ;
- FCK.SetHTML( FCK._Templates[index].Html ) ;
+
+ if(GetE('insertOnly').checked)
+ FCK.InsertHTML( FCK._Templates[index].Html ) ;
+ else
+ FCK.SetHTML( FCK._Templates[index].Html ) ;
+
window.parent.Cancel() ;
}
@@ -205,6 +210,11 @@
</div>
</td>
</tr>
+ <tr>
+ <td align="center">
+ <input type="checkbox"
name="insertOnly" id="insertOnly"><label
for="insertOnly"><span
fckLang="DlgTemplatesInsertOnly">Insert to cursor
position</span></label>
+ </td>
+ </tr>
</table>
</body>
</html>
diff -U 3 -H -d -r -N -- FCKeditor_2.1/editor/lang/en.js
fck/editor/lang/en.js
--- FCKeditor_2.1/editor/lang/en.js 2005-09-21
12:53:40.000000000 -0400
+++ fck/editor/lang/en.js 2005-10-14 10:23:14.000000000
-0400
@@ -465,6 +465,7 @@
DlgTemplatesSelMsg : "Please select the template to open
in the editor<br>(the actual contents will be lost):",
DlgTemplatesLoading : "Loading templates list. Please
wait...",
DlgTemplatesNoTpl : "(No templates defined)",
+DlgTemplatesInsertOnly : "Insert to cursor position",
// About Dialog
DlgAboutAboutTab : "About",
Sorry if the diff file doesn't work out of the box. I'm not sure how
to create those kind of files. Since it basically only change 3
lines of code, it should be trivial to add to the version.
Please include this patch in the next version of FCK if
possible :)
Logged In: YES
user_id=1194901
Arrgh wrong patch :(
Please change the line
FCK.InsertHTML( FCK._Templates[index].Html ) ;
to
FCK.InsertHtml( FCK._Templates[index].Html ) ;
(changed case of "HTML" to "Html")
Logged In: YES
user_id=1430814
I want to use this patch, but I am not following your diff
on how / what to change.
If it si a few lines of code, could you also past
the "before and after" codes, with their line numbers?
Thanks!
Logged In: NO
this method work in the 2.2 version as well
Logged In: NO
Great! this is exactly what i was looking for..
fck_template.html with patch applied for VERSION 2.3
Logged In: YES
user_id=1194901
The patch should work against the 2.3 version too, although
I can not confirm.
So I have uploaded a new file which contains the complete
HTML file for those having trouble with .diff files.
Just drop fck_template.html inside your FCK/editor/dialog.
Hopefully this little patch may help you, and will get into
trunk...
Logged In: NO
This is great and helpful! To get it to work with
FCKeditor version 2.3, however, I needed to adjust the
case of the FCK.InsertHTML method to FCK.InsertHtml. Just
replaced one line in the fck_template.html file as follows:
FIND:
FCK.InsertHTML( FCK._Templates[index].Html ) ;
REPLACE with:
FCK.InsertHtml( FCK._Templates[index].Html ) ;
I wonder if this is a change in 2.3?
Thanks for the submission,
--MN
Logged In: YES
user_id=572424
Hi,
This patch, or a similar implementation, has been included in
FCKeditor and has been committed in the SVN. It will be available
in the next release.
For more information about the FCKeditor SVN system, please use
the following URL:
http://wiki.fckeditor.net/SVN
Best regards,
Frederico Caldeira Knabben
----
http://www.fckeditor.net
"Support Open Source Software"
PS.: This is a canned response.