Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate editor at https://github.com/naseer/mermaid-webapp #110

Closed
naseer opened this issue Jan 21, 2015 · 6 comments
Closed

Integrate editor at https://github.com/naseer/mermaid-webapp #110

naseer opened this issue Jan 21, 2015 · 6 comments

Comments

@naseer
Copy link

naseer commented Jan 21, 2015

Creating to address the discussion at #106 to integrate the editor at https://github.com/naseer/mermaid-webapp

@naseer naseer changed the title Integrated editor at https://github.com/naseer/mermaid-webapp Integrate editor at https://github.com/naseer/mermaid-webapp Jan 21, 2015
@knsv
Copy link
Collaborator

knsv commented Jan 25, 2015

@naseer, you should take a look at the new api for validating text. I had this kind of editor in mind when writing it.

Error handling

When the parser encounters invalid syntax the mermaid.parseError function is called. It is possible to override this function in order to handle the error in an application specific way.

Parsing text without rendering

It is also possible to validate the syntax before rendering in order to streamline the user experience. The function mermaid.parse(txt) takes a text string as an argument and returns true if the text is syntactically correct and false if it is not. The parseError function will be called when the parse function returns false.

The code-example below in meta code illustrates how this could work:

mermaid.parseError = function(err,hash){
    displayErrorInGui(err);
};

var textFieldUpdated = function(){
    var textStr = getTextFromFormField('code');

    if(mermaid.parse(textStr)){
        reRender(textStr)
    }
};

bindEventHandler('change', 'code', textFieldUpdated);

@naseer
Copy link
Author

naseer commented Jan 26, 2015

Thanks @knsv, this will help a lot and avoid the need for mermaid.init all the time

@naseer
Copy link
Author

naseer commented Feb 9, 2015

@knsv - is there something to re-render without calling mermaid.init ?

@knsv
Copy link
Collaborator

knsv commented Feb 9, 2015

No I think mermaid.init is the way to go!

naseer added a commit to naseer/mermaid that referenced this issue Feb 9, 2015
naseer added a commit to naseer/mermaid that referenced this issue Feb 9, 2015
@naseer naseer mentioned this issue Feb 9, 2015
@naseer
Copy link
Author

naseer commented Feb 10, 2015

@knsv - can this be closed now?

@knsv
Copy link
Collaborator

knsv commented Feb 15, 2015

Yes! Closing! Thanks!

@knsv knsv closed this as completed Feb 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants