التحقق من بناء الجمل وتصحيح الإملاء لـ GridJs

لتنفيذ فحص الصياغة وتصحيح الإملاء على إدخال المستخدم ، الخطوات هي

تعيين خيارات التحميل.

على سبيل المثال:

 const option = {
     ...
     //set showCheckSyntaxButton to true
    showCheckSyntaxButton:true,
    //set checkSyntax to true
    checkSyntax:true,
 };
  xs = x_spreadsheet('#gridjs-demo', option)

تعيين عنوان URL للإجراء لفحص الصياغة وتصحيح الإملاء.

على سبيل المثال:

 const checkurl = "/GridJs2/CheckSyntax";  
 xs.setSyntaxCheckUrl(checkurl);

بعد أن يدخل المستخدم محتوى نصيًا في خلية ، سيتم تفعيل عملية فحص الصياغة تلقائيًا بواسطة تطبيق جدول البيانات

تنفيذ فحص الصياغة وتصحيح الإملاء في جانب الخادم.

على سبيل المثال:

# 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