Rich Text Email

Hi there, working on a mini patch to add RichTextEmail.  Basically extending the echopointng.RichTextArea.  

I noticed that you had to reimplement the js files for textAreas to account for cursorupdating.  Which I am working through for the RichTextArea.

Are we using the patched textComponent.js echo2 framework that was put in around June...I think you submitted a patch 3 years ago?

In textArea you used a private static dummy class to instantiate echo2's textComponentPeer then replaced the js file with your own, adjusted version.  

This client-server interaction stuff is still requiring "hard work"  due to my inexperience is there any reason I cant call super() during my RichTextAreaPeer class and then do the replacement.  Given my class will be a direct extension of echopointng.RichTextAreaPeer.    I assumed I would need to implement cursor tracking to allow for macro expansion.  

I am just intending to implement a Rich Text area to use in mail creation dialogs.  I am not coding the entire project specification that includes the templating.

public class RichTextAreaPeer extends echopointng.ui.syncpeer.RichTextAreaPeer {

    public static final Service RICH_TEXT_SERVICE = JavaScriptService.forResource(
            "EPNG.RichTextArea", "/org/openvpms/web/echo/js/rta.js");
    static {
                WebRenderServlet.getServiceRegistry().remove(RICH_TEXT_SERVICE);
        WebRenderServlet.getServiceRegistry().add(RICH_TEXT_SERVICE);
    }

    public RichTextAreaPeer() {
        super();

I have done the BoundRichTextArea and RichTextArea so far, but the Peer class is taking the longest to get the rendering done right.. with styling.

I have added 

 case "set-cursor-position":
                    EPRTA.MessageProcessor.processSetCursorPosition(messagePartElement.childNodes[i]);
                    break;

and

EPRTA.MessageProcessor.processSetCursorPosition = function (setCursorPositionElement) {
    for (var item = setCursorPositionElement.firstChild; item; item = item.nextSibling) {
        var elementId = item.getAttribute("eid");
        var cursorPosition = item.getAttribute("cursorPosition");
        var textComponent = EchoDomPropertyStore.getPropertyValue(elementId, "component");
        var element = document.getElementById(elementId);
        textComponent.setCursorPosition(element, cursorPosition);
    }
},

but my Js is not great  - I had to expand the getComponent function as I wasnt sure it was available in context.

https://github.com/CharltonIT/openvpms-web/pull/6

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Rich Text Email

The modified TextComponent.js is based on that included in the echo-webcontainer-2.1.1.jar.

To use custom javascript for RichTextAreaPeer, you need to:

1. Subclass RichTextArea

2. Subclass RichTextAreaPeer

3. Include a line in openvpms-web-echo/src/main/resources/META-INF/nextapp/echo2/SynchronizePeerBindings.properties that links the new RichTextArea with the new Peer

If memory serves, I couldn't subclass the existing TextComponentPeer as the required methods were private.

With regards to the javascript, try doing a side-by-side diff of the original TextComponent.js code with the new version to determine what is required to support cursor positions. Any cursor positioning support will need to take into account html elements in the text.

Syndicate content