Implementing tinyMCE html editor in KM

Hi,
We are also implementing tinyMCE html editor in KM Web pae composer using given article.
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/com.sap.km.cm.docs/library/uuid/f04b5c5d-3fd2-2a10-8ab0-8fa90e3ac162
But, we are getting runtime error after deployment.
We are using latest version of tinyMCE.
Has anyone else successfully implemented this? Please provide the information on to resolve this issue.
Please do help me on this.
Thanks and Regards,
Rudradev D

Hi Denis ,
Can you tell me where can i locate the tiny_mce.js file because this file is not a part of the project else it would have appeared in NWDS itself . Also you mentioned about <property name="className" value="yourprojectname.Bootstrap"/> . Here which className are you refering to ?? Is it Bootstrap ? 
After following all the steps mentioned in the article https://www.sdn.sap.com/irj/scn/go/portal/prtroot/com.sap.km.cm.docs/library/uuid/f04b5c5d-3fd2-2a10-8ab0-8fa90e3ac162
i do see a change in the Paragraph editor , but its not like the one shown in the article . If anyone has resolved such an issue then pls  reply .
Regards
Mayank

Similar Messages

  • Help? tinyMCE html editor...

    We have tried incorporating the tinyMCE html editor into the Web Page Composer by following the instructions in this document: [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/library/uuid/f04b5c5d-3fd2-2a10-8ab0-8fa90e3ac162|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.km.cm.docs/library/uuid/f04b5c5d-3fd2-2a10-8ab0-8fa90e3ac162]
    (We put it into the article xml.)
    But when you launch the article editor, it opens but there is an an error in the html editor element that says it is an unknown type.
    Has anyone else successfully implemented this?

    Hi,
    has anybody solved this problem with TinyMCE? I tried to implement this with Portal 7.0 SPS 14 and IE 7.0:
    I want to replace the standdard html editor in the Web Page Composer with the tinyMCE. When I launch the editor, for example by creating a new paragraph, I see the TinyMCE UI in the popup window but I can't access the functionality. A Javascript Error is also appearing : Access denied... So I tried to locate the error. I copied the source text of the popup window and created a new html file in km-content with the source code. When I am deleting the function call
    EPCM.relaxDocumentDomain
    everything works fine. So I tried to implement the following code into the function
    relaxDocumentDomain
    EPCM.relaxDocumentDomain = function(){
    try {
      if(noDomainRelaxation == 'true') {
          //Don't Relax the domain
    } catch(err)
      var newDomain = this.getRelaxedDomain();
        if( newDomain != document.domain ){
          document.domain = newDomain;
        this.calculateDynamicTop();
    and changed the following code in the tiny_mce.js from
    document . write ( ' < script id=__ie_onload defer src=\ ' java script : " " \ ' ; > < \ / script > ' );
    to
    document . write( '< script id=__ie_onload defer src= \ 'java script :" " \ ' ;> no Domain Relaxation = true < \ / script>');
    But that does not work, because the the variable noDomainRelaxation is declared after the check in the relaxDocumentDomain function. Does anybody have an idea how to solve this problem? Is it perhaps possible to set the right document domain in the tinymce itself? Thanks.
    Edited by: Pascal Schrack on Sep 18, 2008 2:43 PM

  • Implementing HTML Editor in Dynpro

    Hi,
      How to implement the HTML Editor in Dynpro ?
    Regards
    Prasath

    Check the following threads it clearly explained for ur question,it will be very usefull
    HTML Editor in WebDynpro
    Is there a way to embed an html editor in a webdynpro application?
    Re: Rich Text editor in Webdynpro
    it's possible
    u do this way
    Give the source of text edit as context variable of binary type
    In the DoInit() method write the code
    IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute("Data");
    type = attr.getModifiableSimpleType();
    ISimpleTypeModifiable type;
    defined as a global variable. and u Insert a Iframe and set the source as a context variable Source (String type). andInsert a button with text as Display and create an action as OnActionDisplay(). In that action write the code
    wdContext.currentContextElement.setSource(type.format(wdContext.currentContextElement().getData()));
    u see this thread also, this is helpful to u
    Re: WebDynPro and HTML...
    Check the following link for help
    HTML Editor in WebDynpro
    I would sujjest you to go for JSPDYN Pages where in you have been provided with HTML editor.
    Please check my Blog below for more information
    /people/anil.dichpally/blog/2007/04/25/jsp-dyn-pages-with-an-example
    Using a Iframe UI u can give the source as the path to this html file(the javascript code). But everytime a event occurs the content i the IFrame UI gets refreshed.
    If u have to just display a content in Iframe UI its fine. If u r planning to navigate inside it ..it wont work out .
    You can fire a exit plug to the javscript code if its the last step in ur application or u can fork a process and create a external window with this url.
    Please give me reward points...

  • Html Editor in C# Windows Application

    Hello,
    I am using WebBrowser Control in C# Windows Application,when I change the language from English to Japanese or Chinese,I am unable to type desired language text inside it.
    At the same time when I typed text in our forum text editor I am able to type desired text.
    My aim is to provide same functionality in my windows application html editor.

    Hi Nikhil,
    >> when I change the language from English to Japanese or Chinese,I am unable to type desired language text inside it.
    What do you by “language from English to Japanese or Chinese” and “type desired language text inside it”? Was the language you changed the winfrom language or the system language? Where did you type the text and could you share us a screen shot about this?
    >> My aim is to provide same functionality in my windows application html editor.
    Do you mean you want to create an html editor in your form? If so, I think the link below might be useful to you:
    # tinyMCE HTML Editor in .NET WindowsForms
    http://www.codeproject.com/Articles/27586/tinyMCE-HTML-Editor-in-NET-WindowsForms
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Who can help me with replacing the standard HTML editor in WPC?

    Hi all,
    We have chosen to replace the standard HTML Editor in the Web Page Composer by the TinyMCE Editor. I have worked my way through the document written by Boris Magocsi (https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f04b5c5d-3fd2-2a10-8ab0-8fa90e3ac162) and the TinyMCE Editor is diplayed when we add or edit a paragraph.
    However, we can not type any text in the input field anymore and we can not click any of the buttons in the TinyMCE editor. Can anybody help a total Javascript newby with fixing this? Full points will be awarded obviuosly. Thanks in advance!
    Best regards,
    Jan
    Note: We are on NW 7.0 SP 15 and the WPC component is not patched yet. We are trying to complete that today and patch it to patch level 1.

    Snippet from the default trace:
    #1.#005056A13EB000880001D90400005EBC000452C3D2595400#1216900908012#com.sap.engine.services.connector.resource.impl.MCEventHandl
    er#sap.com/irj#com.sap.engine.services.connector.resource.impl.MCEventHandler#JALAROS#631##192.168.17.45_POD_3367950#JALAROS#ef
    efb1f0597211ddc652005056a13eb0#SAPEngine_Application_Thread[impl:3]_25##0#0#Debug##Java###>>> com.sap.engine.services.connector
    .resource.impl.MCEventHandler15c015c --> 5(locTrSupp:false).cleanup({0}), shared: {1},  destroyed {2}, invoked from: {3}#4#tru
    e#false#false#java.lang.Exception
            at java.lang.Throwable.<init>(Throwable.java:58)
            at com.sap.engine.services.connector.Log.getStackTrace(Log.java:61)
            at com.sap.engine.services.connector.resource.impl.MCEventHandler.cleanup(MCEventHandler.java:267)
            at com.sap.engine.services.connector.resource.impl.MCEventHandler.connectionClosed(MCEventHandler.java:524)
            at com.sap.engine.services.dbpool.spi.LocalTXManagedConnectionImpl.removeConnectionHandle(LocalTXManagedConnectionImpl.
    java:322)
            at com.sap.engine.services.dbpool.cci.ConnectionHandle.close(ConnectionHandle.java:278)
            at com.sap.netweaver.config.store.CommonJDBCConfigPersistence.getProperty(CommonJDBCConfigPersistence.java:1120)
            at com.sap.netweaver.config.store.ConfigNode.getProperty(ConfigNode.java:61)
            at com.sap.netweaver.portal.prt.config.cmsource.CMStoreSource.getInternalTimestamp(CMStoreSource.java:1111)
            at com.sap.netweaver.portal.prt.config.cmsource.CMStoreSource.shouldRefresh(CMStoreSource.java:997)
            at com.sap.netweaver.portal.prt.config.cmsource.CMStoreSource.refreshObjects(CMStoreSource.java:1187)
            at com.sap.netweaver.portal.prt.config.cmsource.CMStoreSource.getTimeStamp(CMStoreSource.java:1331)
            at com.sapportals.config.fwk.meta.ConfigurableSourceSynchronizer.synchronizeListeners(ConfigurableSourceSynchronizer.ja
    va:124)
            at com.sapportals.config.fwk.data.ConfigPlugin.synchronizeConfigurablesCache(ConfigPlugin.java:1216)
            at com.sapportals.config.fwk.data.ConfigPlugin.getConfigurables(ConfigPlugin.java:362)
            at com.sap.nw.wpc.km.service.editor.EditorService.getStringConfig(EditorService.java:1119)
            at com.sap.nw.wpc.km.service.editor.EditorService.getImageLayoutSet(EditorService.java:1096)
            at com.sap.nw.wpc.km.service.editor.component.ImageSelectComponent.getCompoundComponent(ImageSelectComponent.java:213)
            at com.sap.nw.wpc.km.service.editor.component.ImageSelectComponent.initializeFromPageContext(ImageSelectComponent.java:
    135)
            at com.sap.nw.wpc.km.service.editor.component.EditorComponentFactory.getComponent(EditorComponentFactory.java:69)
            at com.sap.nw.wpc.km.service.editor.document.AbstractEditorObject.getComponent(AbstractEditorObject.java:162)
            at pagelet.editor._sapportalsjsp_editor.subDoContent(_sapportalsjsp_editor.java:1045)
            at pagelet.editor._sapportalsjsp_editor.doContent(_sapportalsjsp_editor.java:58)
            at pagelet.editor._sapportalsjsp_editor.service(_sapportalsjsp_editor.java:38)
            at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:360)
            at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:934)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:435)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:527)
            at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:89)
            at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:232)
            at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
            at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:129)
            at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
            at com.sap.nw.wpc.editor.EditorTool.doContent(EditorTool.java:54)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
            at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
            at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
            at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
            at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:645)
            at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
            at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
            at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
            at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
            at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:524)
            at java.security.AccessController.doPrivileged(AccessController.java:231)
            at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:407)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
            at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
            at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
            at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
            at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
            at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionM
    essageListener.java:33)
            at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
            at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
            at java.security.AccessController.doPrivileged(AccessController.java:207)
            at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)
            at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)
    #1.#005056A13EB000880001D90500005EBC000452C3D25AFC5C#1216900908121#com.sap.engine.services.connector.resource.impl.HandleWrappe
    r#sap.com/irj#com.sap.engine.services.connector.resource.impl.HandleWrapper#JALAROS#631##192.168.17.45_POD_3367950#JALAROS#efef
    b1f0597211ddc652005056a13eb0#SAPEngine_Application_Thread[impl:3]_25##0#0#Debug##Plain###>>> com.sap.engine.services.connector.
    jca.ConnectionManagerImpl3fa63fa6.allocateConnection(mcf: com.sap.engine.services.dbpool.spi.ManagedConnectionFactoryImpla986
    92e1, reqInfo: null)#

  • Run script in HTML editor in WebView WP8.1

    I am developing an app in which I need to give HTML editing facility to the user. So I tried different HTML editors but finally TinyMCE was able to show controls for editing. But I am not able to set the contents of Editor. It gives Exception Exception
    from HRESULT: 0x80020101. And I tried all different solutions but could not figure it out. Here is link to my project
        string tinyMice = "<script type='text/javascript'> function myfun() {tinymce.execCommand('mceInsertContent', false, getQueryStrings());}myfun()</script>";
                        await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(1));
                        await webview_demo.InvokeScriptAsync("eval", new string[] { tinyMice });
    Can somebody help?

    hey,
    I am not sure what you exactly want to do but I took a look at the project you uploaded.
    First of all, you better use the NavigationCompleted or
    FrameNavigationCompleted event for executing onload functions.
    I have no idea about the tinymce js plugin but here is what I did to create a similar scenario.
    1) First, create a js function in the removeformat.html to return a string (replacing your getQueryStrings functions)
    function returnMessageValue() {
    return "Hello JS World";
    2) then create a script notify event handler and wire it up to the page so we can get alerts from the html page loaded.
    In NavigationCompleted event:
    string result = await this.webview_demo.InvokeScriptAsync("eval", new string[] { "window.alert = function (AlertMessage) {window.external.notify(AlertMessage)}" });
    this will notify the webview about window.alert's. So we subscribe to the Script notify event:
    webview_demo.ScriptNotify += (sender, args) =>
    MessageDialog m = new MessageDialog(args.Value);
    m.ShowAsync();
    and finally the code execution for our function:
    await webview_demo.InvokeScriptAsync("eval", new[] { "window.alert(returnMessageValue())" });
    // await webview_demo.InvokeScriptAsync("eval",
    // new[] { "tinymce.execCommand(\"mceInsertContent\", false, getQueryStrings())" });
    result:
    hope it helps
    Can Bilgin
    Blog
    Samples CompuSight

  • How could I edit correctly my bullets in my html editor

    I try to manage bullets in a simple HTML Editor.
    To do that, I used two differents methods but they both failed.
    When I look at the generated source code, my tags correcty exist but in the HTMLDocument, I can't see the text well formatted.
    Is anybody could help me?
    Thanks a lot
    Here is the two methods I chose:
    The first one was:
    MutableAttributeSet attr = new SimpleAttributeSet();
    attr.addAttribute(StyleConstants.NameAttribute, style);
    int xStart = m_HTMLEditor.getSelectionStart();
    int xFinish = m_HTMLEditor.getSelectionEnd();
    m_doc.setParagraphAttributes(xStart, xFinish - xStart, attr, false);
    And the second one was:
    try{
         MutableAttributeSet attr = new SimpleAttributeSet();
         attr.addAttribute(StyleConstants.NameAttribute, HTML.Tag.LI);
         m_doc.insertString(m_HTMLEditor.getSelectionStart(), m_HTMLEditor.getSelectedText(), attr);
    catch(Exception ex) {                         IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "An exception occured during the inserting bullet");
    }

    Hi,
    implementing list formatting for HTMLDocuments is complex. To format an arbirtrary text portion as list, <ul> or <ol> and <li> tags have to be added to respective text.
    As one can not predict if a selected text portion has already list formatting or contains a mixture of list and plain text formatting, there are a lot of cases to implement.
    My proposal is to just copy a working implementation as it is present in application SimplyHTML at http://www.lightdev.com/template.php4?id=3
    Ulrich

  • Xml Form Builder HTML Editor

    Hi All,
    In my xml form builder application, i have to insert an image inside the UI "HTML Editor". But there is no option called as "insert image from km" into the HTML Editor? How can i have that option called "Insert Image From KM" ?
    I tried "configuration of the HTML editor" in
    Knowledge Management  Content Management  Utilities  Editing  HTML Editing.
    I enabled the option "Allow Images". Then too it is not reflecting in HTML Editor UI.
    What else can be done for getting that property on HTML Editor UI?
    Thanx and Regards,
    Divya

    Hi,
    My understanding is that the standard HTML editor control from SAP is quite limited. You can copy and paste an image into it (but the image has to already be in KM) - it has no nice control for selecting or positioning the image....
    Some options:
    1. There are options like TinyMCE which I belive can be used in place of the standard HTML editor control.
    2. If the structure of the content on you page is fixed then you could add images into the form as images that the user would provide links for - but this is not as free form as you would maybe like.
    Hope this helps,
    Simon

  • Embeded html editor

    Hello there:
    In my project I wanted to add rich text support for the editor thus I used DefaultStyledDocument. It works fine, as it supports Bold/Italic/underline, foreground/background, etc, and I can save the data as the binary files. However, I was impressed by the online html editor like this: http://www.interspire.com/devedit/
    I think Swing should be able to implement something like this. I don't really want my users able to access the html code, I just want my application to provide a WYSIWYG environment and the app is going to save the data as HTML files in the background.
    I noticed there is a class extending DefaultStyledDocument, HTMLDocument, I am not sure if this class can help me reach my goal.
    Any suggestions? Or link to some sample code?
    Thanks a lot,
    Sway

    Benjamin wrote:
    > Hi,
    > I found in page http://wiki.eclipse.org/index.php/ATF/JSDT, it says there
    > will be translator interface in wtp3.1 for embedded javascript editor to
    > other languages, does the translator interface ready in wtp 3.1?
    Hi Benjamin,
    I believe the translator interface being talked about is IJsTranslation.
    That may be a good place to start looking. It can be found in
    org.eclipse.wst.jsdt.web.core.
    The main JSDT specific extension point you'll probably use is:
    org.eclipse.wst.jsdt.web.core.javascriptPreProcessor - where you specify
    your translator.
    Take a look in org.eclipse.wst.jsdt.web.core and
    org.eclipse.wst.jsdt.web.ui to see how JSDT support gets added to the HTML
    and JSP editors.
    Thanks,
    Chris

  • APEX Supplied HTML Editor (fckeditor) - Limit number of characters

    Hi
    Has anyone found a way of limiting the number of characters allowed in the HTML Editor that is supplied with APEX (3.1/fckeditor)
    I have had a look at the fckeditor web page and found a couple of plugins but I fear that this approach will require me to manually implement fckeditor, and not use the inbuilt one.
    I would also prefer to not do this with an application process as the user can overflow the editor and get the HTTP-400 Value param too long error.
    Regards
    Matt

    Dribble!
    does this help? Is their anyway to limit the character count on a textarea with html editor

  • Creating a PHP/HTML Editor

    I'm doing a school project on a PHP/HTML Editor.
    I'm looking for some help on finding a good tutorial on changing properties to a JEditorPane. I want to set up the indent size, colors for tags, comments, statements, etc...
    anyone help??

    Here, I stole this code from the advanced forum on Saturday and tried to develop it, though gave up when I couldn't get setTabs or load file to work and tooltips was too damn slow.
    I had an idea that I could use it to run javac and to execute Frames and Applets with it ... right now I'm reconfiguring the design and thinking about dropping the highlighter altogether, but thats my story. Still it may be useful /may give you ideas /may be just the base or platform you're looking for.import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.io.*;
    class Highlighter extends DefaultStyledDocument{
         private DefaultStyledDocument doc;
         private Element rootElement;
         private boolean multiLineComment;
         private MutableAttributeSet normal;
         private MutableAttributeSet keyword;
         private MutableAttributeSet comment;
         private MutableAttributeSet quote;
         private MutableAttributeSet tabSpace;
         private Hashtable keywords;
    public Highlighter(){
           doc = this;
         rootElement = doc.getDefaultRootElement();
         putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n" );
         normal = new SimpleAttributeSet();
         StyleConstants.setForeground(normal, Color.black);
         comment = new SimpleAttributeSet();
         StyleConstants.setForeground(comment, Color.green);
         StyleConstants.setItalic(comment, true);
         keyword = new SimpleAttributeSet();
         StyleConstants.setForeground(keyword, Color.blue);
         quote = new SimpleAttributeSet();
         StyleConstants.setForeground(quote, Color.red);
         Object dummyObject = new Object();
         keywords = new Hashtable();
         keywords.put( "abstract", dummyObject );
         keywords.put( "boolean", dummyObject );
         keywords.put( "break", dummyObject );
         keywords.put( "byte", dummyObject );
         keywords.put( "byvalue", dummyObject );
         keywords.put( "case", dummyObject );
         keywords.put( "cast", dummyObject );
         keywords.put( "catch", dummyObject );
         keywords.put( "char", dummyObject );
         keywords.put( "class", dummyObject );
         keywords.put( "continue", dummyObject );
         keywords.put( "default", dummyObject );
         keywords.put( "do", dummyObject );
         keywords.put( "double", dummyObject );
         keywords.put( "else", dummyObject );
         keywords.put( "extends", dummyObject );
         keywords.put( "false", dummyObject );
         keywords.put( "final", dummyObject );
         keywords.put( "finally", dummyObject );
         keywords.put( "float", dummyObject );
         keywords.put( "for", dummyObject );
         keywords.put( "if", dummyObject );
         keywords.put( "implements", dummyObject );
         keywords.put( "import", dummyObject );
         keywords.put( "instanceof", dummyObject );
         keywords.put( "int", dummyObject );
         keywords.put( "interface", dummyObject );
         keywords.put( "long", dummyObject );
         keywords.put( "new", dummyObject );
         keywords.put( "null", dummyObject );
         keywords.put( "package", dummyObject );
         keywords.put( "private", dummyObject );
         keywords.put( "protected", dummyObject );
         keywords.put( "public", dummyObject );
         keywords.put( "return", dummyObject );
         keywords.put( "short", dummyObject );
         keywords.put( "static", dummyObject );
         keywords.put( "super", dummyObject );
         keywords.put( "switch", dummyObject );
         keywords.put( "synchronized", dummyObject );
         keywords.put( "this", dummyObject );
         keywords.put( "throw", dummyObject );
         keywords.put( "throws", dummyObject );
         keywords.put( "transient", dummyObject );
         keywords.put( "true", dummyObject );
         keywords.put( "try", dummyObject );
         keywords.put( "void", dummyObject );
         keywords.put( "volatile", dummyObject );
         keywords.put( "while", dummyObject );
    * Override to apply syntax highlighting after the document has been updated
       public void insertString(int offset, String str, AttributeSet a)
                                            throws BadLocationException{
              if (str.equals("{"))
              str = addMatchingBrace(offset);
              super.insertString(offset, str, a);
              processChangedLines(offset, str.length());
    * Override to apply syntax highlighting after the document has been updated
       public void remove(int offset, int length) throws BadLocationException{
              super.remove(offset, length);
              processChangedLines(offset, 0);
    * Determine how many lines have been changed,
    * then apply highlighting to each line
       private void processChangedLines(int offset, int length)
                                    throws BadLocationException {
              String content = doc.getText(0, doc.getLength());
              // The lines affected by the latest document update
              int startLine = rootElement.getElementIndex( offset );
              int endLine = rootElement.getElementIndex( offset + length );
              // Make sure all comment lines prior to the start line are commented
              // and determine if the start line is still in a multi line comment
              setMultiLineComment( commentLinesBefore( content, startLine ) );
              // Do the actual highlighting
                   for (int i = startLine; i <= endLine; i++){
                        applyHighlighting(content, i);
          // Resolve highlighting to the next end multi line delimiter
              if (isMultiLineComment())commentLinesAfter(content, endLine);
              else highlightLinesAfter(content, endLine);
    * Highlight lines when a multi line comment is still 'open'
    * (ie. matching end delimiter has not yet been encountered)
         private boolean commentLinesBefore(String content, int line){
              int offset = rootElement.getElement( line ).getStartOffset();
              // Start of comment not found, nothing to do
              int startDelimiter = lastIndexOf( content, getStartDelimiter(), offset-2);
              if (startDelimiter < 0)return false;
              // Matching start/end of comment found, nothing to do
              int endDelimiter = indexOf( content, getEndDelimiter(), startDelimiter );
              if (endDelimiter < offset & endDelimiter != -1)return false;
              // End of comment not found, highlight the lines
              doc.setCharacterAttributes(startDelimiter, offset - startDelimiter + 1, comment, false);
              return true;
    * Highlight comment lines to matching end delimiter
         private void commentLinesAfter(String content, int line){
              int offset = rootElement.getElement( line ).getEndOffset();
              // End of comment not found, nothing to do
              int endDelimiter = indexOf( content, getEndDelimiter(), offset );
              if (endDelimiter < 0) return;
              // Matching start/end of comment found, comment the lines
              int startDelimiter = lastIndexOf( content, getStartDelimiter(), endDelimiter );
                   if (startDelimiter < 0 || startDelimiter <= offset){
                        doc.setCharacterAttributes(offset, endDelimiter - offset + 1, comment, false);
    * Highlight lines to start or end delimiter
         private void highlightLinesAfter(String content, int line)
                                                                throws BadLocationException{
              int offset = rootElement.getElement( line ).getEndOffset();
              // Start/End delimiter not found, nothing to do
              int startDelimiter = indexOf( content, getStartDelimiter(), offset );
              int endDelimiter = indexOf( content, getEndDelimiter(), offset );
              if (startDelimiter < 0)     startDelimiter = content.length();
              if (endDelimiter < 0)endDelimiter = content.length();
              int delimiter = Math.min(startDelimiter, endDelimiter);
              if (delimiter < offset)return;
              // Start/End delimiter found, reapply highlighting
              int endLine = rootElement.getElementIndex( delimiter );
                   for (int i = line + 1; i < endLine; i++){
                        Element branch = rootElement.getElement( i );
                        Element leaf = doc.getCharacterElement( branch.getStartOffset() );
                        AttributeSet as = leaf.getAttributes();
                        if ( as.isEqual(comment) )applyHighlighting(content, i);
    * Parse the line to determine the appropriate highlighting
         private void applyHighlighting(String content, int line)
                                                             throws BadLocationException{
              int startOffset = rootElement.getElement( line ).getStartOffset();
              int endOffset = rootElement.getElement( line ).getEndOffset() - 1;
              int lineLength = endOffset - startOffset;
              int contentLength = content.length();
                   if (endOffset >= contentLength)endOffset = contentLength - 1;
              // check for multi line comments
              // (always set the comment attribute for the entire line)
                 if (endingMultiLineComment(content, startOffset, endOffset)
                ||isMultiLineComment()||startingMultiLineComment(content, startOffset, endOffset)){
                         doc.setCharacterAttributes(startOffset, endOffset - startOffset + 1, comment, false);
                         return;
              // set normal attributes for the line
              doc.setCharacterAttributes(startOffset, lineLength, normal, true);
              // check for single line comment
              int index = content.indexOf(getSingleLineDelimiter(), startOffset);
                   if ( (index > -1) && (index < endOffset) ){
                        doc.setCharacterAttributes(index, endOffset - index + 1, comment, false);
                        endOffset = index - 1;
              // check for tokens
              checkForTokens(content, startOffset, endOffset);
    * Does this line contain the start delimiter
         private boolean startingMultiLineComment(String content, int startOffset, int endOffset)
                                                                                                              throws BadLocationException{
              int index = indexOf( content, getStartDelimiter(), startOffset );
                   if ( (index < 0) || (index > endOffset) )return false;
                   else{
                        setMultiLineComment( true );
                        return true;
    * Does this line contain the end delimiter
         private boolean endingMultiLineComment(String content, int startOffset, int endOffset)
                                                                                                             throws BadLocationException{
              int index = indexOf( content, getEndDelimiter(), startOffset );
                   if ( (index < 0) || (index > endOffset) )return false;
                   else{
                        setMultiLineComment( false );
                        return true;
    * We have found a start delimiter
    * and are still searching for the end delimiter
         private boolean isMultiLineComment(){
              return multiLineComment;
         private void setMultiLineComment(boolean value){
              multiLineComment = value;
    * Parse the line for tokens to highlight
         private void checkForTokens(String content, int startOffset, int endOffset){
              while (startOffset <= endOffset){
              // skip the delimiters to find the start of a new token
                   while (isDelimiter(content.substring(startOffset, startOffset+1))){
                        if (startOffset < endOffset)startOffset++;
                        else return;
              // Extract and process the entire token
              if (isQuoteDelimiter( content.substring(startOffset, startOffset + 1)))
                   startOffset = getQuoteToken(content, startOffset, endOffset);
              else startOffset = getOtherToken(content, startOffset, endOffset);
         private int getQuoteToken(String content, int startOffset, int endOffset){
              String quoteDelimiter = content.substring(startOffset, startOffset + 1);
              String escapeString = getEscapeString(quoteDelimiter);
              int index;
              int endOfQuote = startOffset;
              // skip over the escape quotes in this quote
              index = content.indexOf(escapeString, endOfQuote + 1);
                   while ( (index > -1) && (index < endOffset) ){
                        endOfQuote = index + 1;
                        index = content.indexOf(escapeString, endOfQuote);
              // now find the matching delimiter
              index = content.indexOf(quoteDelimiter, endOfQuote + 1);
                   if ( (index < 0) || (index > endOffset) )endOfQuote = endOffset;
                   else endOfQuote = index;
              doc.setCharacterAttributes(startOffset, endOfQuote-startOffset+1, quote, false);
         return endOfQuote + 1;
         private int getOtherToken(String content, int startOffset, int endOffset){
              int endOfToken = startOffset + 1;
              while (endOfToken <= endOffset ){
                   if (isDelimiter(content.substring(endOfToken, endOfToken+1)))break;
                   endOfToken++;
              String token = content.substring(startOffset, endOfToken);
                   if ( isKeyword( token ) )
                        doc.setCharacterAttributes(startOffset, endOfToken-startOffset, keyword, false);
              return endOfToken + 1;
    * Assume the needle will the found at the start/end of the line
         private int indexOf(String content, String needle, int offset){
              int index;
                   while ( (index = content.indexOf(needle, offset)) != -1 ){
                        String text = getLine( content, index ).trim();
                             if (text.startsWith(needle) || text.endsWith(needle))break;
                             else offset = index + 1;
              return index;
    * Assume the needle will the found at the start/end of the line
         private int lastIndexOf(String content, String needle, int offset){
              int index;
              while ( (index = content.lastIndexOf(needle, offset)) != -1 ){
                   String text = getLine( content, index ).trim();
                        if (text.startsWith(needle) || text.endsWith(needle))break;
                        else offset = index - 1;
              return index;
         private String getLine(String content, int offset){
              int line = rootElement.getElementIndex( offset );
              Element lineElement = rootElement.getElement( line );
              int start = lineElement.getStartOffset();
              int end = lineElement.getEndOffset();
              return content.substring(start, end - 1);
    * Override for other languages
         protected boolean isDelimiter(String character){
              String operands = ";:{}()[]+-/%<=>!&|^~*";
                   if (Character.isWhitespace( character.charAt(0) ) ||
                                            operands.indexOf(character)!= -1 ) return true;
                   else return false;
    * Override for other languages
         protected boolean isQuoteDelimiter(String character){
              String quoteDelimiters = "\"'";
                   if (quoteDelimiters.indexOf(character) < 0) return false;
                   else return true;
    * Override for other languages
         protected boolean isKeyword(String token){
              Object o = keywords.get( token );
              return o == null ? false : true;
    * Override for other languages
         protected String getStartDelimiter(){
              return "/*";
    * Override for other languages
         protected String getEndDelimiter(){
              return "*/";
    * Override for other languages
         protected String getSingleLineDelimiter(){
              return "//";
    * Override for other languages
         protected String getEscapeString(String quoteDelimiter){
              return "\\" + quoteDelimiter;
         protected String addMatchingBrace(int offset) throws BadLocationException{
              StringBuffer whiteSpace = new StringBuffer();
              int line = rootElement.getElementIndex( offset );
              int i = rootElement.getElement(line).getStartOffset();
                   while (true){
                        String temp = doc.getText(i, 1);
                             if (temp.equals(" ") || temp.equals("\t")){
                                  whiteSpace.append(temp);
                                i++;
                             else break;
              return "{\n" + whiteSpace.toString() + "\t\n" + whiteSpace.toString() + "}";
    public class MyJavac extends JFrame implements ActionListener{
       JPanel top, main;
         JEditorPane edit = new JEditorPane();
       Highlighter syntax = new Highlighter();
       JButton []buts = new JButton[7];
       String theText="";
    public MyJavac(){
       super("Java Based Text Editor");
       getContentPane().setLayout(new BorderLayout() );
       String []str = {"New","Open","Save","Save As","Compile","J/Frame","Applet"};
       String []tooltips = {"<html><center>Open a new <br>java file</center></html>",
                            "<html><center>Open an existing<br>java file</center></html>",
                            "<html><center>Save java<br>file</center></html>",
                            "<html><center>Save java file<br>with new filename</center></html>",
                            "<html><center>Run the javac<br>DOS compiler</center></html>",
                            "<html><center>Run java JFrame<br>or Frame application</center></html>",
                            "<html><center>Run java Applet<br>html application</center></html>"};
       top = new JPanel();
       top.setLayout(new GridLayout(1,7,5,0) );
       JPanel east = new JPanel();
       JPanel west = new JPanel();
          for(int i=0; i<buts.length; i++){
             buts[i] = new JButton(str);
    buts[i].setToolTipText(tooltips[i]);
    buts[i].addActionListener(this);
    top.add(buts[i]);
    main = new JPanel();
    main.setLayout(new GridLayout(1,1) );
         edit.setEditorKit(new StyledEditorKit());
         edit.setDocument(syntax);
         JScrollPane scroll=new JScrollPane(edit);
    main.add(scroll);
    getContentPane().add("North",top);
    getContentPane().add("Center",main);
    public void actionPerformed(ActionEvent e){
    String option = e.getActionCommand();
    if(option.equals("New")){}
    if(option.equals("Open")) {
    JFileChooser chooser = new JFileChooser();
    int returnVal = chooser.showOpenDialog(this);
    if(returnVal == JFileChooser.APPROVE_OPTION);
    try {
    getFromFile();
    catch(Exception f){
    String error1= "Error opening the file ";
    String error2 = "or the file was not found";
    JOptionPane.showMessageDialog(null, error1 +"\n" + error2);
    edit.setText(theText);
    public void getFromFile() throws Exception{
    int reader = 0;
    theText = "";
    FileReader in = new FileReader("junk.txt");
    do {
    reader = in.read();
    theText += (char)reader;
    } while (reader != -1);
    in.close();
    public static void main(String args[]){
    MyJavac jav = new MyJavac();
         Image onFrame = Toolkit.getDefaultToolkit().getImage("flag.gif") ;
    jav.setIconImage(onFrame);
         jav.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         jav.setSize(600,400);
         jav.setVisible(true);

  • Simple applet html editor

    Hi,
    I need a simple applet html editor.
    Does anyone has implemented one?
    The functions I need is bold, italic, insert table, insert image, and all basic functions of an editor
    I need some source, because I dont want to make it from scratch
    Thanks

    Using the search feature of this site, I found:
    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A57&qt=html+editor
    ;o)
    V.V.

  • Help implementing a WYSIWYG editor

    I am looking for any literature that describes how to implement a WYSIWYG word processor or HTML editor
    (without using a pre-built editor component like JEditorPane).
    I am already familiar with the Model-View-Controller design pattern and the gap-buffer data structure from Gnu-Emacs.
    The best papers and books I have found so far are:
    "The object-oriented implementation of a document editor" by P. Calder & M. Linton
    "Glyphs: Flyweight objects for user interfaces" by P. Calder & M. Linton
    Chapter 2 of "Design Patterns" by Gamma, Helm, Johnson & Vlissides
    ...I would like to find more papers or books like these.

    I can't think of one possible reason to re-invent a WYSIWYG text editor, which is why I have no information for you. I imagine its the same for most or all of the others out there

  • Textarea with HTML editor is not working

    Hi all,
    This is producing me a real headache.
    I created the simplest application in the world with one Textarea with HTML editor, and the editor control does not show the usual tool bar for fonts, color, alignment, etc. Just a ordinary textarea.
    Moreover, this was working before... I moved to another location in my work (me, not the server). Yes, I thought about the Internet Explorer, but Firefox has the same issue.
    So any idea I can try to make this work?
    I have another applications already in production with the same issue.
    Need help!!!!!!!!!
    Thanks in advance.
    Lukas.
    Application Express 2.1.0.00.39
    Oracle Database 10g Express Edition Release 10.2.0.1.0
    Internet Explorer 7.0.5730.11
    Firefox 1.5.0.11
    Windows XP Service Pack 2
    1 G Ram
    Pentium D CPU 2.80GHz

    Lukas,
    I would go and integrate FCKEDITOR (http://www.fckeditor.net/ ) into your application.
    Here are instructions on how to achieve this (sorry but only in German):
    http://www.oracle.com/global/de/community/tipps/einbinden_fckeditor/index.html
    It basically means:
    1) copying the files from fckeditor under the /images directory
    (you can use the instructions here: http://daust.blogspot.com/2006/03/where-are-images-of-application.html)
    2) creating two shortcuts INCLUDE_EDITOR_SCRIPTS and EDITOR
    3) placing the shortcut INCLUDE_EDITOR_SCRIPTS into the page html header and
    4) placing the shortcut EDITOR into the post element text of your plain textarea element
    That's it.
    BTW, FCKEDITOR has been included in Apex 3.0 as a standard item type.
    Regards,
    ~Dietmar.

  • Creating a small HTML-Editor using JEditorPane

    Hello! I'm trying to create a small HTML-Editor. Via this editor users shall be capable to create formatted text (bold, italic, underlined, different sizes, different fonts, different colors). Furthermore, if the user pushes the enter-button a new line-break (<br>) shall be inserted. Basically my editor is working but with some big problems:
    1. When I create an instance of my editor, I initialize it with some html-code.
    this.m_EditorPane.setText("<html><head></head><body></body></html>"); Without this initialization between the <body> and </body> <p> and </p> will be inserted, what I don't want. But if I push now the enter-button at the beginning, <br>-tag will not be inserted in the <body>-area but in the <head>-area.
    2. Styling text is working really good, but when I insert a line-break (via enter-button), the <br>-tag is inserted after the (e.g.) closing bold-tag (</b>). So, in the next line, this style-property must be reselected.
    Can anybody help me to change this behavior?
    Kind regards, Stefan
    P.S. The way I insert the <br>-tag:
    JEditorPane editor = getEditor(ae);
    HTMLDocument doc = getHTMLDocument(editor);
    HTMLEditorKit kit = getHTMLEditorKit(editor);
    editor.replaceSelection("");
    int offset = editor.getCaretPosition();
    kit.insertHTML(doc, offset, "<br>", 0, 0, HTML.Tag.BR);
    editor.getCaret().setDot(editor.getCaretPosition());P.P.S. Sorry for my bad english :-/

    Hello! I'm trying to create a small HTML-Editor. Via this editor users shall be capable to create formatted text (bold, italic, underlined, different sizes, different fonts, different colors). Furthermore, if the user pushes the enter-button a new line-break (<br>) shall be inserted. Basically my editor is working but with some big problems:
    1. When I create an instance of my editor, I initialize it with some html-code.
    this.m_EditorPane.setText("<html><head></head><body></body></html>"); Without this initialization between the <body> and </body> <p> and </p> will be inserted, what I don't want. But if I push now the enter-button at the beginning, <br>-tag will not be inserted in the <body>-area but in the <head>-area.
    2. Styling text is working really good, but when I insert a line-break (via enter-button), the <br>-tag is inserted after the (e.g.) closing bold-tag (</b>). So, in the next line, this style-property must be reselected.
    Can anybody help me to change this behavior?
    Kind regards, Stefan
    P.S. The way I insert the <br>-tag:
    JEditorPane editor = getEditor(ae);
    HTMLDocument doc = getHTMLDocument(editor);
    HTMLEditorKit kit = getHTMLEditorKit(editor);
    editor.replaceSelection("");
    int offset = editor.getCaretPosition();
    kit.insertHTML(doc, offset, "<br>", 0, 0, HTML.Tag.BR);
    editor.getCaret().setDot(editor.getCaretPosition());P.P.S. Sorry for my bad english :-/

Maybe you are looking for