I want to have a commandButton that will insert a text at the current cursor in the editor for a macro that I will parse on the back end. I want to insert #SomeMaco# and have it show up in the editor while they are finishing the email, is this possible?
Thanks!
Append text to editor with a command button
I'd like this feature too!
I see that p:editor is based on CLEditor,
but in this section http://premiumsoftware.net/cleditor/doc ... itorMethod I couldn't find an "insertAtCursor" method or something like that.
A nice to have feature could be Drag&Drop placeholders
I see that p:editor is based on CLEditor,
but in this section http://premiumsoftware.net/cleditor/doc ... itorMethod I couldn't find an "insertAtCursor" method or something like that.
A nice to have feature could be Drag&Drop placeholders
WildFly 10.1.0 Final, Mojarra 2.2.15 PrimeFaces 6.2
Finally I solved it.
I created n buttons in a div with id "availablePlaceholders".
Then, I used this script to add .click() behaviour to the buttons.
Note: editorHtml is the widgetVar of p:editor.
Clicking a button with id "hello", inserts "{ hello}" in the p:editor at cursor position.
Hope it helps
I created n buttons in a div with id "availablePlaceholders".
Then, I used this script to add .click() behaviour to the buttons.
Code: Select all
<h:outputScript target="body">
jQuery(PrimeFaces.escapeClientId('availablePlaceholders button')).click(function() {
var token = jQuery(this).attr('id');
editorHtml.editor.focus();
setTimeout(function() {
editorHtml.editor.execCommand('inserthtml', '{ ' + token + ' }', false);
}, 0);
return false
});
</h:outputScript>
Clicking a button with id "hello", inserts "{ hello}" in the p:editor at cursor position.
Hope it helps
WildFly 10.1.0 Final, Mojarra 2.2.15 PrimeFaces 6.2
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Great, thx for sharing with community.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 50 guests