eclipse-rap / org.eclipse.rap

Eclipse RAP Runtime (Remote Application Platform)
https://www.eclipse.org/rap/
Eclipse Public License 1.0
17 stars 19 forks source link

Add 'insertText' functionality to the Nebula RichTextEditor #178

Closed ans-kanec closed 4 weeks ago

ans-kanec commented 6 months ago

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 );
   }
ifurnadjiev commented 5 months ago

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