Grammalecte  Diff

Differences From Artifact [d1ea962963]:

To Artifact [8bfc3ad28c]:


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    var eventGrammalecte = new CustomEvent("GrammalecteEvent", { detail: JSON.stringify(dataToSend) });
    document.dispatchEvent(eventGrammalecte);
    return dataToSend.IdAction;
}

// ! Envoie de l'information que l'injection est bien faite ;)
// (peut être lu aussi bien par la page web que le content script)
var customAPILoaded = new CustomEvent("GrammalecteIsLoaded");
document.dispatchEvent(customAPILoaded);

// Gros Hack : Auto add a button in tinymce ;)

// Page to test v4 https://www.quackit.com/html/html_editors/tinymce_editor.cfm
// https://www.responsivefilemanager.com/demo.php








|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    var eventGrammalecte = new CustomEvent("GrammalecteEvent", { detail: JSON.stringify(dataToSend) });
    document.dispatchEvent(eventGrammalecte);
    return dataToSend.IdAction;
}

// ! Envoie de l'information que l'injection est bien faite ;)
// (peut être lu aussi bien par la page web que le content script)
var customAPILoaded = new CustomEvent("GLInjectedScriptIsReady");
document.dispatchEvent(customAPILoaded);

// Gros Hack : Auto add a button in tinymce ;)

// Page to test v4 https://www.quackit.com/html/html_editors/tinymce_editor.cfm
// https://www.responsivefilemanager.com/demo.php

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
            let iframeElement;
            if (typeof xEditorAdd.iframeElement !== "undefined" && typeof xEditorAdd.iframeElement.id !== "undefined") {
                iframeElement = xEditorAdd.iframeElement.id;
            } else if (typeof xEditorAdd.editorId !== "undefined") {
                iframeElement = xEditorAdd.editorId + "_ifr";
            }

            sendToGrammalecte({ spellcheck: sText, iframe: iframeElement });
        }
    });
}

function TinyInPage() {
    for (var i = tinyMCE.editors.length - 1; i > -1; i--) {
        let idTiny = tinyMCE.editors[i].id;







|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
            let iframeElement;
            if (typeof xEditorAdd.iframeElement !== "undefined" && typeof xEditorAdd.iframeElement.id !== "undefined") {
                iframeElement = xEditorAdd.iframeElement.id;
            } else if (typeof xEditorAdd.editorId !== "undefined") {
                iframeElement = xEditorAdd.editorId + "_ifr";
            }

            sendToGrammalecte({ sTextToParse: sText, iframe: iframeElement });
        }
    });
}

function TinyInPage() {
    for (var i = tinyMCE.editors.length - 1; i > -1; i--) {
        let idTiny = tinyMCE.editors[i].id;
147
148
149
150
151
152
153
154


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
    if (tinyMCE.majorVersion >= 4) {
        tinyMCE.on("AddEditor", TinyOnEditor);
    } else if (tinyMCE.majorVersion >= 3) {
        tinyMCE.onAddEditor.add(TinyOnEditor);
    }
    try {
        TinyInPage();
    } catch (error) {}


}

/* // ! In the webpage script :
document.addEventListener('GrammalecteIsLoaded', function() {
    // Le gestionnaire d'évènement est prêt!
    // La page web peut effectuer des actions
    ...
});
...
// Pour demander une correction sur le texte
sendToGrammalecte({"spellcheck": "salut comment ca vaa?"});
// Pour demander une correction sur un élément html
sendToGrammalecte({"spellcheck": true, "elm": elementHTML});
// Pour avoir le lexicographe sur un texte
sendToGrammalecte({"lexique": "salut comment ca vaa?"});
// Pour avoir le lexicographe sur un élément html
sendToGrammalecte({"lexique": true, "elm": elementHTML});
*/







|
>
>



|






|

|

|

|

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
    if (tinyMCE.majorVersion >= 4) {
        tinyMCE.on("AddEditor", TinyOnEditor);
    } else if (tinyMCE.majorVersion >= 3) {
        tinyMCE.onAddEditor.add(TinyOnEditor);
    }
    try {
        TinyInPage();
    } catch (e) {
        console.error(e);
    }
}

/* // ! In the webpage script :
document.addEventListener('GLInjectedScriptIsReady', function() {
    // Le gestionnaire d'évènement est prêt!
    // La page web peut effectuer des actions
    ...
});
...
// Pour demander une correction sur le texte
sendToGrammalecte({"sTextToParse": "salut comment ca vaa?"});
// Pour demander une correction sur un élément html
sendToGrammalecte({"sTextToParse": true, "elm": elementHTML});
// Pour avoir le lexicographe sur un texte
sendToGrammalecte({"sTextForLexicographer": "salut comment ca vaa?"});
// Pour avoir le lexicographe sur un élément html
sendToGrammalecte({"sTextForLexicographer": true, "elm": elementHTML});
*/