feat: add parameter for clearing font color and highlight color #461
This commit is contained in:
@@ -284,7 +284,7 @@ Feature: Font color
|
||||
Usage:
|
||||
|
||||
```javascript
|
||||
instance.command.executeColor()
|
||||
instance.command.executeColor(color: string | null)
|
||||
```
|
||||
|
||||
## executeHighlight
|
||||
@@ -294,7 +294,7 @@ Feature: Highlight
|
||||
Usage:
|
||||
|
||||
```javascript
|
||||
instance.command.executeHighlight()
|
||||
instance.command.executeHighlight(color: string | null)
|
||||
```
|
||||
|
||||
## executeTitle
|
||||
|
||||
@@ -284,7 +284,7 @@ instance.command.executeSubscript()
|
||||
用法:
|
||||
|
||||
```javascript
|
||||
instance.command.executeColor()
|
||||
instance.command.executeColor(color: string | null)
|
||||
```
|
||||
|
||||
## executeHighlight
|
||||
@@ -294,7 +294,7 @@ instance.command.executeColor()
|
||||
用法:
|
||||
|
||||
```javascript
|
||||
instance.command.executeHighlight()
|
||||
instance.command.executeHighlight(color: string | null)
|
||||
```
|
||||
|
||||
## executeTitle
|
||||
|
||||
@@ -616,14 +616,18 @@ export class CommandAdapt {
|
||||
this.draw.render({ isSetCursor: false })
|
||||
}
|
||||
|
||||
public color(payload: string) {
|
||||
public color(payload: string | null) {
|
||||
const isDisabled =
|
||||
this.draw.isReadonly() || this.control.isDisabledControl()
|
||||
if (isDisabled) return
|
||||
const selection = this.range.getSelectionElementList()
|
||||
if (selection?.length) {
|
||||
selection.forEach(el => {
|
||||
if (payload) {
|
||||
el.color = payload
|
||||
} else {
|
||||
delete el.color
|
||||
}
|
||||
})
|
||||
this.draw.render({
|
||||
isSetCursor: false,
|
||||
@@ -634,20 +638,28 @@ export class CommandAdapt {
|
||||
const elementList = this.draw.getElementList()
|
||||
const enterElement = elementList[endIndex]
|
||||
if (enterElement?.value === ZERO) {
|
||||
if (payload) {
|
||||
enterElement.color = payload
|
||||
} else {
|
||||
delete enterElement.color
|
||||
}
|
||||
this.draw.render({ curIndex: endIndex, isCompute: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public highlight(payload: string) {
|
||||
public highlight(payload: string | null) {
|
||||
const isDisabled =
|
||||
this.draw.isReadonly() || this.control.isDisabledControl()
|
||||
if (isDisabled) return
|
||||
const selection = this.range.getSelectionElementList()
|
||||
if (selection?.length) {
|
||||
selection.forEach(el => {
|
||||
if (payload) {
|
||||
el.highlight = payload
|
||||
} else {
|
||||
delete el.highlight
|
||||
}
|
||||
})
|
||||
this.draw.render({
|
||||
isSetCursor: false,
|
||||
@@ -658,7 +670,11 @@ export class CommandAdapt {
|
||||
const elementList = this.draw.getElementList()
|
||||
const enterElement = elementList[endIndex]
|
||||
if (enterElement?.value === ZERO) {
|
||||
if (payload) {
|
||||
enterElement.highlight = payload
|
||||
} else {
|
||||
delete enterElement.highlight
|
||||
}
|
||||
this.draw.render({ curIndex: endIndex, isCompute: false })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user