Skip to content

[Bug/Doc]: accessing the HTML contentsย #632

@Gouvernathor

Description

@Gouvernathor

What happened?

The documentation doesn't explain how to get the HTML contents of the editor. I am going to list questions that come to mind when reading the documentation, keep in mind that I'm not asking for the answers to be explained to me, I'm saying the answers should be written in the documentation.


Quoting this page :

const html = toHTML(this.jsonDoc); // -> html string

What is this, in that context ? it's not an Editor instance, since the jsonDoc attribute doesn't exist on it (according to TypeScript at least).


I found traces of using [ngModel] in the HTML template, but there's no english explanation of what it does. Quoting this page :

Input can be a prosemirror document object or undefined or null

What is "Input" in that sentence ? It clearly doesn't mean the initial value of the ngModel, since the html value is initialized with an empty string which is neither a document nor undefined nor null.
What does the ngModel attribute do to the html variable ? I see that the onChange method ignores its parameter and resets the html field, isn't that a bug ? If I change the value of the html field of the component, will it update the contents of the editor on the page ?
Nothing on this page is understandable.


According to TypeScript introspection, the Editor class has a valueChanges observable which seems to return a JsonDoc value that I could then convert to HTML using the toHTML function above, but valueChanges is not mentioned in the documentation : is it stable ? Also isn't there a way to skip the Observable and just get the value ?
It also has a view returning an EditorView (whatever that is, not mentioned in the doc), and an update observable returning the same type : is it internal or am I allowed to use it ? And if so, what is an EditorView and what can I do with it ?

Still according to TypeScript, the Editor class has a setContent method, but no getContent method, why ? My use case is a text area in a form, so I would be happy with reading the contents only at form validation and skip the observable.


So many questions which, in my opinion, should be answered by the documentation.

Willing to submit a PR?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions