Grammalecte  Diff

Differences From Artifact [b8843fe5b2]:

To Artifact [d27d7a87a4]:


85
86
87
88
89
90
91

92
93


94
95
96
97
98
99
100
101
102
103
104
105
106
107

108
109


110
111
112
113
114
115
116
85
86
87
88
89
90
91
92


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109


110
111
112
113
114
115
116
117
118







+
-
-
+
+














+
-
-
+
+








If you don’t want Grammalecte to modify directly the node content, add the property: `data-grammalecte_result_via_event="true"`.

With this property, Grammalecte will send an event to the node each times the text is modified within the panel.
The text can be retrieved with:

    node.addEventListener("GrammalecteResult", function (event) {
        const detail = (typeof(event.detail) === 'string') && JSON.parse(event.detail);
        if (event.detail.sType  &&  event.detail.sType == "text") {
            let sText = event.detail.sText;
        if (detail.sType  &&  detail.sType == "text") {
            let sText = detail.sText;
            ...
        }
    }


### Parse a node and get errors

    oGrammalecteAPI.parseNode("node_id")
    oGrammalecteAPI.parseNode(node)

The node can be a textarea, an editable node or an iframe. The node must have an identifier.
Results (for each paragraph) will be sent in a succession of events at the node.

    node.addEventListener("GrammalecteResult", function (event) {
        const detail = (typeof(event.detail) === 'string') && JSON.parse(event.detail);
        if (event.detail.sType  &&  event.detail.sType == "proofreading") {
            let oResult = event.detail.oResult; // null when the text parsing is finished
        if (detail.sType  &&  detail.sType == "proofreading") {
            let oResult = detail.oResult; // null when the text parsing is finished
            ...
        }
    }

For the last event, `oResult` will be `null`.


125
126
127
128
129
130
131

132
133
134



135
136
137
127
128
129
130
131
132
133
134



135
136
137
138
139
140







+
-
-
-
+
+
+



- destination: node_id (string)

- request_identifier: a custom identifier (string) [default = ""]

Suggestions will be sent within an event at the node identified by `destination`.

    node.addEventListener("GrammalecteResult", function (event) {
        const detail = (typeof(event.detail) === 'string') && JSON.parse(event.detail);
        if (event.detail.sType  &&  event.detail.sType == "spellsugg") {
            let oResult = event.detail.oResult;
            let oInfo = event.detail.oInfo; // object containing the destination and the request_identifier
        if (detail.sType  &&  detail.sType == "spellsugg") {
            let oResult = detail.oResult;
            let oInfo = detail.oInfo; // object containing the destination and the request_identifier
            ...
        }
    }