Overview
Comment: | [doc] Web API update |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | doc |
Files: | files | file ages | folders |
SHA3-256: |
960b24f7ac47ebcaa5a050e092ca3ab1 |
User & Date: | olr on 2020-03-19 08:06:29 |
Other Links: | manifest | tags |
Context
2020-03-19
| ||
08:10 | [doc] Web API update check-in: 6cd37e7067 user: olr tags: trunk, doc | |
08:06 | [doc] Web API update check-in: 960b24f7ac user: olr tags: trunk, doc | |
2020-03-18
| ||
23:54 | [fr] ajustements check-in: 08d9c6d5ad user: olr tags: trunk, fr | |
Changes
Modified doc/API_web.md from [1cf8573643] to [40448ef602].
1 2 3 4 | # API for the web If Grammalecte is installed by the user on his browser (like Firefox or Chrome), you can call several functions for a better integration of grammar checking for your website. This is mostly usefull | > > > > | > > > > > > > > > > > > > > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # API for the web ## Using the Grammalecte API for the web **With Grammalecte 1.8+.** If Grammalecte is installed by the user on his browser (like Firefox or Chrome), you can call several functions for a better integration of grammar checking for your website. This is mostly usefull if you use non-standard textareas. You can: - disable the Grammalecte button (spinning pearl), - launch the Grammalecte panel with custom button (or when you think it’s necessary), - get the modified text via events (instead of having the node content directly modified), - get raw results (list of errors) of grammar checking and spell checking, - get spelling suggestions for a wrong word. ### How it works Usually, webpage scripts can’t call methods or functions of browser extensions. The Grammalecte API is injected within your webpage, with methods launching events that Grammalecte is listening. When Grammalecte receives one of these events, it launches the requested tasks. Results may be sent via events on webpage nodes. ### Detecting if Grammalecte API is here Every call to the Grammalecte API will be done via an object called `oGrammalecteAPI`. if (typeof(oGrammalecteAPI) === "object") { ... } ### Disabling the Grammalecte button (the spinning pearl) By default, Grammalecte inserts a button (a spinning pearl) on each textarea node and editable node (unless the user disabled it). You can tell Grammalete not to create these buttons on your text areas with the property: `data-grammalecte_button="false"`. ### Open the Grammalecte panel for a node If you have disabled the spinning button, you can launch the Grammalecte panel with your custom button. oGrammalecteAPI.openPanelForNode("node_id") oGrammalecteAPI.openPanelForNode(node) The node can be a textarea, an editable node or an iframe. If the node is an iframe, the content won’t be modified by Grammalecte. |
︙ | ︙ | |||
62 63 64 65 66 67 68 | ### 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. | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | ### 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) { if (event.detail.sType && event.detail.sType == "proofreading") { let oResult = event.detail.oResult; // null when the text parsing is finished ... } } |
︙ | ︙ |