Refactor ruleType logic to make it accessible within other besService subclasses
This commit is contained in:
parent
54ba1dea33
commit
edbe39722f
34
service2.js
34
service2.js
@ -49,6 +49,16 @@ class BesService {
|
||||
this.resizeObserver = new ResizeObserver(this.onResize.bind(this))
|
||||
this.resizeObserver.observe(this.hostElement)
|
||||
|
||||
// TODO: Include missing rules
|
||||
// Initial user feedback indicated a requirement for clear differentiation between spelling and grammar errors.
|
||||
this.ruleTypes = {
|
||||
BESANA_1: 'bes-spelling-mistake',
|
||||
BESANA_2: 'bes-spelling-mistake',
|
||||
BESANA_3: 'bes-spelling-mistake',
|
||||
BESANA_4: 'bes-grammar-mistake',
|
||||
BESANA_5: 'bes-spelling-mistake'
|
||||
}
|
||||
|
||||
besServices.push(this)
|
||||
}
|
||||
|
||||
@ -464,18 +474,8 @@ class BesTreeService extends BesService {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Initial user feedback indicated a requirement for clear differentiation between spelling and grammar errors.
|
||||
// So to do that, we need to add a CSS class to the highlight element based on the rule type.
|
||||
const ruleTypes = {
|
||||
BESANA_1: 'bes-spelling-mistake',
|
||||
BESANA_2: 'bes-spelling-mistake',
|
||||
BESANA_3: 'bes-spelling-mistake',
|
||||
BESANA_4: 'bes-grammar-mistake',
|
||||
BESANA_5: 'bes-spelling-mistake'
|
||||
}
|
||||
const ruleType =
|
||||
ruleTypes[match.rule.id] || 'bes-spelling-mistake'
|
||||
|
||||
this.ruleTypes[match.rule.id] || 'bes-spelling-mistake'
|
||||
const { clientRects, highlights } = this.addMistakeMarkup(
|
||||
range,
|
||||
ruleType
|
||||
@ -1206,13 +1206,19 @@ class BesPlainTextService extends BesService {
|
||||
nodes[nodeIdx].node,
|
||||
matchEnd - nodes[nodeIdx].start
|
||||
)
|
||||
const { clientRects, highlights } =
|
||||
this.addMistakeMarkup(matchRange)
|
||||
|
||||
const ruleType =
|
||||
this.ruleTypes[match.rule.id] || 'bes-spelling-mistake'
|
||||
const { clientRects, highlights } = this.addMistakeMarkup(
|
||||
matchRange,
|
||||
ruleType
|
||||
)
|
||||
matches.push({
|
||||
rects: clientRects,
|
||||
highlights: highlights,
|
||||
range: matchRange,
|
||||
match: match
|
||||
match: match,
|
||||
ruleType: ruleType
|
||||
})
|
||||
})
|
||||
this.markProofed(paragraphRange, matches)
|
||||
|
Loading…
x
Reference in New Issue
Block a user