Support for grammar rule enable/disable
This commit is contained in:
		
							
								
								
									
										29
									
								
								service.js
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								service.js
									
									
									
									
									
								
							@@ -36,6 +36,8 @@ class BesService {
 | 
				
			|||||||
    this.hostElement = hostElement
 | 
					    this.hostElement = hostElement
 | 
				
			||||||
    this.textElement = textElement
 | 
					    this.textElement = textElement
 | 
				
			||||||
    this.eventSink = eventSink
 | 
					    this.eventSink = eventSink
 | 
				
			||||||
 | 
					    this.enabledRules = []
 | 
				
			||||||
 | 
					    this.disabledRules = []
 | 
				
			||||||
    this.enabledCategories = []
 | 
					    this.enabledCategories = []
 | 
				
			||||||
    this.disabledCategories = []
 | 
					    this.disabledCategories = []
 | 
				
			||||||
    this.results = [] // Results of grammar-checking, one per each block/paragraph of text
 | 
					    this.results = [] // Results of grammar-checking, one per each block/paragraph of text
 | 
				
			||||||
@@ -134,6 +136,29 @@ class BesService {
 | 
				
			|||||||
    BesService.getServiceByElement(hostElement)?.unregister()
 | 
					    BesService.getServiceByElement(hostElement)?.unregister()
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Enables given grammar rule.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @param {String} rule Rule ID. For the list of rule IDs, see /api/v2/configinfo output.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  enableRule(rule) {
 | 
				
			||||||
 | 
					    this.enabledRules.push(rule)
 | 
				
			||||||
 | 
					    this.disabledRules = this.disabledRules.filter(value => value !== rule)
 | 
				
			||||||
 | 
					    this.scheduleProofing(10)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Disables given grammar rule.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @param {String} rule Rule ID. For the list of rule IDs, see /api/v2/configinfo output.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  disableRule(rule) {
 | 
				
			||||||
 | 
					    this.enabledRules = this.enabledRules.filter(value => value !== rule)
 | 
				
			||||||
 | 
					    this.disabledRules.push(rule)
 | 
				
			||||||
 | 
					    this.scheduleProofing(10)
 | 
				
			||||||
 | 
					    return this
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Enables all grammar rules of the given category.
 | 
					   * Enables all grammar rules of the given category.
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
@@ -561,6 +586,8 @@ class BesTreeService extends BesService {
 | 
				
			|||||||
                    )
 | 
					                    )
 | 
				
			||||||
                  }),
 | 
					                  }),
 | 
				
			||||||
                  language: node.lang ? node.lang : 'sl',
 | 
					                  language: node.lang ? node.lang : 'sl',
 | 
				
			||||||
 | 
					                  enabledRules: this.enabledRules.join(','),
 | 
				
			||||||
 | 
					                  disabledRules: this.disabledRules.join(','),
 | 
				
			||||||
                  enabledCategories: this.enabledCategories.join(','),
 | 
					                  enabledCategories: this.enabledCategories.join(','),
 | 
				
			||||||
                  disabledCategories: this.disabledCategories.join(','),
 | 
					                  disabledCategories: this.disabledCategories.join(','),
 | 
				
			||||||
                  enabledOnly: 'false'
 | 
					                  enabledOnly: 'false'
 | 
				
			||||||
@@ -1196,6 +1223,8 @@ class BesPlainTextService extends BesService {
 | 
				
			|||||||
                ]
 | 
					                ]
 | 
				
			||||||
              }),
 | 
					              }),
 | 
				
			||||||
              language: this.hostElement.lang ? this.hostElement.lang : 'sl',
 | 
					              language: this.hostElement.lang ? this.hostElement.lang : 'sl',
 | 
				
			||||||
 | 
					              enabledRules: this.enabledRules.join(','),
 | 
				
			||||||
 | 
					              disabledRules: this.disabledRules.join(','),
 | 
				
			||||||
              enabledCategories: this.enabledCategories.join(','),
 | 
					              enabledCategories: this.enabledCategories.join(','),
 | 
				
			||||||
              disabledCategories: this.disabledCategories.join(','),
 | 
					              disabledCategories: this.disabledCategories.join(','),
 | 
				
			||||||
              enabledOnly: 'false'
 | 
					              enabledOnly: 'false'
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user