org.eclipse.rap icon indicating copy to clipboard operation
org.eclipse.rap copied to clipboard

Add 'insertText' functionality to the Nebula RichTextEditor

Open ans-kanec opened this issue 1 year ago • 1 comments

The Eclipse Nebula RichTextEditor has an 'insertText' method that inserts a text string in the middle of the existing RichTextEditor text. It would be great to add this 'insertText' functionality to the RAP version of the Nebula RichTextEditor. I have attempted to get this working and will provide the code below:

RichTextEditorHandler.js

(function(){
  'use strict';

  rap.registerTypeHandler( "rwt.widgets.RichTextEditor", {

    factory : function( properties ) {
      return new rwt.widgets.RichTextEditor( properties );
    },

    properties : [ "config", "text", "editable", "font" ],
    
    methods : [ "insertText" ]

  } );

}());

RichTextEditor.js

    insertText : function( params ) {
      if( this.ready ) {
        this.editor.insertText( params.text );
      }
    },

RichTextEditor.java

  /**
   * Insert text to the editing area.  Appends the text in the current cursor position
   * Can contain HTML tags for styling.
   *
   * @param text The text to insert into the editing area.
   */
  public void insertText( String text ) {
    checkWidget();
    if( text == null ) {
      SWT.error( SWT.ERROR_NULL_ARGUMENT );
    }
    JsonObject parameters = new JsonObject()
            .add( "text", text );
    remoteObject.call( "insertText", parameters );
   }

ans-kanec avatar Mar 15 '24 20:03 ans-kanec

Could you please provide these changes as pull request against current state of RAP main branch.

ifurnadjiev avatar Mar 20 '24 09:03 ifurnadjiev