etherpad-lite
etherpad-lite copied to clipboard
Unable to understand the workflow of adding a plugin
So I'm trying to build a custom spellcheck plugin using a ML API, and I'm referring the current spellcheck plugin but I'm unable to understand how exactly it works
'use strict';
const padcookie = require('ep_etherpad-lite/static/js/pad_cookie').padcookie;
const postAceInit = function (hook, context) {
const $outer = $('iframe[name="ace_outer"]').contents().find('iframe');
const $inner = $outer.contents().find('#innerdocbody');
const spellcheck = {
enable() {
$inner.attr('spellcheck', 'true');
$inner.find('div').each(function () {
$(this).attr('spellcheck', 'true');
$(this).find('div').each(function () {
$(this).attr('spellcheck', 'true');
});
});
},
disable() {
$inner.attr('spellcheck', 'false');
$inner.find('div').each(function () {
$(this).attr('spellcheck', 'false');
$(this).find('span').each(function () {
$(this).attr('spellcheck', 'false');
});
});
},
};
/* init */
if (padcookie.getPref('spellcheck') === false) {
$('#options-spellcheck').val();
$('#options-spellcheck').attr('checked', 'unchecked');
$('#options-spellcheck').attr('checked', false);
} else {
$('#options-spellcheck').attr('checked', 'checked');
}
if ($('#options-spellcheck').is(':checked')) {
spellcheck.enable();
} else {
spellcheck.disable();
}
/* on click */
$('#options-spellcheck').on('click', () => {
if ($('#options-spellcheck').is(':checked')) {
padcookie.setPref('spellcheck', true);
spellcheck.enable();
} else {
padcookie.setPref('spellcheck', false);
spellcheck.disable();
}
if (window.browser.chrome) window.location.reload();
});
};
exports.postAceInit = postAceInit;
- I am unable understand the use of cookie here
- How exactly is the content being pushed into the spellcheck function?
- From where is the spellcheck function checking the spelling?
- Does it keep checking the entire text that the user enters or just the latest word entered by the user
Waiting for your reply! Thank You
@sonikanishk did you figure this out yet? If you are still stuck let me know and we can reopen, AFAIk you got this sorted..
Please don't leave stale issues :)