Grammalecte  Check-in [887fd87b74]

Overview
Comment:[fx] fix Web API for parseText and openPanelForText
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 887fd87b749aeeabb7ad2a769f32a259d31d4219d073a3a708a1b0fe9237209b
User & Date: olr on 2020-03-22 08:28:46
Other Links: manifest | tags
Context
2020-03-22
08:32
[doc] Web API update check-in: 714cebddcc user: olr tags: trunk, doc
08:28
[fx] fix Web API for parseText and openPanelForText check-in: 887fd87b74 user: olr tags: trunk, fx
07:51
[core] fix generateParagraph when empty text check-in: 2228382a89 user: olr tags: trunk, core
Changes

Modified doc/API_web.md from [a6776ada80] to [9652ecdf27].

105
106
107
108
109
110
111










112
113
114
115
116
117
118
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128







+
+
+
+
+
+
+
+
+
+







        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`.


### Parse text and get errors

    oGrammalecteAPI.parseText(text, "node_id")
    oGrammalecteAPI.parseText(text, node)

The node must have an identifier.
Like with parseNode, results (for each paragraph) will be sent in a succession of events at the node.



### Get spelling suggestions

    oGrammalecteAPI.getSpellingSuggestions(word, destination, request_identifier)

Parameters:

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [c562cfe40e] to [c1b09949c0].

1021
1022
1023
1024
1025
1026
1027
1028
1029

1030
1031
1032
1033
1034

1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049




1050
1051



1021
1022
1023
1024
1025
1026
1027


1028





1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048


1049
1050
1051







-
-
+
-
-
-
-
-
+















+
+
+
+
-
-
+
+
+
        }
    }

    write () {
        if (this.xNode !== null) {
            if (this.bResultInEvent) {
                const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
                if (this.xNode) {
                    this.xNode.dispatchEvent(xEvent);
                this.xNode.dispatchEvent(xEvent);
                }
                else if (this.xResultNode) {
                    this.xResultNode.dispatchEvent(xEvent);
                }
                //console.log("Text sent via an event :", xEvent.detail);
                //console.log("Text to xNode:", xEvent.detail);
            }
            else if (this.bTextArea) {
                this.xNode.value = this.getText();
            }
            else if (this.bIframe) {
                //console.log(this.getText());
            }
            else {
                this.eraseNodeContent();
                this.dParagraph.forEach((val, key) => {
                    this.xNode.appendChild(document.createTextNode(val.normalize("NFC")));
                    this.xNode.appendChild(document.createElement("br"));
                });
            }
        }
        else if (this.xResultNode !== null) {
            const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
            this.xResultNode.dispatchEvent(xEvent);
            //console.log("Text to xResultNode:", xEvent.detail);
    }
}
        }
    }
}