syntax checking & spell correction for GridJs
Contents
[
Hide
]
To perform syntax checking & spell correction on user input ,the steps are
Set load options.
for example:
const option = {
...
//set showCheckSyntaxButton to true
showCheckSyntaxButton:true,
//set checkSyntax to true
checkSyntax:true,
};
xs = x_spreadsheet('#gridjs-demo', option)
Set action URL for syntax checking & spell correction.
for example:
const checkurl = "/GridJs2/CheckSyntax";
xs.setSyntaxCheckUrl(checkurl);
After a user enters text content in a cell, the action of syntax checking wil be triggered automatically by the spreadsheet application
Implement syntax checking & spell correction in serverside.
for example:
# The logic for invoking syntax checking here can be implemented through a third-party library or custom logic.
def correct_syntax(text, locale):
# replace your logic here
return text
@app.route('/GridJs2/CheckSyntax', methods=['POST'])
def check_syntax():
text = request.form.get('v')
locale = request.form.get('locale')
if not text:
return jsonify({
'Success': False,
'v': ''
}), 200
corrected_content = correct_syntax(text, locale)
return jsonify({
'Success': True,
'v': corrected_content
}), 200