diff options
author | geireann <geireann.lindfield@gmail.com> | 2023-08-15 15:33:28 -0400 |
---|---|---|
committer | geireann <geireann.lindfield@gmail.com> | 2023-08-15 15:33:28 -0400 |
commit | 372face940712d239d48f9884ded34d82d170a94 (patch) | |
tree | d179c7a533de46c414682e90dad12aabb6779f1d /src | |
parent | 02a540ce4cd8374956245f23cfeffa8eebbaa012 (diff) |
trying to prevent colorpicker from generating undo event for every drag movement.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/FontIconBox/FontIconBox.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/client/views/nodes/FontIconBox/FontIconBox.tsx b/src/client/views/nodes/FontIconBox/FontIconBox.tsx index 91eac675f..1b2209224 100644 --- a/src/client/views/nodes/FontIconBox/FontIconBox.tsx +++ b/src/client/views/nodes/FontIconBox/FontIconBox.tsx @@ -267,20 +267,25 @@ export class FontIconBox extends DocComponent<ButtonProps>() { return ScriptCast(this.rootDoc.script); } + colorBatch:UndoManager.Batch|undefined; /** * Color button */ @computed get colorButton() { const color = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.Color); - const backgroundColor = this.props.styleProvider?.(this.rootDoc, this.props, StyleProp.BackgroundColor); const curColor = this.colorScript?.script.run({ this: this.layoutDoc, self: this.rootDoc, value: undefined, _readOnly_: true }).result ?? 'transparent'; const tooltip: string = StrCast(this.rootDoc.toolTip); return ( <ColorPicker setSelectedColor={value => { - const s = this.colorScript; - s && undoable(() => s.script.run({ this: this.layoutDoc, self: this.rootDoc, value: value, _readOnly_: false }).result, `Set ${tooltip} to ${value}`)(); + if (!this.colorBatch) this.colorBatch = UndoManager.StartBatch(`Set ${tooltip} color`); + this.colorScript?.script.run({ this: this.layoutDoc, self: this.rootDoc, value: value, _readOnly_: false }); + }} + setFinalColor={value => { + this.colorScript?.script.run({ this: this.layoutDoc, self: this.rootDoc, value: value, _readOnly_: false }); + this.colorBatch?.end(); + this.colorBatch= undefined; }} selectedColor={curColor} type={Type.PRIM} |