integration of the ace editor for editable reports

(13 posts) (2 voices)

Tags:

No tags yet.

  1. Mark Tetrode, Member

    We have some reports that contain fields with html, js and css code.
    The report users are capable of editing these fields, but it is difficult to see when errors are made in the html / js / css.
    Is it possible for certain fields to replace the <textarea> with the ace editor as explained here:ACE Editor embedding

  2. myDBR Team, Key Master

    myDBR uses CodeMirror as internal editor, it does not use textarea. CodeMirror is pretty similar to the Ace editor, the differencies are quite minimal.

    When you embed html, js and css into your report code, these are treated as strings by the editor's SQL parser. The same would happen with the Ace editor.

    --
    myDBR Team

  3. Mark Tetrode, Member

    Hi

    Thanks for your answer, codemirror looks very promising, just what I need. However, when I run a report with a MySQL text field it gets translated into a textarea, and lib/external/codemirror/editor.js is not loaded.
    Should I load this myself to enable it?

  4. myDBR Team, Key Master

    Mark,
    no extra steps required. It should work as is.

    If you only get a textarea instead of the correct editor, there is something in the installation which causes this. Possible a permission problem in the web server files.

    Take a look at the web server error logs and your browser error console for possible errors. Editing code is much easier with proper editor ;)

    --
    myDBR Team

  5. Mark Tetrode, Member

    Hi myDBR Team

    I think we are not on the same page. When I edit a report the codemirror editor gets loaded and I can enjoy the benefits of editing with color coding etc.

    But this was not my question. Let me rephrase it.

    We have a system where users can edit parts of their configuration. This consists of three tables. There is a table called config, as follows:

    id name value
    --------------------
    1 size 10

    I have created an editable report where users can edit the value. This works great.

    Then, I have a table called htmlheader and a table called customjs. These two are used in our system to adapt the output on a per user basis.

    In the table htmlheader you will find records such as:

    id content
    -------------------
    1 <h1>Header</h1>

    In customjs you will find

    id js
    ----------------------------------
    1 alert("custom js is running");

    I have created editable reports to allow my users adapt their html header and custom javascript, which works (technically speaking) but they very frequently make errors in the html (missing a closing </h1>) or js (missing a closing ") and I have to intervene and solve their issue.

    So what I would like is to re-use the codemirror (or ace or any other) to give them assistance and show the html and js in a color coded way so that less errors are made.

    Can you assist me in that?

    Thanks!

  6. myDBR Team, Key Master

    Mark,
    a misunderstanding. Thought you were talking about the SQL Editor within the myDBR not the in-cell editing.

    There is not yet inline formatted text (HTML/CSS/JavsScript/Markdown) editing capability. It is in the wishlist so we will try to incorporate it at some point, but as said, at this point it is not there yet.

    --
    myDBR Team

  7. Mark Tetrode, Member

    Hi

    Thanks for your clarification. Any idea when this is on the roadmap? Any idea how I can solve this in another way?

    Thanks

    Mark

  8. myDBR Team, Key Master

    No specific timetable for this.

    For now what you could do is to create a myDBR extension which would use the included CodeMirror editor.

    --
    myDBR Team

  9. Mark Tetrode, Member

    Hi

    I successfully managed to install the Dummy extension and understands how this works.
    Could you please give me a hint with the following:

    • enable an extension so that it gets called when editing a table row / field and passing the field value to the extension
    • getting the result of the edit back and update the database with it

    I have decided to also use the codemirror to remain compatible with MyDBR. I will gladly share my code with you once it is finished.

    Thanks

    Mark

  10. myDBR Team, Key Master

    Mark,
    we've added support for HTML editing in the dbr.editable. To enable this feature now, run the updater to get the latest build and add following line to user/defaults.php.

    $mydbr_defaults['include_code_editing'] = true;

    To use the feature in dbr.editable, set the type-parameter to 'htmlmixed'.

    Example:

    select 'dbr.editable', 'html', 'sp_DBR_edit_code', 'in_id=id', 'type=htmlmixed';
    select 'dbr.colstyle', 'html', '[white-space:pre;font-family:Courier]'; select id, html
    from code_editing;

    --
    myDBR Team

  11. Mark Tetrode, Member

    Wonderful, works like a charm! Thank you very much for making this.

    Question: is there any other type than htmlmixed? I see that html and javascript work good, is there a type= for css, for other languages that codemirror supports (e.g. SQL and php)?

    Thanks!

  12. myDBR Team, Key Master

    For now the editing is for htmlmixed i.e HTML with CSS ja JavaScript when put in the respective tags. We'll add the rest (pure JavaScript and CSS, SQL and PHP) into later versions.

    --
    myDBR Team.

  13. Mark Tetrode, Member

    OK, thanks again for putting this in so quickly.


Reply

You must log in to post.