service2.js: Fix empty paragraph handling
This commit is contained in:
parent
6eac44165f
commit
e0e9f1a651
12
service2.js
12
service2.js
@ -432,9 +432,9 @@ class BesDOMService extends BesTreeService {
|
||||
case Node.ELEMENT_NODE:
|
||||
if (this.isBlockElement(node)) {
|
||||
// Block elements are grammar-checked independently.
|
||||
this.onProofing()
|
||||
let result = this.getProofing(node)
|
||||
if (result) {
|
||||
this.onProofing()
|
||||
this.onProofingProgress(result.matches.length)
|
||||
return [{ text: `<${node.tagName}/>`, node: node, markup: true }]
|
||||
}
|
||||
@ -444,6 +444,7 @@ class BesDOMService extends BesTreeService {
|
||||
data = data.concat(this.proofNode(el2, abortController))
|
||||
if (data.some(x => !x.markup && !/^\s*$/.test(x.text))) {
|
||||
// Block element contains some text.
|
||||
this.onProofing()
|
||||
const signal = abortController.signal
|
||||
fetch(
|
||||
new Request(besUrl + '/check', {
|
||||
@ -948,12 +949,16 @@ class BesPlainTextService extends BesService {
|
||||
paragraphRange.setEnd(nodes[nodeIdx].node, end - nodes[nodeIdx].start)
|
||||
while (nodeIdx < nodes.length && nodes[nodeIdx].end <= end) nodeIdx++
|
||||
|
||||
this.onProofing()
|
||||
let result = this.getProofing(paragraphRange)
|
||||
if (result) {
|
||||
this.onProofing()
|
||||
this.onProofingProgress(result.matches.length)
|
||||
continue
|
||||
}
|
||||
let paragraphText = text.substring(start, end)
|
||||
if (!/^\s*$/.test(paragraphText)) {
|
||||
// Paragraph contains some text.
|
||||
this.onProofing()
|
||||
const signal = this.abortController.signal
|
||||
fetch(
|
||||
new Request(besUrl + '/check', {
|
||||
@ -966,7 +971,7 @@ class BesPlainTextService extends BesService {
|
||||
data: JSON.stringify({
|
||||
annotation: [
|
||||
{
|
||||
text: text.substring(start, end)
|
||||
text: paragraphText
|
||||
}
|
||||
]
|
||||
}),
|
||||
@ -1016,6 +1021,7 @@ class BesPlainTextService extends BesService {
|
||||
})
|
||||
.catch(error => this.onFailedProofingResult(error))
|
||||
}
|
||||
}
|
||||
|
||||
this.onProofingProgress(0)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user